[svn:parrot] r44898 - in branches/ops_pct/compilers/opsc: src/Ops/Compiler t

cotto at svn.parrot.org cotto at svn.parrot.org
Fri Mar 12 07:34:45 UTC 2010


Author: cotto
Date: Fri Mar 12 07:34:43 2010
New Revision: 44898
URL: https://trac.parrot.org/parrot/changeset/44898

Log:
[opsc] fix op parsing and actions, add a test, fix some broken tests

Modified:
   branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
   branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm
   branches/ops_pct/compilers/opsc/t/07-emitter.t

Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm	Fri Mar 12 06:30:37 2010	(r44897)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm	Fri Mar 12 07:34:43 2010	(r44898)
@@ -84,6 +84,9 @@
     for $<op_body>.ast<jump> {
         $op.add_jump($_);
     }
+    if ~$<op_name> eq 'runinterp' {
+        $op.add_jump('PARROT_JUMP_RELATIVE');
+    }
     $op<flags> := %flags;
     $op<args>  := @args;
     $op<type>  := ~$<op_type>;
@@ -318,7 +321,7 @@
 
     $past<jump> := list();
 
-    if $macro_name eq 'restart_offset' || $macro_name eq 'goto_offset' {
+    if ~$<macro_type> ne 'expr' && ~$<macro_destination> eq 'OFFSET' {
         $past<jump>.push('PARROT_JUMP_RELATIVE');
     }
 

Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm	Fri Mar 12 06:30:37 2010	(r44897)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler/Grammar.pm	Fri Mar 12 07:34:43 2010	(r44898)
@@ -108,7 +108,7 @@
 }
 
 rule op_macro {
-    <macro_type> <macro_destination> '(' $<body_word>=[''|<body_word>] ')'
+    <macro_type> <macro_destination> '(' <body_word>*? ')'
     {*}
 }
 

Modified: branches/ops_pct/compilers/opsc/t/07-emitter.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/07-emitter.t	Fri Mar 12 06:30:37 2010	(r44897)
+++ branches/ops_pct/compilers/opsc/t/07-emitter.t	Fri Mar 12 07:34:43 2010	(r44898)
@@ -5,7 +5,7 @@
 pir::load_bytecode("compilers/opsc/opsc.pbc");
 pir::load_bytecode("nqp-settings.pbc");
 
-plan(21);
+plan(22);
 
 my $trans := Ops::Trans::C.new();
 
@@ -96,9 +96,16 @@
     opcode * next = expr NEXT();
 }';
 $new_body := translate_op_body($trans, $op_body);
-$restart_addr_ok := $new_body ~~ /'cur_opcode + 3;'/;
+$restart_addr_ok := $new_body ~~ /'cur_opcode + 2;'/;
 ok($restart_addr_ok, "expr NEXT() translated ok");
 
+$op_body := '
+inline op runinterp(in PMC) {
+}';
+$new_body := translate_op_body($trans, $op_body);
+$restart_addr_ok := $new_body ~~ /'PARROT_JUMP_RELATIVE'/;
+ok($restart_addr_ok, "runinterp has PARROT_JUMP_RELATIVE");
+
 #say($source);
 
 sub translate_op_body($trans, $body) {


More information about the parrot-commits mailing list