summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-10-18 17:06:59 (GMT)
committerGuido van Rossum <guido@python.org>1993-10-18 17:06:59 (GMT)
commitdb3165e6559c6b83373e7fed9cdf4371552a9a8e (patch)
tree97b057363244668ebec6630553a86ad2206e3fd2 /Python/compile.c
parentcacd9579d48cb1e2acc3536c9701987b118edf8c (diff)
downloadcpython-db3165e6559c6b83373e7fed9cdf4371552a9a8e.zip
cpython-db3165e6559c6b83373e7fed9cdf4371552a9a8e.tar.gz
cpython-db3165e6559c6b83373e7fed9cdf4371552a9a8e.tar.bz2
* bltinmodule.c: removed exec() built-in function.
* Grammar: add exec statement; allow testlist in expr statement. * ceval.c, compile.c, opcode.h: support exec statement; avoid optimizing locals when it is used * fileobject.{c,h}: add getfilename() internal function.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 0eb06cb..2a1a2b4 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1305,7 +1305,7 @@ com_expr_stmt(c, n)
struct compiling *c;
node *n;
{
- REQ(n, expr_stmt); /* exprlist ('=' exprlist)* */
+ REQ(n, expr_stmt); /* testlist ('=' testlist)* */
com_node(c, CHILD(n, NCH(n)-1));
if (NCH(n) == 1) {
com_addbyte(c, PRINT_EXPR);
@@ -1467,6 +1467,25 @@ com_access_stmt(c, n)
}
static void
+com_exec_stmt(c, n)
+ struct compiling *c;
+ node *n;
+{
+ REQ(n, exec_stmt);
+ /* exec_stmt: 'exec' expr ['in' expr [',' expr]] */
+ com_node(c, CHILD(n, 1));
+ if (NCH(n) >= 4)
+ com_node(c, CHILD(n, 3));
+ else
+ com_addoparg(c, LOAD_CONST, com_addconst(c, None));
+ if (NCH(n) >= 6)
+ com_node(c, CHILD(n, 5));
+ else
+ com_addbyte(c, DUP_TOP);
+ com_addbyte(c, EXEC_STMT);
+}
+
+static void
com_if_stmt(c, n)
struct compiling *c;
node *n;
@@ -1909,6 +1928,9 @@ com_node(c, n)
case access_stmt:
com_access_stmt(c, n);
break;
+ case exec_stmt:
+ com_exec_stmt(c, n);
+ break;
case if_stmt:
com_if_stmt(c, n);
break;
@@ -2183,6 +2205,8 @@ optimize(c)
opcode = NEXTOP();
if (opcode == STOP_CODE)
break;
+ if (opcode == EXEC_STMT)
+ goto end; /* Don't optimize if exec present */
if (HAS_ARG(opcode))
oparg = NEXTARG();
if (opcode == STORE_NAME || opcode == DELETE_NAME ||