Author: kjs
Date: Sun Jan 4 05:54:37 2009
New Revision: 34916
Modified:
trunk/compilers/pirc/src/pircompunit.c
trunk/compilers/pirc/src/piremit.c
Log:
[pirc] assign a register to a .const object declared in a .sub
Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c (original)
+++ trunk/compilers/pirc/src/pircompunit.c Sun Jan 4 05:54:37 2009
@@ -1,6 +1,6 @@
/*
* $Id$
- * Copyright (C) 2007-2008, The Perl Foundation.
+ * Copyright (C) 2007-2009, The Perl Foundation.
*/
/*
@@ -1331,6 +1331,7 @@
/* declare it as a local, so that it will get a register assigned. */
declare_local(lexer, PMC_TYPE, constsym);
+ assign_vanilla_register(lexer, constsym);
value->name = name; /* set name of constant node */
value->type = PMC_VAL; /* set type of constant node */
@@ -1345,19 +1346,6 @@
push_operand(lexer, expr_from_target(lexer, consttarg));
push_operand(lexer, expr_from_const(lexer, value));
- /* XXXX
-
- Don't generate that instruction if the constant is never referenced.
- This is true for all variants (pmc, int, string, num) in this function.
-
- As the constant is declared as a .local (see above), it will only
- be assigned a color (register) iff the symbol is referenced (looked up
- for the first time).
-
- XXX fix this.
-
-
- */
}
else if (value->type == INT_VAL) {
@@ -1375,6 +1363,7 @@
VTABLE_set_integer_native(lexer->interp, intconst,
value->val.ival);
declare_local(lexer, PMC_TYPE, constsym);
+ assign_vanilla_register(lexer, constsym);
value->name = name;
@@ -1403,6 +1392,7 @@
VTABLE_set_number_native(lexer->interp, numconst, value->val.nval);
declare_local(lexer, PMC_TYPE, constsym);
+ assign_vanilla_register(lexer, constsym);
value->name = name;
@@ -1432,6 +1422,7 @@
strlen(value->val.sval)));
declare_local(lexer, PMC_TYPE, constsym);
+ assign_vanilla_register(lexer, constsym);
value->name = name;
Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c (original)
+++ trunk/compilers/pirc/src/piremit.c Sun Jan 4 05:54:37 2009
@@ -294,7 +294,8 @@
=item C<void
print_subs(struct lexer_state * const lexer)>
-XXX
+Top-level function to print all generated code. This function
+iterates over all subs and prints their instructions.
=cut
@@ -672,6 +673,10 @@
=item C<static void
emit_pbc_expr(lexer_state * const lexer, expression * const operand)>
+Emit bytecode for the expression C<operand>. This is a dispatch
+function, invoking the appropriate function depending on C<operand>'s
+type.
+
=cut
*/