Front page | perl.cvs.parrot |
Postings from January 2009
[svn:parrot] r35053 - trunk/compilers/pirc/src
From:
kjs
Date:
January 6, 2009 09:27
Subject:
[svn:parrot] r35053 - trunk/compilers/pirc/src
Message ID:
20090106172709.E4459CB9F9@x12.develooper.com
Author: kjs
Date: Tue Jan 6 09:27:09 2009
New Revision: 35053
Modified:
trunk/compilers/pirc/src/pircompunit.c
trunk/compilers/pirc/src/pircompunit.h
trunk/compilers/pirc/src/pirpcc.c
Log:
[pirc] fix bytecode generation for methodcalls.
Modified: trunk/compilers/pirc/src/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.c (original)
+++ trunk/compilers/pirc/src/pircompunit.c Tue Jan 6 09:27:09 2009
@@ -759,9 +759,12 @@
/*
=item C<void
-unshift_arg(argument *last, argument * const newarg)>
+unshift_arg(invocation * const inv, argument * const newarg)>
+
+Unshift argument C<newarg> on an invocation object. The number
+of arguments in the list of C<inv> is incremented to reflect
+the extra argument on the list.
-Unshift argument C<newarg> in front of the list, pointed to by C<last>.
Given this list:
A->B->C->D
@@ -783,13 +786,16 @@
*/
argument *
-unshift_arg(argument *last, argument * const newarg) {
- if (last) {
- newarg->next = last->next;
- last->next = newarg;
- return last;
+unshift_arg(invocation * const inv, argument * const newarg) {
+ ++inv->num_arguments;
+
+ if (inv->arguments) {
+ newarg->next = inv->arguments->next;
+ inv->arguments->next = newarg;
}
- return newarg;
+
+ inv->arguments = newarg;
+ return inv->arguments;
}
/*
Modified: trunk/compilers/pirc/src/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/src/pircompunit.h (original)
+++ trunk/compilers/pirc/src/pircompunit.h Tue Jan 6 09:27:09 2009
@@ -417,7 +417,7 @@
/* functions for argument node creation and storing */
argument *new_argument(struct lexer_state * const lexer, expression * const expr);
argument *add_arg(argument *arg1, argument * const arg2);
-argument *unshift_arg(argument *last, argument * const newarg);
+argument *unshift_arg(invocation * const inv, argument * const newarg);
target *add_param(struct lexer_state * const lexer, pir_type type, char const * const name);
target *set_param_alias(struct lexer_state * const lexer, char const * const alias);
Modified: trunk/compilers/pirc/src/pirpcc.c
==============================================================================
--- trunk/compilers/pirc/src/pirpcc.c (original)
+++ trunk/compilers/pirc/src/pirpcc.c Tue Jan 6 09:27:09 2009
@@ -317,6 +317,8 @@
/* add the index (of the signature PMC) in the PBC constant table as operand */
push_operand(lexer, expr_from_int(lexer, array_index));
+ fprintf(stderr, "args2ops: %d arguments\n", num_arguments);
+
/* no need to continue if there's no arguments */
if (num_arguments == 0)
return;
@@ -617,12 +619,9 @@
*/
static void
convert_pcc_methodcall(lexer_state * const lexer, invocation * const inv) {
- fprintf(stderr, "convert pcc method call\n");
- new_sub_instr(lexer, PARROT_OP_set_args_pc, "set_args_pc", inv->num_arguments);
-
/* in a methodcall, the invocant object is passed as the first argument */
- inv->arguments = unshift_arg(inv->arguments,
- new_argument(lexer, expr_from_target(lexer, inv->sub)));
+ unshift_arg(inv, new_argument(lexer, expr_from_target(lexer, inv->sub)));
+ new_sub_instr(lexer, PARROT_OP_set_args_pc, "set_args_pc", inv->num_arguments);
arguments_to_operands(lexer, inv->arguments, inv->num_arguments);
@@ -631,7 +630,7 @@
new_sub_instr(lexer, PARROT_OP_callmethodcc_p_sc, "callmethodcc_p_sc", 0);
add_operands(lexer, "%T%E", inv->sub, inv->method);
- fprintf(stderr, "convert pcc method call done\n");
+
}
/*
-
[svn:parrot] r35053 - trunk/compilers/pirc/src
by kjs