#!/usr/bin/env parrot .sub "&print" get_params "(0b1010)", $P10 $S8 = join "", $P10 print $S8 set_returns "(0b10010)", 1 returncc .end .sub "&say" get_params "(0b1010)", $P10 $S8 = join "", $P10 print $S8 print "\n" set_returns "(0b10010)", 1 returncc .end .sub "&statement_control:loop" get_params "(0b10, 0b10, 0b10, 0b10)", $P10, $P11, $P12, $P13 print "==> Callee alligator #1:\n " $S99 = typeof $P12 print $S99 print " - " print $P12 print "\n" sc_loop_next: newsub $P1, .Continuation, loopCond $I8 = get_addr $P11 $S8 = set $I8 store_global $S8, $P1 invoke $P11 loopCond: find_global $P8, $S8 unless $P8, sc_loop_last newsub $P1, .Continuation, loopBody $I8 = get_addr $P12 $S8 = set $I8 print "==> Callee alligator #2:\n " $S99 = typeof $P12 print $S99 print " - " print $P12 print "\n" store_global $S8, $P1 invoke $P12 loopBody: print $P8 print "-- BACK TO BODY\n" find_global $P8, $S8 newsub $P1, .Continuation, loopPost $I8 = get_addr $P13 $S8 = set $I8 store_global $S8, $P1 invoke $P13 loopPost: find_global $P8, $S8 goto sc_loop_next sc_loop_last: returncc .end .sub "&postfix:++" get_params "(0b10)", $P10 $P2 = new .PerlUndef $P2 = assign $P10 inc $P10 set_returns "(0b10010)", $P2 returncc .end .sub "&infix:ne" get_params "(0b10, 0b10)", $P10, $P11 $P2 = new .PerlUndef $S8 = set $P10 $S9 = set $P11 $I8 = isne $S8, $S9 $P2 = assign $I8 set_returns "(0b10010)", $P2 returncc .end .namespace ['main'] .sub init @MAIN, @ANON new_pad 0 main() .end .sub main @ANON .local pmc s__x print "###### I will now demonstrate that ALLIGATOR becomes RAPTOR! ######\n\n" s__x = new .PerlUndef new_pad -1 store_lex -1, "$x", s__x ### {{{ Syn "=" {Var "$x"; ### 0} .local pmc P1_var P1_var = new .PerlUndef P1_var = find_name "$x" .local pmc P2_lit P2_lit = new .PerlUndef P2_lit = assign 0 P1_var = assign P2_lit ### }}} -e line 1, column 14-20 .local pmc P3_block newsub P3_block, .Continuation, LABEL_0_blockBegin goto LABEL_0_blockEnd LABEL_0_blockBegin: .local pmc P4_cc $I8 = get_addr P3_block $S8 = set $I8 find_global P4_cc, $S8 ### {{{ App &infix:< (: Var "$x", 10) .local pmc P5_var P5_var = new .PerlUndef P5_var = find_name "$x" .local pmc RAPTOR RAPTOR = new .PerlUndef RAPTOR = assign "RAPTOR" .local pmc P7_app P7_app = new .PerlUndef get_results "(0b10)", P7_app $P1 = find_name "&infix:ne" set_args '(0b10010, 0b10010)', P5_var, RAPTOR invokecc $P1 ### }}} -e line 1, column 22-27 P7_app = 1 store_global $S8, P7_app invoke P4_cc LABEL_0_blockEnd: .local pmc ALLIGATOR newsub ALLIGATOR, .Continuation, LABEL_1_blockBegin print "==> Original alligator:\n " $S99 = typeof ALLIGATOR print $S99 print " - " print ALLIGATOR print "\n" goto LABEL_1_blockEnd LABEL_1_blockBegin: .local pmc P9_cc print "==> Reentrant alligator (BROKEN - became RAPTOR!):\n " $S99 = typeof ALLIGATOR print $S99 print " - " print ALLIGATOR print "\n" print "\n###### Here, the program commits seppuku on itself... ######\n\n" $I8 = get_addr ALLIGATOR $S8 = set $I8 find_global P9_cc, $S8 ### {{{ App &say (: Var "$x") ### {{{ Var "$x" .local pmc P10_var P10_var = new .PerlUndef P10_var = find_name "$x" ### }}} -e line 1, column 40-43 .local pmc P11_app P11_app = new .PerlUndef get_results "(0b10)", P11_app $P1 = find_name "&say" set_args '(0b10010)', P10_var invokecc $P1 ### }}} -e line 1, column 36-43 store_global $S8, P11_app invoke P9_cc LABEL_1_blockEnd: .local pmc P12_block newsub P12_block, .Continuation, LABEL_2_blockBegin goto LABEL_2_blockEnd LABEL_2_blockBegin: .local pmc P13_cc $I8 = get_addr P12_block $S8 = set $I8 find_global P13_cc, $S8 ### {{{ App &postfix:++ (: Var "$x") .local pmc P14_var P14_var = new .PerlUndef P14_var = find_name "$x" .local pmc P15_app P15_app = new .PerlUndef get_results "(0b10)", P15_app $P1 = find_name "&postfix:++" set_args '(0b10010)', P14_var invokecc $P1 ### }}} -e line 1, column 28-32 store_global $S8, P15_app invoke P13_cc LABEL_2_blockEnd: .local pmc P16_app P16_app = new .PerlUndef get_results "(0b10)", P16_app $P1 = find_name "&statement_control:loop" set_args '(0b10010, 0b10010, 0b10010, 0b10010)', P1_var, P3_block, ALLIGATOR, P12_block invokecc $P1 .end