[svn:parrot] r40055 - in branches/ops_pct/compilers/opsc: ops t

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Jul 13 13:34:34 UTC 2009


Author: bacek
Date: Mon Jul 13 13:34:33 2009
New Revision: 40055
URL: https://trac.parrot.org/parrot/changeset/40055

Log:
[opsc] Implement parsing of skip file

Modified:
   branches/ops_pct/compilers/opsc/ops/oplib.pm
   branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t

Modified: branches/ops_pct/compilers/opsc/ops/oplib.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/ops/oplib.pm	Mon Jul 13 13:17:07 2009	(r40054)
+++ branches/ops_pct/compilers/opsc/ops/oplib.pm	Mon Jul 13 13:34:33 2009	(r40055)
@@ -94,6 +94,8 @@
 
     my %optable;
     self<optable>    := %optable;
+    my %skiptable;
+    self<skiptable>  := %skiptable;
     self<ops>        := <>;
 
     self;
@@ -180,20 +182,20 @@
 method _load_skip_file() {
 ##    open $op, '<', $skip_file
 ##        or die "Can't open $skip_file: $!";
+    # slurp isn't very efficient. But extending NQP beyond bare minimum is not in scope.
+    my $buf     := slurp(self<skip_file>);
+    my @lines   := split("\n", $buf);
+
 ##    while (<$op>) {
-##        chomp;
-##        s/#.*$//;
-##        s/\s*$//;
-##        s/^\s*//;
-##        next unless $_;
-##        ($name) = split( /\s+/, $_ );
-##        if ( exists $self->{optable}{$name} ) {
-##            die "skipped opcode is also in $num_file:$.";
-##        }
-##        $self->{skiptable}{$name} = 1;
-##    }
-##    undef $op;
-##    return 1;
+    for @lines {
+        # XXX Bit ugly. But I don't know how to invoke ~~ in NQP...
+        if /^^ \S+ $$/($_) {
+            if ( exists( self<optable>, $_) ) {
+                die("skipped opcode '$_' is also in num_file");
+            }
+            self<skiptable>{$_} := 1;
+        }
+    }
 }
 
 
@@ -211,14 +213,19 @@
     self<files>;
 }
 
+method max_op_num() {
+    self<max_op_num>;
+}
+
 method optable() {
     self<optable>;
 }
 
-method max_op_num() {
-    self<max_op_num>;
+method skiptable() {
+    self<skiptable>;
 }
 
+
 # Local Variables:
 #   mode: perl6
 #   fill-column: 100

Modified: branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t	Mon Jul 13 13:17:07 2009	(r40054)
+++ branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t	Mon Jul 13 13:34:33 2009	(r40055)
@@ -7,7 +7,7 @@
     load_bytecode "opsc_core.pbc"
 >;
 
-plan(4);
+plan(6);
 
 my @files := qw{
     ../../src/ops/core.ops
@@ -34,4 +34,7 @@
 ok( $lib.optable<end> == 0, "'end' have code 0");
 ok( $lib.optable<set_args_pc> == 42, "'set_args_pc' have code 42");
 
+ok( $lib.skiptable<abs_i_ic>,       "'abs_i_ic' in skiptable");
+ok( $lib.skiptable<ne_nc_nc_ic>,    "'ne_nc_nc_ic' in skiptable");
+
 # vim: expandtab shiftwidth=4 ft=perl6:


More information about the parrot-commits mailing list