develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34692 - trunk/compilers/pirc/new

From:
kjs
Date:
December 31, 2008 01:13
Subject:
[svn:parrot] r34692 - trunk/compilers/pirc/new
Message ID:
20081231091331.9DA39CB9FA@x12.develooper.com
Author: kjs
Date: Wed Dec 31 01:13:28 2008
New Revision: 34692

Modified:
   trunk/compilers/pirc/new/bcgen.c
   trunk/compilers/pirc/new/bcgen.h
   trunk/compilers/pirc/new/pircompunit.c
   trunk/compilers/pirc/new/piremit.c

Log:
[pirc] Fix build: PMCNULL was not defined. Re-#define it, as #include parrot/interpreter.h which defines it does not help.
+ whitespace fixes
+ remove dependency of bcgen on pirsymbol. 
+ debug stuff.

Modified: trunk/compilers/pirc/new/bcgen.c
==============================================================================
--- trunk/compilers/pirc/new/bcgen.c	(original)
+++ trunk/compilers/pirc/new/bcgen.c	Wed Dec 31 01:13:28 2008
@@ -4,12 +4,22 @@
  */
 #include <stdio.h>
 #include <assert.h>
+
+
 #include "parrot/parrot.h"
-#include "parrot/embed.h"
+
+/* #include "parrot/interpreter.h" */
+
+/* #include "parrot/embed.h" */
 
 #include "bcgen.h" /* XXX future maybe parrot/bcgen.h */
 
-#include "pirsymbol.h" /* XXX remove this dependency somehow. */
+
+/* XXX Fix the build for now; #including parrot/interpreter.h that
+   defines this doesn't seem to help. */
+#ifndef PMCNULL
+#  define PMCNULL         ((PMC *)NULL)
+#endif
 
 /*
 
@@ -433,7 +443,7 @@
     /* A type_count of 1 means there was a :multi flag, but no :multi types.
      * therefore, create a special signature and return that.  */
     if (type_count == 1)
-        return pmc_new(interp, enum_class_FixedIntegerArray);
+        return pmc_new(bc->interp, enum_class_FixedIntegerArray);
 
     /* create a FixedPMCArray to store all multi types */
     multi_signature = pmc_new(bc->interp, enum_class_FixedPMCArray);
@@ -509,7 +519,7 @@
                 lexiter->info->color);
 
 */
-        Parrot_PCCINVOKE(bc->interp, lex_info, method, "SI->", lexname, lexiter->info->color);
+        Parrot_PCCINVOKE(bc->interp, lex_info, method, "SI->", lexname, lexiter->color);
 
         lexiter = lexiter->next;
     }

Modified: trunk/compilers/pirc/new/bcgen.h
==============================================================================
--- trunk/compilers/pirc/new/bcgen.h	(original)
+++ trunk/compilers/pirc/new/bcgen.h	Wed Dec 31 01:13:28 2008
@@ -26,7 +26,7 @@
 /* struct to represent a MULTI_TYPE_KEYED multi_type */
 typedef struct multi_key_type {
 
-    struct multi_key_type * next;
+    struct multi_key_type *next;
 } multi_key_type;
 
 
@@ -34,8 +34,8 @@
 typedef struct multi_type {
 
     union multi_union {
-        char const     * ident;
-        multi_key_type   key;
+        char const     *ident;
+        multi_key_type  key;
     } u;
 
     multi_entry entry_type;
@@ -48,9 +48,9 @@
  * sub.
  */
 typedef struct lexical {
-    char const     * name;
-    struct syminfo * info;
-    struct lexical * next;
+    char const     *name;
+    int            *color;
+    struct lexical *next;
 
 } lexical;
 
@@ -59,18 +59,18 @@
  * generator needs to know.
  */
 typedef struct sub_info {
-    char const         * subname;
-    char const         * nsentry;
-    char const         * subid;
-    char const         * outersub;
-    int                  vtable_index;
-    unsigned             regs_used[4];
-    int                  startoffset;
-    int                  endoffset;
-    unsigned             num_multi_types; /* number of multi types */
-    multi_type         * multi_types;   /* array with :multi data types, if this is a multi sub */
-    lexical            * lexicals;
-    multi_type         * name_space; /* can be a string or key */
+    char const    *subname;
+    char const    *nsentry;
+    char const    *subid;
+    char const    *outersub;
+    int            vtable_index;
+    unsigned       regs_used[4];
+    int            startoffset;
+    int            endoffset;
+    unsigned       num_multi_types; /* number of multi types */
+    multi_type    *multi_types;   /* array with :multi data types, if this is a multi sub */
+    lexical       *lexicals;
+    multi_type    *name_space; /* can be a string or key */
 
 } sub_info;
 

Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c	(original)
+++ trunk/compilers/pirc/new/pircompunit.c	Wed Dec 31 01:13:28 2008
@@ -638,7 +638,6 @@
     else
         add_target(lexer, CURRENT_SUB(lexer)->parameters, targ);
 
-
     /* set the parameter just added as curtarget */
     lexer->curtarget = targ;
 
@@ -653,6 +652,8 @@
     /* set a pointer from the target to the symbol info object */
     targ->info = &sym->info;
 
+
+
     return targ;
 }
 
@@ -1752,7 +1753,7 @@
 set_lex_flag(lexer_state * const lexer, target * const t, char const * const name) {
     lexical *lex = (lexical *)pir_mem_allocate(lexer, sizeof (lexical));
     lex->name    = name;
-    lex->info    = t->info;
+    lex->color   = &t->info->color;
 
     /* link this lex node in the list of lexicals */
     lex->next = CURRENT_SUB(lexer)->info.lexicals;

Modified: trunk/compilers/pirc/new/piremit.c
==============================================================================
--- trunk/compilers/pirc/new/piremit.c	(original)
+++ trunk/compilers/pirc/new/piremit.c	Wed Dec 31 01:13:28 2008
@@ -117,6 +117,7 @@
 */
 void
 print_target(lexer_state * const lexer, target * const t) {
+    if (t->info)
     fprintf(out, "%c%d", pir_register_types[t->info->type], t->info->color);
 
     /* if the target has a key, print that too */
@@ -770,11 +771,17 @@
 /*
     fprintf(stderr, "emit_pbc(): starting...\n");
 */
+
+    /* after everything is parsed we know how many instructions and operands
+     * there are, and thus how many bytes must be allocated for emitting
+     * the bytecode. At this point we can create the codesegment.
+     */
     create_codesegment(lexer->bc, lexer->codesize);
 
 /*
     fprintf(stderr, "ok 1\n");
 */
+    /* initialize iterator */
     subiter = lexer->subs->next;
 
     assert(subiter);
@@ -790,8 +797,7 @@
     while (subiter != lexer->subs->next);
 
     /* write the output to a file. */
-
-    write_pbc_file(lexer->bc, "a.pbc");
+    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