Author: kjs
Date: Tue Dec 30 02:44:32 2008
New Revision: 34632
Modified:
trunk/compilers/pirc/new/pir.y
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/pircompunit.h
trunk/compilers/pirc/new/pirparser.c
Log:
[pirc] insert the value of a :named flag as an extra argument. +Do some magic
with flags.
Modified: trunk/compilers/pirc/new/pir.y
==============================================================================
--- trunk/compilers/pirc/new/pir.y (original)
+++ trunk/compilers/pirc/new/pir.y Tue Dec 30 02:44:32 2008
@@ -1645,8 +1645,8 @@
opt_long_results
".end_call" "\n"
{ /* $4 contains an invocation object */
- set_invocation_args($4, $3);
- $$ = set_invocation_results($4, $6);
+ set_invocation_args(lexer, $4, $3);
+ $$ = set_invocation_results(lexer, $4, $6);
}
;
@@ -1709,11 +1709,11 @@
short_invocation : opt_target_list '=' simple_invocation
- { $$ = set_invocation_results($3, $1); }
+ { $$ = set_invocation_results(lexer, $3, $1); }
| target '=' simple_invocation
- { $$ = set_invocation_results($3, $1); }
+ { $$ = set_invocation_results(lexer, $3, $1); }
| simple_invocation
- { $$ = set_invocation_results($1, NULL); }
+ { $$ = set_invocation_results(lexer, $1, NULL); }
;
simple_invocation : subcall
@@ -1736,14 +1736,14 @@
}
$$ = invoke(lexer, CALL_METHOD, $1, $3);
- set_invocation_args($$, $4);
+ set_invocation_args(lexer, $$, $4);
}
;
subcall : sub arguments
{
$$ = invoke(lexer, CALL_PCC, $1, NULL);
- set_invocation_args($$, $2);
+ set_invocation_args(lexer, $$, $2);
}
;
@@ -1853,7 +1853,7 @@
short_return_stat : ".return" arguments "\n"
{
$$ = invoke(lexer, CALL_RETURN);
- set_invocation_args($$, $2);
+ set_invocation_args(lexer, $$, $2);
}
| ".tailcall" simple_invocation "\n"
{ /* was the invocation a method call? then it
becomes a method tail
@@ -1869,7 +1869,7 @@
short_yield_stat : ".yield" arguments "\n"
{
$$ = invoke(lexer, CALL_YIELD);
- set_invocation_args($$, $2);
+ set_invocation_args(lexer, $$, $2);
}
;
@@ -1910,7 +1910,7 @@
".end_return" "\n"
{
$$ = invoke(lexer, CALL_RETURN);
- set_invocation_args($$, $3);
+ set_invocation_args(lexer, $$, $3);
}
;
@@ -1919,7 +1919,7 @@
".end_yield" "\n"
{
$$ = invoke(lexer, CALL_YIELD);
- set_invocation_args($$, $3);
+ set_invocation_args(lexer, $$, $3);
}
;
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Tue Dec 30 02:44:32 2008
@@ -1548,7 +1548,7 @@
/*
=item C<void
-set_invocation_args(invocation * const inv, argument * const args)>
+set_invocation_args(lexer_state * const lexer, invocation * const inv,
argument * const args)>
Set the args of an invocation onto the current invocation object.
The number of arguments in the list is counted, and stored in the
@@ -1558,7 +1558,7 @@
*/
invocation *
-set_invocation_args(invocation * const inv, argument * const args) {
+set_invocation_args(lexer_state * const lexer, invocation * const inv,
argument * const args) {
argument *arg_iter;
unsigned arg_count = 0;
@@ -1570,10 +1570,31 @@
arg_iter = arg_iter->next;
/* count :named arguments twice, once for the argument,
- * once for the :named flag value.
+ * once for the :named flag value. Also, add an extra
+ * argument holding the :named flag value, which is a
+ * constant string.
*/
- if (TEST_FLAG(arg_iter->flags, TARGET_FLAG_NAMED))
+ if (TEST_FLAG(arg_iter->flags, TARGET_FLAG_NAMED)) {
+ argument *arg = new_argument(lexer, expr_from_string(lexer,
arg_iter->alias));
+
+ /* and clear the :named flag on the original argument; XXX is
this correct?
+ a disassemble on a test file generated by Parrot seems to
do this.
+ */
+ CLEAR_FLAG(arg_iter->flags, TARGET_FLAG_NAMED);
+
+ add_arg(arg_iter, arg);
+
+ /* set the :named flag on this extra argument. XXX is this
correct? */
+ SET_FLAG(arg->flags, TARGET_FLAG_NAMED);
+
+
+ /* we just inserted an extra argument for the value of
:named() flag;
+ * but it need not be handled here; so skip it now:
+ */
+ arg_iter = arg_iter->next;
+
arg_count += 2;
+ }
else
++arg_count;
}
@@ -1591,7 +1612,7 @@
/*
=item C<void
-set_invocation_results(invocation * const inv, target * const results)>
+set_invocation_results(lexer_state * const lexer, invocation * const inv,
target * const results)>
Set the invocation results on the invocation object C<inv>.
The number of results is stored in the invocation object.
@@ -1600,19 +1621,19 @@
*/
invocation *
-set_invocation_results(invocation * const inv, target * const results) {
- target *count_iter;
+set_invocation_results(lexer_state * const lexer, invocation * const inv,
target * const results) {
+ target *result_iter;
unsigned result_count = 0;
inv->results = results;
if (results) {
- count_iter = results->next;
+ result_iter = results->next;
do {
- count_iter = count_iter->next;
+ result_iter = result_iter->next;
++result_count;
}
- while (count_iter != results->next);
+ while (result_iter != results->next);
}
/* fprintf(stderr, "invocation has %u results\n", result_count); */
Modified: trunk/compilers/pirc/new/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.h (original)
+++ trunk/compilers/pirc/new/pircompunit.h Tue Dec 30 02:44:32 2008
@@ -387,8 +387,11 @@
/* functions for creating an invocation node and setting various fields */
invocation *invoke(struct lexer_state * const lexer, invoke_type, ...);
invocation *set_invocation_type(invocation * const inv, invoke_type type);
-invocation *set_invocation_args(invocation * const inv, argument * const args);
-invocation *set_invocation_results(invocation * const inv, target * const
results);
+invocation *set_invocation_args(struct lexer_state * const lexer, invocation *
const inv,
+ argument * const args);
+
+invocation *set_invocation_results(struct lexer_state * const lexer,
invocation * const inv,
+ target * const results);
/* conversion functions that wrap their arguments into a target node */
target *target_from_symbol(struct lexer_state * const lexer, struct symbol *
const sym);
Modified: trunk/compilers/pirc/new/pirparser.c
==============================================================================
--- trunk/compilers/pirc/new/pirparser.c (original)
+++ trunk/compilers/pirc/new/pirparser.c Tue Dec 30 02:44:32 2008
@@ -3857,8 +3857,8 @@
case 242:
#line 1647 "pir.y"
{ /* $4 contains an invocation object */
- set_invocation_args((yyvsp[(4) - (8)].invo),
(yyvsp[(3) - (8)].argm));
- (yyval.invo) = set_invocation_results((yyvsp[(4)
- (8)].invo), (yyvsp[(6) - (8)].targ));
+ set_invocation_args(lexer, (yyvsp[(4) -
(8)].invo), (yyvsp[(3) - (8)].argm));
+ (yyval.invo) = set_invocation_results(lexer,
(yyvsp[(4) - (8)].invo), (yyvsp[(6) - (8)].targ));
;}
break;
@@ -3949,17 +3949,17 @@
case 260:
#line 1712 "pir.y"
- { (yyval.invo) = set_invocation_results((yyvsp[(3) - (3)].invo),
(yyvsp[(1) - (3)].targ)); ;}
+ { (yyval.invo) = set_invocation_results(lexer, (yyvsp[(3) - (3)].invo),
(yyvsp[(1) - (3)].targ)); ;}
break;
case 261:
#line 1714 "pir.y"
- { (yyval.invo) = set_invocation_results((yyvsp[(3) - (3)].invo),
(yyvsp[(1) - (3)].targ)); ;}
+ { (yyval.invo) = set_invocation_results(lexer, (yyvsp[(3) - (3)].invo),
(yyvsp[(1) - (3)].targ)); ;}
break;
case 262:
#line 1716 "pir.y"
- { (yyval.invo) = set_invocation_results((yyvsp[(1) - (1)].invo), NULL); ;}
+ { (yyval.invo) = set_invocation_results(lexer, (yyvsp[(1) - (1)].invo),
NULL); ;}
break;
case 265:
@@ -3979,7 +3979,7 @@
}
(yyval.invo) = invoke(lexer, CALL_METHOD,
(yyvsp[(1) - (4)].targ), (yyvsp[(3) - (4)].expr));
- set_invocation_args((yyval.invo), (yyvsp[(4) -
(4)].argm));
+ set_invocation_args(lexer, (yyval.invo),
(yyvsp[(4) - (4)].argm));
;}
break;
@@ -3987,7 +3987,7 @@
#line 1744 "pir.y"
{
(yyval.invo) = invoke(lexer, CALL_PCC, (yyvsp[(1)
- (2)].targ), NULL);
- set_invocation_args((yyval.invo), (yyvsp[(2) -
(2)].argm));
+ set_invocation_args(lexer, (yyval.invo),
(yyvsp[(2) - (2)].argm));
;}
break;
@@ -4131,7 +4131,7 @@
#line 1854 "pir.y"
{
(yyval.invo) = invoke(lexer, CALL_RETURN);
- set_invocation_args((yyval.invo), (yyvsp[(2) -
(3)].argm));
+ set_invocation_args(lexer, (yyval.invo),
(yyvsp[(2) - (3)].argm));
;}
break;
@@ -4151,7 +4151,7 @@
#line 1870 "pir.y"
{
(yyval.invo) = invoke(lexer, CALL_YIELD);
- set_invocation_args((yyval.invo), (yyvsp[(2) -
(3)].argm));
+ set_invocation_args(lexer, (yyval.invo),
(yyvsp[(2) - (3)].argm));
;}
break;
@@ -4199,7 +4199,7 @@
#line 1911 "pir.y"
{
(yyval.invo) = invoke(lexer, CALL_RETURN);
- set_invocation_args((yyval.invo), (yyvsp[(3) -
(5)].argm));
+ set_invocation_args(lexer, (yyval.invo),
(yyvsp[(3) - (5)].argm));
;}
break;
@@ -4207,7 +4207,7 @@
#line 1920 "pir.y"
{
(yyval.invo) = invoke(lexer, CALL_YIELD);
- set_invocation_args((yyval.invo), (yyvsp[(3) -
(5)].argm));
+ set_invocation_args(lexer, (yyval.invo),
(yyvsp[(3) - (5)].argm));
;}
break;