Author: kjs
Date: Tue Dec 16 10:34:46 2008
New Revision: 33971
Modified:
trunk/compilers/pirc/new/pir.y
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/pirparser.c
trunk/compilers/pirc/new/pirsymbol.c
trunk/compilers/pirc/new/pirsymbol.h
Log:
[pirc] more refactoring. Removed field #4 ('name', 'regno', and union-ified
them)
Modified: trunk/compilers/pirc/new/pir.y
==============================================================================
--- trunk/compilers/pirc/new/pir.y (original)
+++ trunk/compilers/pirc/new/pir.y Tue Dec 16 10:34:46 2008
@@ -1032,7 +1032,7 @@
if ($1->s.sym->info.type != PMC_TYPE)
yypirerror(yyscanner, lexer,
"indexed object '%s' is not of type
'pmc'",
- $1->s.sym->name);
+ $1->s.sym->info.id.name);
/* create a target node based on the symbol
node;
* sym already has a PASM register, so through
@@ -1578,7 +1578,7 @@
if ($4->s.sym->info.type != PMC_TYPE) /* a .lex
must be a PMC */
yypirerror(yyscanner, lexer, "lexical '%s'
must be of type 'pmc'",
- $4->s.sym->name);
+ $4->s.sym->info.id.name);
}
set_lex_flag($4, $2);
}
@@ -1693,14 +1693,14 @@
}
else { /* is not a register but a symbol */
- symbol *sym = find_symbol(lexer,
$1->s.sym->name);
+ symbol *sym = find_symbol(lexer,
$1->s.sym->info.id.name);
if (sym == NULL)
yypirerror(yyscanner, lexer,
- "symbol '%s' was not declared",
$1->s.sym->name);
+ "symbol '%s' was not declared",
$1->s.sym->info.id.name);
else if ($1->s.sym->info.type != PMC_TYPE)
yypirerror(yyscanner, lexer,
"cannot invoke method: '%s' is
not of type 'pmc'",
- $1->s.sym->name);
+ $1->s.sym->info.id.name);
/* get a target based on the symbol, it
contains a register */
invocant = $1;
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Tue Dec 16 10:34:46 2008
@@ -649,12 +649,12 @@
/* :slurpy can only be set on a PMC parameter */
if (TEST_FLAG(flag, TARGET_FLAG_SLURPY) && param->s.sym->info.type !=
PMC_TYPE)
yypirerror(lexer->yyscanner, lexer,
- "cannot set :slurpy flag on non-pmc %s",
param->s.sym->name);
+ "cannot set :slurpy flag on non-pmc %s",
param->s.sym->info.id.name);
/* :opt_flag can only be set on a int parameter */
if (TEST_FLAG(flag, TARGET_FLAG_OPT_FLAG) && param->s.sym->info.type !=
INT_TYPE)
yypirerror(lexer->yyscanner, lexer,
- "cannot set :opt_flag flag on non-int %s",
param->s.sym->name);
+ "cannot set :opt_flag flag on non-int %s",
param->s.sym->info.id.name);
return param;
}
@@ -2099,7 +2099,7 @@
}
else { /* find the global label in the current file, or find it
during runtime */
target *sub = generate_unique_pir_reg(lexer, PMC_TYPE);
- global_label *glob = find_global_label(lexer,
inv->sub->s.sym->name);
+ global_label *glob = find_global_label(lexer,
inv->sub->s.sym->info.id.name);
if (glob) {
/* XXX fix pmc const stuff */
@@ -2110,7 +2110,7 @@
new_sub_instr(lexer, PARROT_OP_find_sub_not_null_p_sc,
"find_sub_not_null_p_sc");
- add_operands(lexer, "%T%s", sub, inv->sub->s.sym->name);
+ add_operands(lexer, "%T%s", sub,
inv->sub->s.sym->info.id.name);
/* save the current instruction in a list; entries in this
list will be
* fixed up, if possible, after the parsing phase.
@@ -2127,7 +2127,8 @@
* find_sub_not_null_p_sc
*
*/
- save_global_reference(lexer, CURRENT_INSTRUCTION(lexer),
inv->sub->s.sym->name);
+ save_global_reference(lexer, CURRENT_INSTRUCTION(lexer),
+ inv->sub->s.sym->info.id.name);
}
new_sub_instr(lexer, PARROT_OP_invokecc_p, "invokecc_p");
Modified: trunk/compilers/pirc/new/pirparser.c
==============================================================================
--- trunk/compilers/pirc/new/pirparser.c (original)
+++ trunk/compilers/pirc/new/pirparser.c Tue Dec 16 10:34:46 2008
@@ -3040,7 +3040,7 @@
if ((yyvsp[(1) - (2)].targ)->s.sym->info.type
!= PMC_TYPE)
yypirerror(yyscanner, lexer,
"indexed object '%s' is not of type
'pmc'",
- (yyvsp[(1) -
(2)].targ)->s.sym->name);
+ (yyvsp[(1) -
(2)].targ)->s.sym->info.id.name);
/* create a target node based on the symbol
node;
* sym already has a PASM register, so through
@@ -3756,7 +3756,7 @@
if ((yyvsp[(4) - (5)].targ)->s.sym->info.type !=
PMC_TYPE) /* a .lex must be a PMC */
yypirerror(yyscanner, lexer, "lexical '%s'
must be of type 'pmc'",
- (yyvsp[(4) -
(5)].targ)->s.sym->name);
+ (yyvsp[(4) -
(5)].targ)->s.sym->info.id.name);
}
set_lex_flag((yyvsp[(4) - (5)].targ), (yyvsp[(2) -
(5)].sval));
;}
@@ -3893,14 +3893,14 @@
}
else { /* is not a register but a symbol */
- symbol *sym = find_symbol(lexer, (yyvsp[(1) -
(4)].targ)->s.sym->name);
+ symbol *sym = find_symbol(lexer, (yyvsp[(1) -
(4)].targ)->s.sym->info.id.name);
if (sym == NULL)
yypirerror(yyscanner, lexer,
- "symbol '%s' was not declared",
(yyvsp[(1) - (4)].targ)->s.sym->name);
+ "symbol '%s' was not declared",
(yyvsp[(1) - (4)].targ)->s.sym->info.id.name);
else if ((yyvsp[(1) -
(4)].targ)->s.sym->info.type != PMC_TYPE)
yypirerror(yyscanner, lexer,
"cannot invoke method: '%s' is
not of type 'pmc'",
- (yyvsp[(1) -
(4)].targ)->s.sym->name);
+ (yyvsp[(1) -
(4)].targ)->s.sym->info.id.name);
/* get a target based on the symbol, it
contains a register */
invocant = (yyvsp[(1) - (4)].targ);
Modified: trunk/compilers/pirc/new/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/new/pirsymbol.c (original)
+++ trunk/compilers/pirc/new/pirsymbol.c Tue Dec 16 10:34:46 2008
@@ -167,8 +167,6 @@
symbol *
new_symbol(NOTNULL(lexer_state * const lexer), NOTNULL(char const * const
name), pir_type type) {
symbol *sym = pir_mem_allocate_zeroed_typed(lexer, symbol);
- /* XXX remove the next 3 statements */
- sym->name = name;
sym->info.id.name = name;
sym->info.type = type;
@@ -203,7 +201,7 @@
/* store all symbols in the list and set the type on each symbol. */
while (iter != NULL) {
- unsigned long hash = get_hashcode(iter->name, table->size);
+ unsigned long hash = get_hashcode(iter->info.id.name, table->size);
/* look up this symbol; if it exists already, that's an error.
* don't use find_symbol, as that will update the live_interval of the
symbol.
@@ -213,8 +211,9 @@
bucket *b = get_bucket(table, hash);
while (b) {
symbol *s = bucket_symbol(b);
- if (STREQ(s->name, iter->name)) {
- yypirerror(lexer->yyscanner, lexer, "symbol '%s' already
declared", iter->name);
+ if (STREQ(s->info.id.name, iter->info.id.name)) {
+ yypirerror(lexer->yyscanner, lexer, "symbol '%s' already
declared",
+ iter->info.id.name);
break; /* out of the loop */
}
b = b->next;
@@ -260,7 +259,7 @@
while (b) {
if (bucket_symbol(b)->info.color == NO_REG_ALLOCATED)
fprintf(stderr, "Warning: in sub '%s': symbol '%s'
declared but not used\n",
- subiter->sub_name, bucket_symbol(b)->name);
+ subiter->sub_name,
bucket_symbol(b)->info.id.name);
b = b->next;
}
@@ -295,7 +294,7 @@
while (buck) {
symbol *sym = bucket_symbol(buck);
- if (STREQ(sym->name, name)) {
+ if (STREQ(sym->info.id.name, name)) {
if (sym->info.color == NO_REG_ALLOCATED) /* no PASM register
assigned yet */
/* get a new reg from vanilla reg. allocator */
assign_vanilla_register(lexer, sym);
@@ -304,7 +303,7 @@
if (TEST_FLAG(lexer->flags, LEXER_FLAG_VERBOSE))
- fprintf(stderr, "live range of variable %s: (%d, %d)\n",
sym->name,
+ fprintf(stderr, "live range of variable %s: (%d, %d)\n",
sym->info.id.name,
sym->info.interval->startpoint,
sym->info.interval->endpoint);
return sym;
@@ -332,9 +331,6 @@
new_pir_reg(NOTNULL(lexer_state * const lexer), pir_type type, int regno) {
pir_reg *r = pir_mem_allocate_zeroed_typed(lexer, pir_reg);
- /* XXX remove next 3 statements */
- r->regno = regno;
-
r->info.type = type;
r->info.color = NO_REG_ALLOCATED;
r->info.id.regno = regno;
@@ -363,7 +359,7 @@
*/
pir_reg *iter = CURRENT_SUB(lexer)->registers[type];
while (iter != NULL) {
- if (iter->regno == regno) {
+ if (iter->info.id.regno == regno) {
/* update the end point of this register's live interval */
iter->info.interval->endpoint = lexer->stmt_counter;
return iter;
Modified: trunk/compilers/pirc/new/pirsymbol.h
==============================================================================
--- trunk/compilers/pirc/new/pirsymbol.h (original)
+++ trunk/compilers/pirc/new/pirsymbol.h Tue Dec 16 10:34:46 2008
@@ -41,9 +41,9 @@
int color;
pir_type type;
live_interval *interval;
+ char const *name;
*/
- char const *name; /* name of this symbol */
target_flag flags;
struct symbol *next;
@@ -58,8 +58,8 @@
int color;
pir_type type;
live_interval *interval;
+ int regno;
*/
- int regno; /* symbolic (PIR) register number */
struct pir_reg *next;