[Python-checkins] CVS: python/dist/src/Lib/compiler ast.py,1.19,1.20 pycodegen.py,1.58,1.59 symbols.py,1.10,1.11 transformer.py,1.30,1.31

Barry Warsaw bwarsaw@users.sourceforge.net
Fri, 21 Dec 2001 12:03:38 -0800


Update of /cvsroot/python/python/dist/src/Lib/compiler
In directory usw-pr-cvs1:/tmp/cvs-serv14609/Lib/compiler

Modified Files:
	ast.py pycodegen.py symbols.py transformer.py 
Log Message:
Merge of the release22 branch changes back into the trunk.


Index: ast.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/ast.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** ast.py	2001/10/18 21:57:37	1.19
--- ast.py	2001/12/21 20:03:35	1.20
***************
*** 283,286 ****
--- 283,301 ----
          return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
  
+ class Expression(Node):
+     # Expression is an artifical node class to support "eval"
+     nodes["expression"] = "Expression"
+     def __init__(self, node):
+         self.node = node
+ 
+     def getChildren(self):
+         return self.node,
+ 
+     def getChildNodes(self):
+         return self.node,
+ 
+     def __repr__(self):
+         return "Expression(%s)" % (repr(self.node))
+ 
  class UnaryAdd(Node):
      nodes["unaryadd"] = "UnaryAdd"

Index: pycodegen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** pycodegen.py	2001/11/27 23:35:10	1.58
--- pycodegen.py	2001/12/21 20:03:35	1.59
***************
*** 35,38 ****
--- 35,39 ----
  END_FINALLY = 4
  
+ # XXX this doesn't seem to be used
  class BlockStack(misc.Stack):
      __super_init = misc.Stack.__init__
***************
*** 352,355 ****
--- 353,363 ----
          self.emit('RETURN_VALUE')
  
+     def visitExpression(self, node):
+         self.set_lineno(node)
+         self.scopes = self.parseSymbols(node)
+         self.scope = self.scopes[node]
+         self.visit(node.node)
+         self.emit('RETURN_VALUE')
+ 
      def visitFunction(self, node):
          self._visitFuncOrLambda(node, isLambda=0)
***************
*** 1159,1165 ****
          self.graph = pyassem.PyFlowGraph("<expression>", tree.filename)
          self.__super_init()
-         self.set_lineno(tree)
          walk(tree, self)
-         self.emit('RETURN_VALUE')
  
      def get_module(self):
--- 1167,1171 ----
***************
*** 1182,1185 ****
--- 1188,1192 ----
      def get_module(self):
          return self
+     
      def visitDiscard(self, node):
          # XXX Discard means it's an expression.  Perhaps this is a bad
***************
*** 1300,1304 ****
          self.graph.setFreeVars(self.scope.get_free_vars())
          self.graph.setCellVars(self.scope.get_cell_vars())
- ##        self.graph.setFlag(CO_NESTED)
  
  def generateArgList(arglist):
--- 1307,1310 ----

Index: symbols.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/symbols.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** symbols.py	2001/10/18 21:57:37	1.10
--- symbols.py	2001/12/21 20:03:35	1.11
***************
*** 207,210 ****
--- 207,212 ----
          self.visit(node.node, scope)
  
+     visitExpression = visitModule
+ 
      def visitFunction(self, node, parent):
          parent.add_def(node.name)

Index: transformer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** transformer.py	2001/10/18 21:57:37	1.30
--- transformer.py	2001/12/21 20:03:35	1.31
***************
*** 173,177 ****
          # from the built-in function input()
          ### is this sufficient?
!         return self.com_node(nodelist[0])
  
      def funcdef(self, nodelist):
--- 173,177 ----
          # from the built-in function input()
          ### is this sufficient?
!         return Expression(self.com_node(nodelist[0]))
  
      def funcdef(self, nodelist):