develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35460 - trunk/compilers/pirc/src

From:
kjs
Date:
January 12, 2009 15:14
Subject:
[svn:parrot] r35460 - trunk/compilers/pirc/src
Message ID:
20090112231424.0545FCBA08@x12.develooper.com
Author: kjs
Date: Mon Jan 12 15:14:23 2009
New Revision: 35460

Modified:
   trunk/compilers/pirc/src/bcgen.c
   trunk/compilers/pirc/src/main.c
   trunk/compilers/pirc/src/pircapi.c
   trunk/compilers/pirc/src/pircompunit.c
   trunk/compilers/pirc/src/piremit.c

Log:
[pirc] commen out all line noise and add infrastructure to run the code after compilation. Use: ./pirc -x -b foo.pir. -x for 'execute after compile' and -b for 'compile to bytecode'. Multiple :main flags does not work correctly: it should run the last :main marked sub. It doesn't.

Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c	(original)
+++ trunk/compilers/pirc/src/bcgen.c	Mon Jan 12 15:14:23 2009
@@ -480,7 +480,9 @@
 opcode_t
 emit_opcode(bytecode * const bc, opcode_t op) {
     *bc->opcursor = op;
+/*
     fprintf(stderr, "\n[%d]", op);
+*/
     return (bc->opcursor++ - bc->interp->code->base.data);
 
 }
@@ -500,7 +502,9 @@
 opcode_t
 emit_int_arg(bytecode * const bc, int intval) {
     *bc->opcursor = intval;
+/*
     fprintf(stderr, "{%d}", intval);
+*/
     return (bc->opcursor++ - bc->interp->code->base.data);
 }
 

Modified: trunk/compilers/pirc/src/main.c
==============================================================================
--- trunk/compilers/pirc/src/main.c	(original)
+++ trunk/compilers/pirc/src/main.c	Mon Jan 12 15:14:23 2009
@@ -81,6 +81,7 @@
     "  -S        do not perform strength reduction\n"
     "  -v        verbose mode\n"
     "  -W        show warning messages\n"
+    "  -x        execute code after compilation\n"
 #ifdef YYDEBUG
     "  -y        debug bison-generated parser\n"
 #endif
@@ -136,6 +137,17 @@
 
 
 
+static void
+runcode(PARROT_INTERP, int argc, char *argv[]) {
+
+    /* runs :init functions */
+    PackFile_fixup_subs(interp, PBC_MAIN, NULL);
+
+    /* RT#46149 no return value :-( */
+    Parrot_runcode(interp, argc, argv);
+}
+
+
 
 /*
 
@@ -152,6 +164,7 @@
     char const * const program_name = argv[0];
     int                flexdebug    = 0;
     int                flags        = 0;
+    int                execute      = 0;
     char              *filename     = NULL;
     char              *outputfile   = NULL;
     char              *hdocoutfile  = NULL;
@@ -231,6 +244,9 @@
             case 'W':
                 SET_FLAG(flags, LEXER_FLAG_WARNINGS);
                 break;
+            case 'x':
+                execute = 1;
+                break;
 /* Only allow for debug flag if the generated parser supports it */
 #ifdef YYDEBUG
             case 'y':
@@ -327,7 +343,13 @@
     }
 
     parse_file(interp, flexdebug, file, filename, flags, 0, macrosize, outputfile);
+/*
     fprintf(stderr, "done\n");
+*/
+
+    if (execute)
+        runcode(interp, argc, argv);
+
 }
 #endif
 

Modified: trunk/compilers/pirc/src/pircapi.c
==============================================================================
--- trunk/compilers/pirc/src/pircapi.c	(original)
+++ trunk/compilers/pirc/src/pircapi.c	Mon Jan 12 15:14:23 2009
@@ -136,8 +136,10 @@
 
 
     /* XXX just want to make sure pirc doesn't segfault when doing bytecode stuff. */
+/*
     if (TEST_FLAG(lexer->flags, LEXER_FLAG_OUTPUTPBC))
         fprintf(stderr, "pirc ok\n");
+*/
 
     /* clean up after playing */
     release_resources(lexer);
@@ -214,8 +216,10 @@
         emit_pbc(lexer);
     }
 
-
+/*
     fprintf(stderr, "ok\n");
+*/
+
     /* clean up after playing */
     release_resources(lexer);
 

Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c	(original)
+++ trunk/compilers/pirc/src/pircompunit.c	Mon Jan 12 15:14:23 2009
@@ -2134,6 +2134,9 @@
     key_entry *iter   = keylist->head;
 
     /* goto end of list */
+    /* XXX this could be optimized by having key_entries stored in
+     * a circular linked list. Fix later.
+     */
     while (iter->next != NULL)
         iter = iter->next;
 

Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c	(original)
+++ trunk/compilers/pirc/src/piremit.c	Mon Jan 12 15:14:23 2009
@@ -989,7 +989,9 @@
     write_pbc_file(lexer->bc, "a.pbc");  /* XXX fix output file specified by user */
 
     /* XXX just make sure no seg. faults  happened */
+/*
     fprintf(stderr, "done writing pbc\n");
+*/
 }
 
 /*



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About