mirror of
https://github.com/python/cpython.git
synced 2025-09-10 02:36:56 +00:00
* Remove PRINT_ITEM(_TO), PRINT_NEWLINE(_TO) opcodes.
* Fix some docstrings and one Print -> print. * Fix test_{class,code,descrtut,dis,extcall,parser,popen,pkg,subprocess,syntax,traceback}. These were the ones that generated code with a print statement. In most remaining failing tests there's an issue with the soft space.
This commit is contained in:
parent
08c47ba0df
commit
88fc6646d1
31 changed files with 159 additions and 553 deletions
|
@ -734,14 +734,6 @@ opcode_stack_effect(int opcode, int oparg)
|
|||
|
||||
case PRINT_EXPR:
|
||||
return -1;
|
||||
case PRINT_ITEM:
|
||||
return -1;
|
||||
case PRINT_NEWLINE:
|
||||
return 0;
|
||||
case PRINT_ITEM_TO:
|
||||
return -2;
|
||||
case PRINT_NEWLINE_TO:
|
||||
return -1;
|
||||
case INPLACE_LSHIFT:
|
||||
case INPLACE_RSHIFT:
|
||||
case INPLACE_AND:
|
||||
|
@ -1625,43 +1617,6 @@ compiler_lambda(struct compiler *c, expr_ty e)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
compiler_print(struct compiler *c, stmt_ty s)
|
||||
{
|
||||
int i, n;
|
||||
bool dest;
|
||||
|
||||
assert(s->kind == Print_kind);
|
||||
n = asdl_seq_LEN(s->v.Print.values);
|
||||
dest = false;
|
||||
if (s->v.Print.dest) {
|
||||
VISIT(c, expr, s->v.Print.dest);
|
||||
dest = true;
|
||||
}
|
||||
for (i = 0; i < n; i++) {
|
||||
expr_ty e = (expr_ty)asdl_seq_GET(s->v.Print.values, i);
|
||||
if (dest) {
|
||||
ADDOP(c, DUP_TOP);
|
||||
VISIT(c, expr, e);
|
||||
ADDOP(c, ROT_TWO);
|
||||
ADDOP(c, PRINT_ITEM_TO);
|
||||
}
|
||||
else {
|
||||
VISIT(c, expr, e);
|
||||
ADDOP(c, PRINT_ITEM);
|
||||
}
|
||||
}
|
||||
if (s->v.Print.nl) {
|
||||
if (dest)
|
||||
ADDOP(c, PRINT_NEWLINE_TO)
|
||||
else
|
||||
ADDOP(c, PRINT_NEWLINE)
|
||||
}
|
||||
else if (dest)
|
||||
ADDOP(c, POP_TOP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
compiler_if(struct compiler *c, stmt_ty s)
|
||||
{
|
||||
|
@ -2236,8 +2191,6 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
|
|||
break;
|
||||
case AugAssign_kind:
|
||||
return compiler_augassign(c, s);
|
||||
case Print_kind:
|
||||
return compiler_print(c, s);
|
||||
case For_kind:
|
||||
return compiler_for(c, s);
|
||||
case While_kind:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue