[Python-checkins] python/dist/src/Python ast.c, 1.1.2.34,
1.1.2.35 newcompile.c, 1.1.2.55, 1.1.2.56
jhylton at users.sourceforge.net
jhylton at users.sourceforge.net
Tue Dec 2 00:53:45 EST 2003
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv22363/Python
Modified Files:
Tag: ast-branch
ast.c newcompile.c
Log Message:
Add support for calls with *args and **kwargs.
Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.34
retrieving revision 1.1.2.35
diff -C2 -d -r1.1.2.34 -r1.1.2.35
*** ast.c 15 Oct 2003 06:19:31 -0000 1.1.2.34
--- ast.c 2 Dec 2003 05:53:43 -0000 1.1.2.35
***************
*** 1150,1153 ****
--- 1150,1154 ----
asdl_seq *args = NULL;
asdl_seq *keywords = NULL;
+ expr_ty vararg = NULL, kwarg = NULL;
REQ(n, arglist);
***************
*** 1201,1208 ****
}
}
}
/* XXX syntax error if more than 255 arguments */
! return Call(func, args, keywords, NULL, NULL);
error:
--- 1202,1217 ----
}
}
+ else if (TYPE(ch) == STAR) {
+ vararg = ast_for_expr(CHILD(n, i+1));
+ i++;
+ }
+ else if (TYPE(ch) == DOUBLESTAR) {
+ kwarg = ast_for_expr(CHILD(n, i+1));
+ i++;
+ }
}
/* XXX syntax error if more than 255 arguments */
! return Call(func, args, keywords, vararg, kwarg);
error:
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.55
retrieving revision 1.1.2.56
diff -C2 -d -r1.1.2.55 -r1.1.2.56
*** newcompile.c 24 Nov 2003 04:14:34 -0000 1.1.2.55
--- newcompile.c 2 Dec 2003 05:53:43 -0000 1.1.2.56
***************
*** 1622,1625 ****
--- 1622,1658 ----
static int
+ compiler_call(struct compiler *c, expr_ty e)
+ {
+ int n, code = 0;
+
+ VISIT(c, expr, e->v.Call.func);
+ n = asdl_seq_LEN(e->v.Call.args);
+ if (e->v.Call.starargs) {
+ VISIT(c, expr, e->v.Call.starargs);
+ code |= 1;
+ }
+ if (e->v.Call.kwargs) {
+ VISIT(c, expr, e->v.Call.kwargs);
+ code |= 2;
+ }
+ VISIT_SEQ(c, expr, e->v.Call.args);
+ switch (code) {
+ case 0:
+ ADDOP_I(c, CALL_FUNCTION, n);
+ break;
+ case 1:
+ ADDOP_I(c, CALL_FUNCTION_VAR, n);
+ break;
+ case 2:
+ ADDOP_I(c, CALL_FUNCTION_KW, n);
+ break;
+ case 3:
+ ADDOP_I(c, CALL_FUNCTION_VAR_KW, n);
+ break;
+ }
+ return 1;
+ }
+
+ static int
compiler_listcomp_generator(struct compiler *c, listcomp_ty l, expr_ty elt)
{
***************
*** 1739,1748 ****
return compiler_compare(c, e);
case Call_kind:
! VISIT(c, expr, e->v.Call.func);
! n = asdl_seq_LEN(e->v.Call.args);
! /* XXX other args */
! VISIT_SEQ(c, expr, e->v.Call.args);
! ADDOP_I(c, CALL_FUNCTION, n);
! break;
case Repr_kind:
VISIT(c, expr, e->v.Repr.value);
--- 1772,1776 ----
return compiler_compare(c, e);
case Call_kind:
! return compiler_call(c, e);
case Repr_kind:
VISIT(c, expr, e->v.Repr.value);
More information about the Python-checkins
mailing list