[svn:parrot] r46487 - in branches/ops_pct: compilers/opsc compilers/opsc/src/Ops compilers/opsc/src/Ops/Compiler compilers/opsc/src/Ops/Trans config/gen/makefiles

cotto at svn.parrot.org cotto at svn.parrot.org
Tue May 11 04:27:42 UTC 2010


Author: cotto
Date: Tue May 11 04:27:41 2010
New Revision: 46487
URL: https://trac.parrot.org/parrot/changeset/46487

Log:
[opsc] make ops2c act more like ops2c.pl
dynops get translated but don't compile yet

Modified:
   branches/ops_pct/compilers/opsc/ops2c.nqp
   branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
   branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm
   branches/ops_pct/compilers/opsc/src/Ops/File.pm
   branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm
   branches/ops_pct/config/gen/makefiles/root.in

Modified: branches/ops_pct/compilers/opsc/ops2c.nqp
==============================================================================
--- branches/ops_pct/compilers/opsc/ops2c.nqp	Tue May 11 04:11:44 2010	(r46486)
+++ branches/ops_pct/compilers/opsc/ops2c.nqp	Tue May 11 04:27:41 2010	(r46487)
@@ -2,21 +2,39 @@
 
 pir::load_bytecode("compilers/opsc/opsc.pbc");
 
-my @files := <
-    src/ops/core.ops
-    src/ops/bit.ops
-    src/ops/cmp.ops
-    src/ops/debug.ops
-    src/ops/io.ops
-    src/ops/math.ops
-    src/ops/object.ops
-    src/ops/pmc.ops
-    src/ops/set.ops
-    src/ops/string.ops
-    src/ops/sys.ops
-    src/ops/var.ops
-    src/ops/experimental.ops
->;
+my @args := get_args();
+my $core := 0;
+my @files;
+my $i := 0;
+
+while ($i lt pir::elements(@args)) {
+    if (@args[$i] eq '--core') {
+        my $ops_dir := 'src/ops';
+
+        @files := <
+            src/ops/core.ops
+            src/ops/bit.ops
+            src/ops/cmp.ops
+            src/ops/debug.ops
+            src/ops/io.ops
+            src/ops/math.ops
+            src/ops/object.ops
+            src/ops/pmc.ops
+            src/ops/set.ops
+            src/ops/string.ops
+            src/ops/sys.ops
+            src/ops/var.ops
+            src/ops/experimental.ops
+        >;
+        $core := 1;
+    }
+    elsif (@args[$i] eq '--dynamic') {
+        $core := 0;
+        $i++;
+        @files.push( @args[$i] );
+    }
+    $i++;
+}
 
 
 my $trans := Ops::Trans::C.new();
@@ -26,18 +44,23 @@
 );
 
 my $start_time := pir::time__N();
-my $f := Ops::File.new(|@files, :oplib($lib));
+my $f := Ops::File.new(|@files, :oplib($lib), :core($core));
 my $end_time := pir::time__N();
 say('# Ops parsed ' ~ ($end_time - $start_time));
 my $emitter := Ops::Emitter.new(
-    :ops_file($f), :trans($trans), :script('ops2c'),
-    :flags(
-        hash( core => 1 )
+    :ops_file($f), :trans($trans),
+    :script('ops2c.nqp'), :file(@files[0]),
+    :flags( hash( core => $core )
     ),
 );
 
 $emitter.print_c_header_file();
 $emitter.print_c_source_file();
 
+sub get_args() {
+    my $interp := pir::getinterp__P();
+    $interp[2];
+}
+
 
 # vim: expandtab shiftwidth=4 ft=perl6:

Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm	Tue May 11 04:11:44 2010	(r46486)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm	Tue May 11 04:27:41 2010	(r46487)
@@ -42,10 +42,11 @@
             if ! $skiptable.exists($full_name) {
                 if $optable.exists($full_name) {
                     $op<code> := $optable{$full_name};
+                    $op<experimental> := 0;
                 }
                 else {
-                    say('# experimental. Not in ops.num ' ~ $full_name);
                     $op<code> := $CODE++;
+                    $op<experimental> := 1;
                 }
 
                 $past<ops>.push($op);
@@ -306,7 +307,7 @@
 }
 
 method body_word($/) {
-    #say('# body_word');
+    #say('# body_word: '~ ~$<word>);
     my $past;
     if $<word> {
         $past := PAST::Op.new(
@@ -415,13 +416,6 @@
     }
 }
 
-method macro_sanity_checks($/) {
-    #can't have NEXT with non-empty param
-    #must have param with OFFSET or ADDRESS
-    #can't have restart ADDRESS
-
-}
-
 # Local Variables:
 #   mode: perl6
 #   fill-column: 100

Modified: branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm	Tue May 11 04:11:44 2010	(r46486)
+++ branches/ops_pct/compilers/opsc/src/Ops/Emitter.pm	Tue May 11 04:27:41 2010	(r46487)
@@ -20,7 +20,7 @@
     # Preparing various bits.
     my $suffix := $trans.suffix();
 
-    my $base := %flags<core> ?? 'core' !! $file; #FIXME drop .ops
+    my $base := %flags<core> ?? 'core' !! subst( $file, /.ops$$/, '');
     my $base_ops_stub := $base ~ '_ops' ~ $suffix;
     my $base_ops_h    := $base_ops_stub ~ '.h';
 
@@ -28,13 +28,20 @@
     self<suffix>  := $suffix;
     self<bs>      := $base ~ $suffix ~ '_';
 
-    self<include> := "parrot/oplib/$base_ops_h";
-    self<header>  := (~%flags<dir>) ~ "include/" ~ self<include>;
-    self<source>  := (~%flags<dir>) ~ "src/ops/$base_ops_stub.c";
-
-    self<sym_export> := %flags<dynamic>
-                        ?? 'PARROT_DYNEXT_EXPORT'
-                        !! '';
+    if %flags<core> {
+        self<include> := "parrot/oplib/$base_ops_h";
+        self<header>  := (~%flags<dir>) ~ "include/" ~ self<include>;
+        self<source>  := (~%flags<dir>) ~ "src/ops/$base_ops_stub.c";
+    }
+    else {
+        self<include> := $base ~ "_ops.h";
+        self<header>  := self<include>;
+        self<source>  := $base ~ "_ops.c";
+    }
+
+    self<sym_export> := %flags<core>
+                        ?? ''
+                        !! 'PARROT_DYNEXT_EXPORT';
 
     self<init_func>  := join('_',
         'Parrot', 'DynOp', $base ~ $suffix, |$ops_file.version );
@@ -173,7 +180,7 @@
 
 method _emit_dymanic_lib_load($fh) {
 
-    if ! self.flags<dynamic> {
+    if self.flags<core> {
         return;
     }
 
@@ -257,7 +264,7 @@
  */
 |);
 
-    if self.flags<dynamic> {
+    if !self.flags<core> {
         $fh.print("#define PARROT_IN_EXTENSION\n");
     }
 

Modified: branches/ops_pct/compilers/opsc/src/Ops/File.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/File.pm	Tue May 11 04:11:44 2010	(r46486)
+++ branches/ops_pct/compilers/opsc/src/Ops/File.pm	Tue May 11 04:27:41 2010	(r46487)
@@ -183,12 +183,17 @@
 
 =end
 
-method new(*@files, :$oplib!, :$nolines) {
+method new(*@files, :$oplib!, :$nolines, :$core) {
     self<files>   := @files;
     self<oplib>   := $oplib;
+    self<core>    := $core;
     self<ops>     := list(); # Ops
     self<preamble>:= '';
 
+    if !self<core> {
+        self<file> := @files[0];
+    }
+
     self<compiler>:= pir::compreg__Ps('Ops');
     self<compiler>.set_oplib($oplib);
 
@@ -246,6 +251,9 @@
     my $past     := $compiler.compile($str, :target('past'));
 
     for @($past<ops>) {
+        if $_<experimental> && self<core> {
+            say("# Experimental op " ~ $_.full_name ~ " is not in ops.num.");
+        }
         self<ops>.push($_);
     }
 

Modified: branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm	Tue May 11 04:11:44 2010	(r46486)
+++ branches/ops_pct/compilers/opsc/src/Ops/Trans/C.pm	Tue May 11 04:27:41 2010	(r46487)
@@ -255,7 +255,7 @@
 
 method emit_op_lookup($emitter, $fh) {
 
-    if $emitter.flags<dynamic> {
+    if !$emitter.flags<core> {
         return;
     }
 

Modified: branches/ops_pct/config/gen/makefiles/root.in
==============================================================================
--- branches/ops_pct/config/gen/makefiles/root.in	Tue May 11 04:11:44 2010	(r46486)
+++ branches/ops_pct/config/gen/makefiles/root.in	Tue May 11 04:27:41 2010	(r46487)
@@ -234,8 +234,6 @@
 #
 ###############################################################################
 
-GEN_OPSFILES =
-
 GEN_HEADERS = \
     $(INC_DIR)/vtable.h \
     $(INC_DIR)/oplib/ops.h \
@@ -330,7 +328,6 @@
     $(LIBRARY_DIR)/postgres.pbc
 
 FLUID_FILES_1 = \
-    $(GEN_OPSFILES) \
     $(GEN_HEADERS) \
     $(GEN_SOURCES) \
     $(GEN_MODULES) \
@@ -499,7 +496,7 @@
 #IF(platform_asm):    src/platform_asm$(O) \
 
 
-OPS_FILES = @ops@ $(GEN_OPSFILES)
+OPS_FILES = @ops@
 
 ###############################################################################
 #
@@ -798,11 +795,11 @@
 installable: all $(INSTALLABLEPARROT) $(INSTALLABLEPDUMP) $(INSTALLABLEDIS) $(INSTALLABLEPDB) $(INSTALLABLEPBC_MERGE) $(INSTALLABLEPBCTOEXE) $(INSTALLABLECONFIG) $(INSTALLABLENQP) $(INSTALLABLENCITHUNKGEN) $(INSTALLABLETAPIR)
 
 bootstrap-ops : opsc
-	$(NQP_RX) compilers/opsc/ops2c.nqp
+	$(NQP_RX) compilers/opsc/ops2c.nqp --core
 	make
 
 bootstrap-ops-test : opsc
-	$(NQP_RX) compilers/opsc/ops2c.nqp
+	$(NQP_RX) compilers/opsc/ops2c.nqp --core
 	make test
 
 runtime/parrot/include/parrotlib.pbc: runtime/parrot/library/parrotlib.pir $(PARROT) $(GEN_PASM_INCLUDES)


More information about the parrot-commits mailing list