Author: kjs
Date: Sat Dec 27 11:29:40 2008
New Revision: 34439
Modified:
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/piremit.c
trunk/compilers/pirc/new/pirsymbol.c
trunk/compilers/pirc/new/pirsymbol.h
Log:
[pirc] add the sub PMC after the sub has been parsed, in the finalization
routine for subroutines. This will allow us to store the constant table index
by which this sub was stored in the constant table, in the global_label node,
which is created for each subroutine. Then, when a subroutine invokes another
subroutine, it can find this constant table index.
+ rename const_nr as constant_table_index, which is a bit clearer.
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Sat Dec 27 11:29:40 2008
@@ -2105,7 +2105,7 @@
if (glob) {
/* XXX fix pmc const stuff */
new_sub_instr(lexer, PARROT_OP_set_p_pc, "set_p_pc");
- add_operands(lexer, "%T%i", sub, glob->const_nr);
+ add_operands(lexer, "%T%i", sub, glob->const_table_index);
}
else { /* find it during runtime (hopefully, otherwise
exception) */
new_sub_instr(lexer, PARROT_OP_find_sub_not_null_p_sc,
@@ -2318,7 +2318,8 @@
*/
/* create an operand that refers to a constant PMC */
- new_second_operand = expr_from_const(lexer, new_const(lexer,
INT_TYPE, glob->const_nr));
+ new_second_operand = expr_from_const(lexer, new_const(lexer,
INT_TYPE,
+
glob->const_table_index));
/* link it into the list of operands; the /current/ second operand
should be removed,
* so insert the new expression as second operand, and make sure
the old second
* operand is no longer in the list.
@@ -2403,6 +2404,8 @@
/* if register allocation was requested, do that now */
if (TEST_FLAG(lexer->flags, LEXER_FLAG_REGALLOC))
linear_scan_register_allocation(lexer->lsr);
+
+ add_sub_pmc(lexer->bc, &CURRENT_SUB(lexer)->info);
}
/*
Modified: trunk/compilers/pirc/new/piremit.c
==============================================================================
--- trunk/compilers/pirc/new/piremit.c (original)
+++ trunk/compilers/pirc/new/piremit.c Sat Dec 27 11:29:40 2008
@@ -559,8 +559,6 @@
fprintf(stderr, "start offset of sub '%s' is: %d\tend offest: %d\n",
subiter->info.subname, subiter->info.startoffset,
subiter->info.endoffset);
- add_sub_pmc(lexer->bc, &subiter->info);
-
emit_pbc_sub(lexer, subiter);
subiter = subiter->next;
}
Modified: trunk/compilers/pirc/new/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/new/pirsymbol.c (original)
+++ trunk/compilers/pirc/new/pirsymbol.c Sat Dec 27 11:29:40 2008
@@ -511,7 +511,7 @@
new_global_label(NOTNULL(lexer_state * const lexer), NOTNULL(char const *
const name)) {
global_label *glob = pir_mem_allocate_zeroed_typed(lexer, global_label);
glob->name = name;
- glob->const_nr = 0;
+ glob->const_table_index = 0;
return glob;
}
Modified: trunk/compilers/pirc/new/pirsymbol.h
==============================================================================
--- trunk/compilers/pirc/new/pirsymbol.h (original)
+++ trunk/compilers/pirc/new/pirsymbol.h Sat Dec 27 11:29:40 2008
@@ -58,7 +58,7 @@
/* structure to represent a global label */
typedef struct global_label {
char const *name;
- int const_nr;
+ int const_table_index;
} global_label;