Add support for extra (*) arguments to preorder.

Change default dispatch to use extended call syntax in place of apply.
This commit is contained in:
Jeremy Hylton 2001-04-11 16:26:05 +00:00
parent 9ab019bee7
commit d91bbba89d
2 changed files with 6 additions and 6 deletions

View File

@ -61,13 +61,13 @@ class ASTVisitor:
print "dispatch", className
else:
print "dispatch", className, (meth and meth.__name__ or '')
return apply(meth, (node,) + args)
return meth(node, *args)
def preorder(self, tree, visitor):
def preorder(self, tree, visitor, *args):
"""Do preorder walk of tree using visitor"""
self.visitor = visitor
visitor.visit = self._preorder
self._preorder(tree)
self._preorder(tree, *args) # XXX *args make sense?
_preorder = dispatch

View File

@ -61,13 +61,13 @@ class ASTVisitor:
print "dispatch", className
else:
print "dispatch", className, (meth and meth.__name__ or '')
return apply(meth, (node,) + args)
return meth(node, *args)
def preorder(self, tree, visitor):
def preorder(self, tree, visitor, *args):
"""Do preorder walk of tree using visitor"""
self.visitor = visitor
visitor.visit = self._preorder
self._preorder(tree)
self._preorder(tree, *args) # XXX *args make sense?
_preorder = dispatch