summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-02-09 21:28:07 (GMT)
committerGeorg Brandl <georg@python.org>2007-02-09 21:28:07 (GMT)
commit88fc6646d1b97cb3ba6188808e7c016884d44a73 (patch)
tree4cf73aca05a06e89ae71a719c7b2329af51392b8 /Lib/compiler
parent08c47ba0df4ba87cdce34c126e5bdb28f8c6034c (diff)
downloadcpython-88fc6646d1b97cb3ba6188808e7c016884d44a73.zip
cpython-88fc6646d1b97cb3ba6188808e7c016884d44a73.tar.gz
cpython-88fc6646d1b97cb3ba6188808e7c016884d44a73.tar.bz2
* 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.
Diffstat (limited to 'Lib/compiler')
-rw-r--r--Lib/compiler/ast.py44
-rw-r--r--Lib/compiler/pyassem.py3
-rw-r--r--Lib/compiler/pycodegen.py23
-rw-r--r--Lib/compiler/transformer.py21
4 files changed, 1 insertions, 90 deletions
diff --git a/Lib/compiler/ast.py b/Lib/compiler/ast.py
index ac48710..259e1c4 100644
--- a/Lib/compiler/ast.py
+++ b/Lib/compiler/ast.py
@@ -998,50 +998,6 @@ class Power(Node):
def __repr__(self):
return "Power((%s, %s))" % (repr(self.left), repr(self.right))
-class Print(Node):
- def __init__(self, nodes, dest, lineno=None):
- self.nodes = nodes
- self.dest = dest
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.extend(flatten(self.nodes))
- children.append(self.dest)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- if self.dest is not None:
- nodelist.append(self.dest)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
-
-class Printnl(Node):
- def __init__(self, nodes, dest, lineno=None):
- self.nodes = nodes
- self.dest = dest
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.extend(flatten(self.nodes))
- children.append(self.dest)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- if self.dest is not None:
- nodelist.append(self.dest)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
-
class Raise(Node):
def __init__(self, expr1, expr2, expr3, lineno=None):
self.expr1 = expr1
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py
index 9f45d61..551791e 100644
--- a/Lib/compiler/pyassem.py
+++ b/Lib/compiler/pyassem.py
@@ -783,8 +783,7 @@ class StackDepthTracker:
'DELETE_SLICE+3': -3,
'STORE_SUBSCR': -3,
'DELETE_SUBSCR': -2,
- # PRINT_EXPR?
- 'PRINT_ITEM': -1,
+ 'PRINT_EXPR': -1,
'RETURN_VALUE': -1,
'YIELD_VALUE': -1,
'BUILD_CLASS': -2,
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index 0e49781..8db4e0d 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -1130,29 +1130,6 @@ class CodeGenerator:
opcode = callfunc_opcode_info[have_star, have_dstar]
self.emit(opcode, kw << 8 | pos)
- def visitPrint(self, node, newline=0):
- self.set_lineno(node)
- if node.dest:
- self.visit(node.dest)
- for child in node.nodes:
- if node.dest:
- self.emit('DUP_TOP')
- self.visit(child)
- if node.dest:
- self.emit('ROT_TWO')
- self.emit('PRINT_ITEM_TO')
- else:
- self.emit('PRINT_ITEM')
- if node.dest and not newline:
- self.emit('POP_TOP')
-
- def visitPrintnl(self, node):
- self.visitPrint(node, newline=1)
- if node.dest:
- self.emit('PRINT_NEWLINE_TO')
- else:
- self.emit('PRINT_NEWLINE')
-
def visitReturn(self, node):
self.set_lineno(node)
self.visit(node.value)
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index 3a2be13..5f2face 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -387,26 +387,6 @@ class Transformer:
return AugAssign(lval, op[1], exprNode, lineno=op[2])
raise WalkerError, "can't get here"
- def print_stmt(self, nodelist):
- # print ([ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ])
- items = []
- if len(nodelist) == 1:
- start = 1
- dest = None
- elif nodelist[1][0] == token.RIGHTSHIFT:
- assert len(nodelist) == 3 \
- or nodelist[3][0] == token.COMMA
- dest = self.com_node(nodelist[2])
- start = 4
- else:
- dest = None
- start = 1
- for i in range(start, len(nodelist), 2):
- items.append(self.com_node(nodelist[i]))
- if nodelist[-1][0] == token.COMMA:
- return Print(items, dest, lineno=nodelist[0][2])
- return Printnl(items, dest, lineno=nodelist[0][2])
-
def del_stmt(self, nodelist):
return self.com_assign(nodelist[1], OP_DELETE)
@@ -1480,7 +1460,6 @@ _legal_node_types = [
symbol.simple_stmt,
symbol.compound_stmt,
symbol.expr_stmt,
- symbol.print_stmt,
symbol.del_stmt,
symbol.pass_stmt,
symbol.break_stmt,