move constants out of transformer so that they can be shared with ast
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 8 Feb 2000 18:57:32 +0000 (18:57 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 8 Feb 2000 18:57:32 +0000 (18:57 +0000)
add varargs and kwargs attributes to Function nodes

Lib/compiler/ast.py
Lib/compiler/transformer.py
Tools/compiler/compiler/ast.py
Tools/compiler/compiler/transformer.py

index 9c214d453d102507773f0a5453cad76dbc5f3eb2..1715a7f65c4918d2fd2ef781f5cee33eae01df09 100644 (file)
@@ -1,4 +1,5 @@
 import types
+from consts import CO_VARARGS, CO_VARKEYWORDS
 
 nodes = {}
 
@@ -85,6 +86,12 @@ class Function(Node):
     self.code = code
     self._children = ('function',
                        name, argnames, defaults, flags, doc, code)
+    self.varargs = self.kwargs = None
+    if flags & CO_VARARGS:
+      self.varargs = 1
+    if flags & CO_VARKEYWORDS:
+      self.kwargs = 1
+    
 
   def __repr__(self):
     return "Function(%s,%s,%s,%s,%s,%s)" % self._children[1:]
index 9200f7acbd5bbfb6b283f14d65c33261be8644fb..42d34dcbdc608998b21c0bc019b85f59dfe2690b 100644 (file)
@@ -99,14 +99,8 @@ import pprint
 
 error = 'walker.error'
 
-# code flags
-CO_VARARGS = 1
-CO_VARKEYWORDS = 2
-
-# operation flags
-OP_ASSIGN = 'OP_ASSIGN'
-OP_DELETE = 'OP_DELETE'
-OP_APPLY = 'OP_APPLY'
+from consts import CO_VARARGS, CO_VARKEYWORDS
+from consts import OP_ASSIGN, OP_DELETE, OP_APPLY
 
 def asList(nodes):
   l = []
index 9c214d453d102507773f0a5453cad76dbc5f3eb2..1715a7f65c4918d2fd2ef781f5cee33eae01df09 100644 (file)
@@ -1,4 +1,5 @@
 import types
+from consts import CO_VARARGS, CO_VARKEYWORDS
 
 nodes = {}
 
@@ -85,6 +86,12 @@ class Function(Node):
     self.code = code
     self._children = ('function',
                        name, argnames, defaults, flags, doc, code)
+    self.varargs = self.kwargs = None
+    if flags & CO_VARARGS:
+      self.varargs = 1
+    if flags & CO_VARKEYWORDS:
+      self.kwargs = 1
+    
 
   def __repr__(self):
     return "Function(%s,%s,%s,%s,%s,%s)" % self._children[1:]
index 9200f7acbd5bbfb6b283f14d65c33261be8644fb..42d34dcbdc608998b21c0bc019b85f59dfe2690b 100644 (file)
@@ -99,14 +99,8 @@ import pprint
 
 error = 'walker.error'
 
-# code flags
-CO_VARARGS = 1
-CO_VARKEYWORDS = 2
-
-# operation flags
-OP_ASSIGN = 'OP_ASSIGN'
-OP_DELETE = 'OP_DELETE'
-OP_APPLY = 'OP_APPLY'
+from consts import CO_VARARGS, CO_VARKEYWORDS
+from consts import OP_ASSIGN, OP_DELETE, OP_APPLY
 
 def asList(nodes):
   l = []