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

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Mar 8 20:11:44 UTC 2010


Author: bacek
Date: Mon Mar  8 20:11:43 2010
New Revision: 44775
URL: https://trac.parrot.org/parrot/changeset/44775

Log:
Don't parse ops in OpLib

Modified:
   branches/ops_pct/compilers/opsc/src/Ops/OpLib.pm
   branches/ops_pct/compilers/opsc/t/05-oplib.t

Modified: branches/ops_pct/compilers/opsc/src/Ops/OpLib.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/OpLib.pm	Mon Mar  8 19:58:31 2010	(r44774)
+++ branches/ops_pct/compilers/opsc/src/Ops/OpLib.pm	Mon Mar  8 20:11:43 2010	(r44775)
@@ -25,8 +25,7 @@
 
 =begin SYNOPSIS
 
-    my $oplib := Ops::OpLib.new.BUILD(
-        :files(@files),
+    my $oplib := Ops::OpLib.new(
         :num_file('../../src/ops/ops.num'),
         :skip_file('../../src/ops/ops.skip'),
     ));
@@ -37,16 +36,6 @@
 
 =over 4
 
-=item * C<@.files>
-
-Op files. Mandatory argument of C<BUILD> method.
-
-=item * C<@.ops_past>
-
-List of parsed ops. Currently as C<PAST::Block>, but we probably will use
-more specific class inherited from C<PAST::Block> to provide some helper
-methods.
-
 =item * C<$.max_op_num>
 
 Scalar holding number of highest non-experimental op.  Example:
@@ -96,7 +85,7 @@
 
 =over 4
 
-=item C<BUILD>
+=item C<new>
 
 Build OpLib.
 
@@ -104,14 +93,9 @@
 
 =end METHODS
 
-method new(:@files, :$num_file, :$skip_file) {
-    # Process arguments
-    if + at files == 0 {
-        die("We need some files!")
-    }
-    self<files>      := @files;
-    self<num_file>   := $num_file  || './src/ops/ops.num';
-    self<skip_file>  := $skip_file || './src/ops/ops.skip';
+method new(:$num_file, :$skip_file) {
+    self<num_file>   := $num_file  // './src/ops/ops.num';
+    self<skip_file>  := $skip_file // './src/ops/ops.skip';
 
     # Initialize self.
     self<max_op_num> := 0;
@@ -126,53 +110,6 @@
 
 =begin METHODS
 
-=item C<parse_ops>
-
-Parse all ops files passed to BUILD method. Create self.ops list for parsed
-ops.  This function is used primarily for testing.  When invoked directly, the
-HLLCompiler sets the past directly.
-
-=end METHODS
-
-method parse_ops() {
-    for self.files() {
-        for @(self.parse_ops_file($_)) {
-            self<ops_past>.push($_);
-        }
-    }
-}
-
-=begin METHODS
-
-=item C<parse_ops_file>
-
-Parse single ops file. Returns list of parsed ops.
-
-=end METHODS
-
-method parse_ops_file($file) {
-    my $parser := self._get_compiler();
-    my $buffer := slurp($file);
-    my $past   := $parser.compile($buffer, :target('past'));
-    #_dumper($past);
-    #say($file ~ ' ' ~ +@($past<ops>));
-    $past<ops>;
-}
-
-=begin METHODS
-
-=item C<set_ops_past>
-
-Assign an already-constructed past tree to self.
-
-=end METHODS
-
-method set_ops_past($past) {
-    self<ops_past> := $past;
-}
-
-=begin METHODS
-
 =item C<load_op_map_files>
 
 Load ops.num and ops.skip files.
@@ -184,128 +121,6 @@
     self._load_skip_file;
 }
 
-=begin METHODS
-
-=item C<build_ops>
-
-Take C<ops_past> and do any runcore-agnostic processing on it.  This means such
-things as expanding opcodes with C<in> params into multiple functions,
-determining jump flags, etc.
-
-=end METHODS
-
-method build_ops() {
-    
-    #ops.num is guaranteed not to have any holes, but the ordering also comes
-    #from all the .ops files catted together.  It should be sufficient to go
-    #through the past, expanding ops to opfuncs as necessary and simply
-    #verifying that they end up with the right number.  A special case is
-    #experimental.ops, which don't appear in ops.num.
-
-    my $op_num := 0;
-
-    for self<ops_past><ops>.iterator {
-        my $cur_op := $_;
-        say("found an op: "~ ~$_<name>);
-        #my $jump_flags := self.get_jump_flags($cur_op);
-        #figure out all the constant data: flags, name, etc
-        #build an array of args
-        #$args := [ [] ];
-        #for eq:
-        #     [ [ {'dir'=>'in', 'type'=>'ic', 'label'=>0}, {'dir'=>'in', 'type'=>'i', 'label'=>0} ] , ...
-
-
-
-        #check for any skiplisted long opnames before adding them to ops
-
-    }
-
-    #'JUMP' => '0',
-    #'NAME' => 'end',
-    #'FLAGS' => {
-    #    '' => undef,
-    #    'flow' => undef,
-    #    'check_event' => undef,
-    #    'base_core' => undef
-    #},
-    #'ARGDIRS' => [],
-    #'TYPE' => 'inline',
-    #'CODE' => 0,
-    #'ARGS' => [],
-    #'BODY' => '#line 53 "src/ops/core.ops"
-    #{{=0}};
-    #',
-    #'LABELS' => []
-
-
-}
-
-=begin METHODS
-
-=item C<get_jump_flags>
-
-Process the body of this op to figure out which jump flags need to be set.
-
-=end METHODS
-
-method get_jump_flags($op) {
-    my %jumps;
-    my @jumps;
-
-    #figure out which control flow flags need to be set for this op
-    if (match( " 'goto' \s+ 'ADDRESS' ", ~$op)) {
-        %jumps{'PARROT_JUMP_ADDRESS'} := 1;
-    }
-
-    if (match( " 'goto' \s+ 'OFFSET' ", ~$op) ||
-        $op.name eq 'runinterp' ) {
-        %jumps{'PARROT_JUMP_RELATIVE'} := 1;
-    }
-
-    if (match( " 'goto' \s+ 'POP' ", ~$op)) {
-        %jumps{'PARROT_JUMP_POP'} := 1;
-    }
-
-    if (match( " 'expr' \s+ 'NEXT' ", ~$op) ||
-        $op.name eq 'runinterp' ) {
-        %jumps{'PARROT_JUMP_ENEXT'} := 1;
-    }
-
-    if (match( " 'restart' \s+ 'OFFSET' ", ~$op)) {
-        %jumps{'PARROT_JUMP_RELATIVE'} := 1;
-        %jumps{'PARROT_JUMP_RESTART'}  := 1;
-    }
-    elsif (match( " 'restart' \s+ 'OFFSET' ", ~$op)) {
-        %jumps{'PARROT_JUMP_RESTART'} := 1;
-        %jumps{'PARROT_JUMP_ENEXT'}   := 1;
-    }
-    elsif ($op.name eq 'branch_cs' || $op.name eq 'returncc' ) {
-        %jumps{'PARROT_JUMP_RESTART'} := 1;
-    }
-    elsif (match( " 'restart' \s+ 'ADDRESS' ", ~~$op)) {
-        %jumps{'PARROT_JUMP_RESTART'} := 1;
-        %jumps{'PARROT_JUMP_ENEXT'}   := 0;
-    }
-
-    #XXX: need to handle PARROT_JUMP_GNEXT
-
-    for %jumps {
-        if %jumps{$_} {
-            @jumps.push($_);
-        }
-    }
-
-    if + at jumps == 0 {
-        $op<jump_flags> := '0';
-    }
-    else {
-        $op<jump_flags> := join('|', @jumps);
-    }
-    say(~$op<jump_flags>);
-}
-
-
-
 my method _load_num_file() {
     # slurp isn't very efficient. But extending NQP beyond bare minimum is not in scope.
     my $buf := slurp(self<num_file>);
@@ -374,22 +189,12 @@
 }
 
 
-method _get_compiler() {
-    Q:PIR { 
-        %r = compreg 'Ops'
-    };
-}
-
 =begin ACCESSORS
 
 Various methods for accessing internals.
 
 =over 4
 
-=item * C<ops_past>
-
-=item * C<files>
-
 =item * C<max_op_num>
 
 =item * C<optable>
@@ -398,14 +203,6 @@
 
 =end ACCESSORS
 
-method ops_past() {
-    self<ops_past>;
-}
-
-method files() {
-    self<files>;
-}
-
 method max_op_num() {
     self<max_op_num>;
 }

Modified: branches/ops_pct/compilers/opsc/t/05-oplib.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/05-oplib.t	Mon Mar  8 19:58:31 2010	(r44774)
+++ branches/ops_pct/compilers/opsc/t/05-oplib.t	Mon Mar  8 20:11:43 2010	(r44775)
@@ -4,25 +4,13 @@
 
 pir::load_bytecode("compilers/opsc/opsc.pbc");
 
-plan(6);
-
-my @files := ('src/ops/core.ops', 'src/ops/math.ops');
+plan(5);
 
 my $lib := Ops::OpLib.new(
-    :files(@files),
     :num_file('src/ops/ops.num'),
     :skip_file('src/ops/ops.skip'),
 );
 
-$lib.parse_ops();
-
-# 84 core
-# 116 math
-# We generate all variants during compilation. So check for ">"
-ok(+($lib.ops_past) > 84 + 116, "ops file parsed");
-say("# count " ~+$lib.ops_past);
-#_dumper($lib.ops_past);
-
 # It's 1258 currently. But testing for exact match isn't nessary.
 ok( $lib.max_op_num > 1200, "ops.num file parsed");
 


More information about the parrot-commits mailing list