Author: kjs
Date: Sat Dec 27 11:05:47 2008
New Revision: 34436
Modified:
trunk/compilers/pirc/new/bcgen.c
trunk/compilers/pirc/new/bcgen.h
trunk/compilers/pirc/new/main.c
trunk/compilers/pirc/new/piremit.c
Log:
[pirc] refactoring of add_sub_pmc function using new sub_info structure.
+ move a line in yyerror; this makes more sense, to keep print stuff together.
Modified: trunk/compilers/pirc/new/bcgen.c
==============================================================================
--- trunk/compilers/pirc/new/bcgen.c (original)
+++ trunk/compilers/pirc/new/bcgen.c Sat Dec 27 11:05:47 2008
@@ -368,15 +368,7 @@
*/
void
-add_sub_pmc(bytecode * const bc,
- char const * const subname,
- char const * const nsentry,
- char const * const subid,
- int vtable_index,
- unsigned regs_used[],
- int startoffset,
- int endoffset)
-{
+add_sub_pmc(bytecode * const bc, sub_info *info) {
PMC *sub_pmc;
Parrot_sub *sub;
int subconst_index;
@@ -390,14 +382,14 @@
*/
sub_pmc = pmc_new(bc->interp, enum_class_Sub);
sub = PMC_sub(sub_pmc);
- subname_index = add_string_const(bc, subname);
+ subname_index = add_string_const(bc, info->subname);
subname_const = bc->interp->code->const_table->constants[subname_index];
/* set start and end offset of this sub in the bytecode. This is
calculated during
* the parsing phase.
*/
- sub->start_offs = startoffset;
- sub->end_offs = endoffset;
+ sub->start_offs = info->startoffset;
+ sub->end_offs = info->endoffset;
/* XXX fix namespace stuff */
sub->namespace_name = NULL;
@@ -414,14 +406,14 @@
/* Set the vtable index; if this .sub was declared as :vtable, its vtable
* index was found during the parse; otherwise it's -1.
*/
- sub->vtable_index = vtable_index;
+ sub->vtable_index = info->vtable_index;
/* XXX fix multi stuff */
sub->multi_signature = NULL;
/* store register usage of this sub. */
for (i = 0; i < 4; ++i)
- sub->n_regs_used[i] = regs_used[i];
+ sub->n_regs_used[i] = info->regs_used[i];
/* store the name of this sub; it's stored in the constant table. */
sub->name = subname_const->u.string;
@@ -429,16 +421,16 @@
/* If there was a :nsentry, add it to the constants table, and set
* the ns_entry_name attribute to that STRING. Default value is the sub's
name.
*/
- if (nsentry)
- sub->ns_entry_name = add_string_const_from_cstring(bc, nsentry);
+ if (info->nsentry)
+ sub->ns_entry_name = add_string_const_from_cstring(bc, info->nsentry);
else
sub->ns_entry_name = subname_const->u.string;
/* if there was a :subid, add it to the constants table, and set the subid
* attribute to that STRING. Default value is the sub's name.
*/
- if (subid)
- sub->subid = add_string_const_from_cstring(bc, subid);
+ if (info->subid)
+ sub->subid = add_string_const_from_cstring(bc, info->subid);
else
sub->subid = subname_const->u.string;
@@ -451,7 +443,7 @@
subconst_index = add_pmc_const(bc, sub_pmc);
/* Add a new fixup entry in the fixup table for this sub. */
- PackFile_FixupTable_new_entry(bc->interp, subname, enum_fixup_sub,
subconst_index);
+ PackFile_FixupTable_new_entry(bc->interp, info->subname, enum_fixup_sub,
subconst_index);
}
Modified: trunk/compilers/pirc/new/bcgen.h
==============================================================================
--- trunk/compilers/pirc/new/bcgen.h (original)
+++ trunk/compilers/pirc/new/bcgen.h Sat Dec 27 11:05:47 2008
@@ -84,10 +84,7 @@
/* retrieves the index of s in the constant table */
-
-void add_sub_pmc(bytecode * const bc,
- char const * const subname, char const * const nsentry, char const
* const subid,
- int vtable_index, unsigned regs_used[], int startoffset, int
endoffset);
+void add_sub_pmc(bytecode * const bc, sub_info *info);
#endif /* PARROT_BCGEN_H_GUARD */
Modified: trunk/compilers/pirc/new/main.c
==============================================================================
--- trunk/compilers/pirc/new/main.c (original)
+++ trunk/compilers/pirc/new/main.c Sat Dec 27 11:05:47 2008
@@ -523,14 +523,14 @@
vfprintf(stderr, message, arg_ptr);
va_end(arg_ptr);
- ++lexer->parse_errors;
-
/* print current token if it doesn't contain a newline token. */
if (!strstr(current_token, "\n"))
fprintf(stderr, "\n\tcurrent token: '%s'", current_token);
fprintf(stderr, "\n\n");
+ ++lexer->parse_errors;
+
return 0;
}
Modified: trunk/compilers/pirc/new/piremit.c
==============================================================================
--- trunk/compilers/pirc/new/piremit.c (original)
+++ trunk/compilers/pirc/new/piremit.c Sat Dec 27 11:05:47 2008
@@ -558,14 +558,7 @@
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.subname,
- subiter->info.nsentry,
- subiter->info.subid,
- subiter->info.vtable_index,
- subiter->info.regs_used,
- subiter->info.startoffset,
- subiter->info.endoffset);
+ add_sub_pmc(lexer->bc, &subiter->info);
emit_pbc_sub(lexer, subiter);
subiter = subiter->next;