Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created February 24, 2013 13:43
Show Gist options
  • Save jnthn/5023898 to your computer and use it in GitHub Desktop.
Save jnthn/5023898 to your computer and use it in GitHub Desktop.
use QASTJVM;
# Build a simple QAST tree.
my $cu := QAST::CompUnit.new();
my $b := QAST::Block.new(
QAST::Op.new(
:op('say'),
QAST::SVal.new( :value('JVM compiles QAST to JVM') )
));
$cu.push($b);
$cu.main(QAST::Op.new(
:op('call'),
QAST::BVal.new( :value($b) )
));
# Compile it.
my $jast := QAST::CompilerJAST.jast($cu, :classname('JVMOnJVM'));
say($jast.dump);
$ nqp nqp-jvm-cc.nqp cj.nqp > JVMOnJVM.dump
$ java -cp bin;3rdparty/bcel/bcel-5.2.jar org/perl6/nqp/jast2bc/JASTToJVMBytecode JVMOnJVM.dump JVMOnJVM.class
$ java -cp .;bin;3rdparty/bcel/bcel-5.2.jar JVMOnJVM
JVM compiles QAST to JVM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment