[svn:parrot] r44725 - in branches/ops_pct/compilers/opsc: . src/Ops/Trans t

bacek at svn.parrot.org bacek at svn.parrot.org
Sun Mar 7 07:50:49 UTC 2010


Author: bacek
Date: Sun Mar  7 07:50:47 2010
New Revision: 44725
URL: https://trac.parrot.org/parrot/changeset/44725

Log:
Handle args.labels

Modified:
   branches/ops_pct/compilers/opsc/TODO
   branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm
   branches/ops_pct/compilers/opsc/t/06-emitter.t

Modified: branches/ops_pct/compilers/opsc/TODO
==============================================================================
--- branches/ops_pct/compilers/opsc/TODO	Sun Mar  7 07:21:13 2010	(r44724)
+++ branches/ops_pct/compilers/opsc/TODO	Sun Mar  7 07:50:47 2010	(r44725)
@@ -2,7 +2,6 @@
 
 Required for initial self-hosting:
 
-  * Implement handling of labels in Trans::C
   * Replacement for ops2c.pl
   * Update config/gen/makefiles/root.in to use opsc instead of ops2c
 

Modified: branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm	Sun Mar  7 07:21:13 2010	(r44724)
+++ branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm	Sun Mar  7 07:50:47 2010	(r44725)
@@ -208,13 +208,11 @@
                 |map( -> $d { %arg_dir_mapping{$d<direction>} }, $op<normalized_args>)
             ) ~ ' }'
             !! '{ (arg_dir_t) 0 }';
-        my $labels := '{ '
-            ~ join(
-            ", ", '0'
-            #$op->labels
-            #? $op->labels
-            #: 0
-            ) ~ ' }';
+        my $labels := $op<normalized_args>
+            ?? '{ ' ~ join(", ",
+                |map( -> $d { $d<is_label> ?? 1 !! 0 }, $op<normalized_args>)
+            ) ~ ' }'
+            !! '{ 0 }';
 
         $fh.print('{' ~ qq|
    /* $index */

Modified: branches/ops_pct/compilers/opsc/t/06-emitter.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/06-emitter.t	Sun Mar  7 07:21:13 2010	(r44724)
+++ branches/ops_pct/compilers/opsc/t/06-emitter.t	Sun Mar  7 07:50:47 2010	(r44725)
@@ -3,13 +3,14 @@
 pir::load_bytecode("compilers/opsc/opsc.pbc");
 pir::load_bytecode("nqp-settings.pbc");
 
-plan(18);
+plan(19);
 
 my $trans := Ops::Trans::C.new();
 
 my @files := <
     src/ops/io.ops
     src/ops/sys.ops
+    src/ops/cmp.ops
 >;
 
 my $f := Ops::File.new(|@files);
@@ -62,6 +63,8 @@
 ok($source ~~ /'PREG(1)'/, 'Trans::C arg translation works');
 ok($source ~! /'OP_SIZE'/, 'Trans::C translates OP_SIZE');
 
+# "eq"
+ok($source ~~ /'0,' \s '0,' \s '1'/, "Labels handled correctly");
 
 my $op_body := '
 inline op do_stuff(invar PMC)
@@ -81,7 +84,7 @@
 ok($restart_addr_ok, "goto OFFSET() and \$1 translated ok");
 ok($new_body ~~ /'PARROT_JUMP_RELATIVE'/, "jump flags generated");
 
-#say($source);
+say($source);
 
 sub translate_op_body($trans, $body) {
     my $file  := Ops::File.new_str($body);


More information about the parrot-commits mailing list