[Python-checkins] r45287 - python/trunk/Python/compile.c
anthony.baxter
python-checkins at python.org
Wed Apr 12 02:43:10 CEST 2006
Author: anthony.baxter
Date: Wed Apr 12 02:43:09 2006
New Revision: 45287
Modified:
python/trunk/Python/compile.c
Log:
per Jeremy's email, remove the _WITH_CAST versions of macros. g++
still has errors from the casts of asdl_seq_GET to cmpop_ty, but
otherwise it's C++ clean.
Modified: python/trunk/Python/compile.c
==============================================================================
--- python/trunk/Python/compile.c (original)
+++ python/trunk/Python/compile.c Wed Apr 12 02:43:09 2006
@@ -1717,17 +1717,7 @@
int _i; \
asdl_seq *seq = (SEQ); /* avoid variable capture */ \
for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
- TYPE ## _ty elt = asdl_seq_GET(seq, _i); \
- if (!compiler_visit_ ## TYPE((C), elt)) \
- return 0; \
- } \
-}
-
-#define VISIT_SEQ_WITH_CAST(C, TYPE, SEQ, CAST) { \
- int _i; \
- asdl_seq *seq = (SEQ); /* avoid variable capture */ \
- for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
- TYPE ## _ty elt = (CAST)asdl_seq_GET(seq, _i); \
+ TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, _i); \
if (!compiler_visit_ ## TYPE((C), elt)) \
return 0; \
} \
@@ -1737,19 +1727,7 @@
int _i; \
asdl_seq *seq = (SEQ); /* avoid variable capture */ \
for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
- TYPE ## _ty elt = asdl_seq_GET(seq, _i); \
- if (!compiler_visit_ ## TYPE((C), elt)) { \
- compiler_exit_scope(c); \
- return 0; \
- } \
- } \
-}
-
-#define VISIT_SEQ_IN_SCOPE_WITH_CAST(C, TYPE, SEQ, CAST) { \
- int _i; \
- asdl_seq *seq = (SEQ); /* avoid variable capture */ \
- for (_i = 0; _i < asdl_seq_LEN(seq); _i++) { \
- TYPE ## _ty elt = (CAST)asdl_seq_GET(seq, _i); \
+ TYPE ## _ty elt = (TYPE ## _ty)asdl_seq_GET(seq, _i); \
if (!compiler_visit_ ## TYPE((C), elt)) { \
compiler_exit_scope(c); \
return 0; \
@@ -1809,8 +1787,8 @@
break;
case Interactive_kind:
c->c_interactive = 1;
- VISIT_SEQ_IN_SCOPE_WITH_CAST(c, stmt,
- mod->v.Interactive.body, stmt_ty);
+ VISIT_SEQ_IN_SCOPE(c, stmt,
+ mod->v.Interactive.body);
break;
case Expression_kind:
VISIT_IN_SCOPE(c, expr, mod->v.Expression.body);
@@ -1971,7 +1949,7 @@
if (!compiler_decorators(c, decos))
return 0;
if (args->defaults)
- VISIT_SEQ_WITH_CAST(c, expr, args->defaults, expr_ty);
+ VISIT_SEQ(c, expr, args->defaults);
if (!compiler_enter_scope(c, s->v.FunctionDef.name, (void *)s,
s->lineno))
return 0;
@@ -2024,7 +2002,7 @@
/* push the tuple of base classes on the stack */
n = asdl_seq_LEN(s->v.ClassDef.bases);
if (n > 0)
- VISIT_SEQ_WITH_CAST(c, expr, s->v.ClassDef.bases, expr_ty);
+ VISIT_SEQ(c, expr, s->v.ClassDef.bases);
ADDOP_I(c, BUILD_TUPLE, n);
if (!compiler_enter_scope(c, s->v.ClassDef.name, (void *)s,
s->lineno))
@@ -2108,7 +2086,7 @@
}
if (args->defaults)
- VISIT_SEQ_WITH_CAST(c, expr, args->defaults, expr_ty);
+ VISIT_SEQ(c, expr, args->defaults);
if (!compiler_enter_scope(c, name, (void *)e, e->lineno))
return 0;
@@ -2181,12 +2159,12 @@
VISIT(c, expr, s->v.If.test);
ADDOP_JREL(c, JUMP_IF_FALSE, next);
ADDOP(c, POP_TOP);
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.If.body, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.If.body);
ADDOP_JREL(c, JUMP_FORWARD, end);
compiler_use_next_block(c, next);
ADDOP(c, POP_TOP);
if (s->v.If.orelse)
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.If.orelse, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.If.orelse);
compiler_use_next_block(c, end);
return 1;
}
@@ -2209,12 +2187,12 @@
compiler_use_next_block(c, start);
ADDOP_JREL(c, FOR_ITER, cleanup);
VISIT(c, expr, s->v.For.target);
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.For.body, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.For.body);
ADDOP_JABS(c, JUMP_ABSOLUTE, start);
compiler_use_next_block(c, cleanup);
ADDOP(c, POP_BLOCK);
compiler_pop_fblock(c, LOOP, start);
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.For.orelse, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.For.orelse);
compiler_use_next_block(c, end);
return 1;
}
@@ -2253,7 +2231,7 @@
ADDOP_JREL(c, JUMP_IF_FALSE, anchor);
ADDOP(c, POP_TOP);
}
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.While.body, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.While.body);
ADDOP_JABS(c, JUMP_ABSOLUTE, loop);
/* XXX should the two POP instructions be in a separate block
@@ -2267,7 +2245,7 @@
}
compiler_pop_fblock(c, LOOP, loop);
if (orelse != NULL) /* what if orelse is just pass? */
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.While.orelse, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.While.orelse);
compiler_use_next_block(c, end);
return 1;
@@ -2348,7 +2326,7 @@
compiler_use_next_block(c, body);
if (!compiler_push_fblock(c, FINALLY_TRY, body))
return 0;
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.TryFinally.body, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.TryFinally.body);
ADDOP(c, POP_BLOCK);
compiler_pop_fblock(c, FINALLY_TRY, body);
@@ -2356,7 +2334,7 @@
compiler_use_next_block(c, end);
if (!compiler_push_fblock(c, FINALLY_END, end))
return 0;
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.TryFinally.finalbody, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.TryFinally.finalbody);
ADDOP(c, END_FINALLY);
compiler_pop_fblock(c, FINALLY_END, end);
@@ -2413,7 +2391,7 @@
compiler_use_next_block(c, body);
if (!compiler_push_fblock(c, EXCEPT, body))
return 0;
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.TryExcept.body, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.TryExcept.body);
ADDOP(c, POP_BLOCK);
compiler_pop_fblock(c, EXCEPT, body);
ADDOP_JREL(c, JUMP_FORWARD, orelse);
@@ -2444,7 +2422,7 @@
ADDOP(c, POP_TOP);
}
ADDOP(c, POP_TOP);
- VISIT_SEQ_WITH_CAST(c, stmt, handler->body, stmt_ty);
+ VISIT_SEQ(c, stmt, handler->body);
ADDOP_JREL(c, JUMP_FORWARD, end);
compiler_use_next_block(c, except);
if (handler->type)
@@ -2452,7 +2430,7 @@
}
ADDOP(c, END_FINALLY);
compiler_use_next_block(c, orelse);
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.TryExcept.orelse, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.TryExcept.orelse);
compiler_use_next_block(c, end);
return 1;
}
@@ -2672,7 +2650,7 @@
ADDOP(c, RETURN_VALUE);
break;
case Delete_kind:
- VISIT_SEQ_WITH_CAST(c, expr, s->v.Delete.targets, expr_ty)
+ VISIT_SEQ(c, expr, s->v.Delete.targets)
break;
case Assign_kind:
n = asdl_seq_LEN(s->v.Assign.targets);
@@ -3042,7 +3020,7 @@
if (e->v.List.ctx == Store) {
ADDOP_I(c, UNPACK_SEQUENCE, n);
}
- VISIT_SEQ_WITH_CAST(c, expr, e->v.List.elts, expr_ty);
+ VISIT_SEQ(c, expr, e->v.List.elts);
if (e->v.List.ctx == Load) {
ADDOP_I(c, BUILD_LIST, n);
}
@@ -3056,7 +3034,7 @@
if (e->v.Tuple.ctx == Store) {
ADDOP_I(c, UNPACK_SEQUENCE, n);
}
- VISIT_SEQ_WITH_CAST(c, expr, e->v.Tuple.elts, expr_ty);
+ VISIT_SEQ(c, expr, e->v.Tuple.elts);
if (e->v.Tuple.ctx == Load) {
ADDOP_I(c, BUILD_TUPLE, n);
}
@@ -3117,9 +3095,9 @@
VISIT(c, expr, e->v.Call.func);
n = asdl_seq_LEN(e->v.Call.args);
- VISIT_SEQ_WITH_CAST(c, expr, e->v.Call.args, expr_ty);
+ VISIT_SEQ(c, expr, e->v.Call.args);
if (e->v.Call.keywords) {
- VISIT_SEQ_WITH_CAST(c, keyword, e->v.Call.keywords, keyword_ty);
+ VISIT_SEQ(c, keyword, e->v.Call.keywords);
n |= asdl_seq_LEN(e->v.Call.keywords) << 8;
}
if (e->v.Call.starargs) {
@@ -3500,7 +3478,7 @@
}
/* BLOCK code */
- VISIT_SEQ_WITH_CAST(c, stmt, s->v.With.body, stmt_ty);
+ VISIT_SEQ(c, stmt, s->v.With.body);
/* End of try block; start the finally block */
ADDOP(c, POP_BLOCK);
More information about the Python-checkins
mailing list