|
Perl 6
SMOP Mold: Revision 29
(Mold is currently under implementation) A Mold block(?) is composed of three parts
The registers 1,2,3 are initialised with
OpcodesCall$target = $invocant.$method_name($pos1,$pos2,:$named1($named1_value)...) Creates a capture and calls method whose name is stored in $method_name using the responder interface of $invocant Call2$target = $invocant.$method_name(|$catpure) Gotogoto label Jumps to label Brif $condition {goto iftrue} else {goto iffalse} Jumps to iiftrue if $condition is equal to a native True, to iffalse if it's equal to False, aborts executions and prints out an error otherwise (TODO throw an exception) Exampe$*OUT.print("hello world\n") is translated to
# register declarations
my $r10;
my $r11;
my $r12; # we have to store even unused return values somewhere
# constants
my $r4 = $SMOP__S1P__RootNamespace;
my $r5 = "postcircumfix:{ }";
my $r6 = "$*OUT";
my $r7 = "FETCH";
my $r8 = "print";
my $r9 = "hello world\n";
#opcodes
$r10 = $r4.$r5($r6);
$r11 = $r10.$r7();
$r12 = $r11.$r8($r9);
The opcodes part ultimatly compiles to such byte code # will be filled in tomorrow |