Author: kjs
Date: Sun Jan  4 07:06:01 2009
New Revision: 34919

Modified:
   trunk/compilers/pirc/src/pir.y
   trunk/compilers/pirc/src/pircompunit.c
   trunk/compilers/pirc/src/pirparser.c
   trunk/compilers/pirc/src/pirsymbol.c

Log:
[pirc] more .const stuff.

Modified: trunk/compilers/pirc/src/pir.y
==============================================================================
--- trunk/compilers/pirc/src/pir.y      (original)
+++ trunk/compilers/pirc/src/pir.y      Sun Jan  4 07:06:01 2009
@@ -2007,11 +2007,11 @@
                       ;
 
 const_decl            : ".const" const_tail
-                            { store_global_constant(lexer, $2); }
+                            { /*store_global_constant(lexer, $2); */}
                       ;
 
 globalconst_decl      : ".globalconst" const_tail
-                            { /* XXX is .globalconst to be kept? */ }
+                            { store_global_constant(lexer, $2); }
                       ;
 
 const_tail            : "int" identifier '=' TK_INTC

Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c      (original)
+++ trunk/compilers/pirc/src/pircompunit.c      Sun Jan  4 07:06:01 2009
@@ -1295,11 +1295,10 @@
 
 /*
 
-=item C<constant *
+=item C<constdecl *
 new_named_const(lexer_state * const lexer, value_type type, char * const name, 
...)>
 
-Creates a new constant node of the given type, by the given name.
-Wrapper function for C<create_const>.
+Creates a new constdecl node of the given type, by the given name.
 
 =cut
 
@@ -1331,19 +1330,19 @@
             panic(lexer, "unknown data type in create_const() (%d)", type);
             break;
     }
-
+    va_end(arg_ptr);
     c->name = name;
     c->type = type;
-    va_end(arg_ptr);
+
     return c;
 }
 
 /*
 
-=item C<constant *
+=item C<constdecl *
 new_pmc_const(char const * const type, char const * const name, constant * 
const value)>
 
-Create a new PMC constant of type C<type>, name C<name> and having a value 
C<value>.
+Create a new PMC constant declaration of type C<type>, name C<name> and having 
a value C<value>.
 The type must be a string indicating a valid type name (e.g. "Sub"). C<name> 
is the name
 of the constant, and the value of the constant is passed as C<value>.
 
@@ -1389,7 +1388,9 @@
         new_sub_instr(lexer, PARROT_OP_set_p_pc, "set_p_pc", 0);
         push_operand(lexer, expr_from_target(lexer, consttarg));
         push_operand(lexer, expr_from_const(lexer, value));
-
+        /*set_instrf(lexer, "set", "%T%C", consttarg, value);
+        get_opinfo(lexer->yyscanner);
+        */
         decl->name     = name;
         decl->type     = PMC_VAL;
         decl->val.pval = value->val.sval;
@@ -1417,6 +1418,11 @@
             push_operand(lexer, expr_from_target(lexer, consttarg));
             push_operand(lexer, expr_from_int(lexer, index));
 
+            /* declaration of an Integer means it's a PMC, not an INT_TYPE */
+            decl->name     = name;
+            decl->type     = PMC_VAL;
+            decl->val.pval = value->val.sval;
+
         }
         else {
             yypirerror(lexer->yyscanner, lexer,
@@ -1444,6 +1450,10 @@
             push_operand(lexer, expr_from_target(lexer, consttarg));
             push_operand(lexer, expr_from_int(lexer, index));
 
+            decl->name     = name;
+            decl->type     = PMC_VAL;
+            decl->val.pval = value->val.sval;
+
         }
         else {
             yypirerror(lexer->yyscanner, lexer,
@@ -1458,9 +1468,11 @@
             symbol *constsym  = new_symbol(lexer, name, PMC_TYPE);
             target *consttarg = target_from_symbol(lexer, constsym);
 
-            PMC *strconst = pmc_new(lexer->interp,
+            PMC    *strconst  = pmc_new(lexer->interp,
                                     Parrot_get_ctx_HLL_type(lexer->interp, 
enum_class_String));
-            int index     = add_pmc_const(lexer->bc, strconst);
+
+            int     index     = add_pmc_const(lexer->bc, strconst);
+
             VTABLE_set_string_native(lexer->interp, strconst,
                                      string_from_cstring(lexer->interp, 
value->val.sval,
                                                          
strlen(value->val.sval)));
@@ -1472,6 +1484,10 @@
             push_operand(lexer, expr_from_target(lexer, consttarg));
             push_operand(lexer, expr_from_int(lexer, index));
 
+            decl->name     = name;
+            decl->type     = PMC_VAL;
+            decl->val.pval = value->val.sval;
+
         }
         else {
             yypirerror(lexer->yyscanner, lexer,

Modified: trunk/compilers/pirc/src/pirparser.c
==============================================================================
--- trunk/compilers/pirc/src/pirparser.c        (original)
+++ trunk/compilers/pirc/src/pirparser.c        Sun Jan  4 07:06:01 2009
@@ -4320,12 +4320,12 @@
 
   case 328:
 #line 2010 "pir.y"
-    { store_global_constant(lexer, (yyvsp[(2) - (2)].cdec)); ;}
+    { /*store_global_constant(lexer, $2); */;}
     break;
 
   case 329:
 #line 2014 "pir.y"
-    { /* XXX is .globalconst to be kept? */ ;}
+    { store_global_constant(lexer, (yyvsp[(2) - (2)].cdec)); ;}
     break;
 
   case 330:

Modified: trunk/compilers/pirc/src/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/src/pirsymbol.c        (original)
+++ trunk/compilers/pirc/src/pirsymbol.c        Sun Jan  4 07:06:01 2009
@@ -327,10 +327,11 @@
                 }
 
 
+            /*
             if (TEST_FLAG(lexer->flags, LEXER_FLAG_REGALLOC))
                 fprintf(stderr, "live range of variable %s: (%d, %d)\n", 
sym->info.id.name,
                         sym->info.interval->startpoint, 
sym->info.interval->endpoint);
-
+            */
             return sym;
         }
 
@@ -344,6 +345,8 @@
         /*
         fprintf(stderr, "symbol type: %d ==> %d\n", c->type, 
convert_valuetype_to_pirtype[c->type]);
         */
+        if (sym->info.color == NO_REG_ALLOCATED)
+            assign_vanilla_register(lexer, sym);
         return sym;
     }
 

Reply via email to