Kaydet (Commit) 9605c11c authored tarafından Jeremy Hylton's avatar Jeremy Hylton

move constants out of transformer so that they can be shared with ast

add varargs and kwargs attributes to Function nodes
üst 69e2c6ef
import types import types
from consts import CO_VARARGS, CO_VARKEYWORDS
nodes = {} nodes = {}
...@@ -85,6 +86,12 @@ class Function(Node): ...@@ -85,6 +86,12 @@ class Function(Node):
self.code = code self.code = code
self._children = ('function', self._children = ('function',
name, argnames, defaults, flags, doc, code) 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): def __repr__(self):
return "Function(%s,%s,%s,%s,%s,%s)" % self._children[1:] return "Function(%s,%s,%s,%s,%s,%s)" % self._children[1:]
......
...@@ -99,14 +99,8 @@ import pprint ...@@ -99,14 +99,8 @@ import pprint
error = 'walker.error' error = 'walker.error'
# code flags from consts import CO_VARARGS, CO_VARKEYWORDS
CO_VARARGS = 1 from consts import OP_ASSIGN, OP_DELETE, OP_APPLY
CO_VARKEYWORDS = 2
# operation flags
OP_ASSIGN = 'OP_ASSIGN'
OP_DELETE = 'OP_DELETE'
OP_APPLY = 'OP_APPLY'
def asList(nodes): def asList(nodes):
l = [] l = []
......
import types import types
from consts import CO_VARARGS, CO_VARKEYWORDS
nodes = {} nodes = {}
...@@ -85,6 +86,12 @@ class Function(Node): ...@@ -85,6 +86,12 @@ class Function(Node):
self.code = code self.code = code
self._children = ('function', self._children = ('function',
name, argnames, defaults, flags, doc, code) 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): def __repr__(self):
return "Function(%s,%s,%s,%s,%s,%s)" % self._children[1:] return "Function(%s,%s,%s,%s,%s,%s)" % self._children[1:]
......
...@@ -99,14 +99,8 @@ import pprint ...@@ -99,14 +99,8 @@ import pprint
error = 'walker.error' error = 'walker.error'
# code flags from consts import CO_VARARGS, CO_VARKEYWORDS
CO_VARARGS = 1 from consts import OP_ASSIGN, OP_DELETE, OP_APPLY
CO_VARKEYWORDS = 2
# operation flags
OP_ASSIGN = 'OP_ASSIGN'
OP_DELETE = 'OP_DELETE'
OP_APPLY = 'OP_APPLY'
def asList(nodes): def asList(nodes):
l = [] l = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment