summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-14 18:30:26 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-14 18:30:26 (GMT)
commit49d6dc4123173ab77ac220c3298a6db621fd6d4e (patch)
tree61d059ba1ae4da98c999ee9b36a6a5eebdc9edae /Python
parent92df0c67d013fcfc2042ccc3106fb9d1f077d783 (diff)
downloadcpython-49d6dc4123173ab77ac220c3298a6db621fd6d4e.zip
cpython-49d6dc4123173ab77ac220c3298a6db621fd6d4e.tar.gz
cpython-49d6dc4123173ab77ac220c3298a6db621fd6d4e.tar.bz2
Added varargs code.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 0f21adfa..4cd1c94 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1956,6 +1956,30 @@ com_fplist(c, n)
}
static void
+com_arglist(c, n)
+ struct compiling *c;
+ node *n;
+{
+ int i, nargs, op;
+ REQ(n, varargslist);
+ /* varargslist: (fpdef ',')* '+' NAME | fpdef (',' fpdef)* [','] */
+ op = UNPACK_ARG;
+ nargs = (NCH(n) + 1) / 2;
+ for (i = 0; i < NCH(n); i += 2) {
+ if (TYPE(CHILD(n, i)) == PLUS) {
+ op = UNPACK_VARARG;
+ nargs = i/2;
+ break;
+ }
+ }
+ com_addoparg(c, op, nargs);
+ for (i = 0; i < 2*nargs; i += 2)
+ com_fpdef(c, CHILD(n, i));
+ if (op == UNPACK_VARARG)
+ com_addopname(c, STORE_NAME, CHILD(n, 2*nargs+1));
+}
+
+static void
com_file_input(c, n)
struct compiling *c;
node *n;
@@ -1978,17 +2002,12 @@ compile_funcdef(c, n)
{
node *ch;
REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */
- ch = CHILD(n, 2); /* parameters: '(' [fplist] ')' */
- ch = CHILD(ch, 1); /* ')' | fplist */
+ ch = CHILD(n, 2); /* parameters: '(' [varargslist] ')' */
+ ch = CHILD(ch, 1); /* ')' | varargslist */
if (TYPE(ch) == RPAR)
com_addoparg(c, UNPACK_ARG, 0);
- else {
- int i;
- REQ(ch, fplist); /* fplist: fpdef (',' fpdef)* */
- com_addoparg(c, UNPACK_ARG, (NCH(ch)+1)/2);
- for (i = 0; i < NCH(ch); i += 2)
- com_fpdef(c, CHILD(ch, i));
- }
+ else
+ com_arglist(c, ch);
c->c_infunction = 1;
com_node(c, CHILD(n, 4));
c->c_infunction = 0;