本文整理汇总了Python中compiler.walk方法的典型用法代码示例。如果您正苦于以下问题:Python compiler.walk方法的具体用法?Python compiler.walk怎么用?Python compiler.walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compiler
的用法示例。
在下文中一共展示了compiler.walk方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _visitFuncOrLambda
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def _visitFuncOrLambda(self, node, isLambda=0):
if not isLambda and node.decorators:
for decorator in node.decorators.nodes:
self.visit(decorator)
ndecorators = len(node.decorators.nodes)
else:
ndecorators = 0
gen = self.FunctionGen(node, self.scopes, isLambda,
self.class_name, self.get_module())
walk(node.code, gen)
gen.finish()
self.set_lineno(node)
for default in node.defaults:
self.visit(default)
self._makeClosure(gen, len(node.defaults))
for i in range(ndecorators):
self.emit('CALL_FUNCTION', 1)
示例2: visitClass
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def visitClass(self, node):
gen = self.ClassGen(node, self.scopes,
self.get_module())
walk(node.code, gen)
gen.finish()
self.set_lineno(node)
self.emit('LOAD_CONST', node.name)
for base in node.bases:
self.visit(base)
self.emit('BUILD_TUPLE', len(node.bases))
self._makeClosure(gen, 0)
self.emit('CALL_FUNCTION', 0)
self.emit('BUILD_CLASS')
self.storeName(node.name)
# The rest are standard visitor methods
# The next few implement control-flow statements
示例3: parseSymbols
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def parseSymbols(self, tree):
s = symbols.SymbolVisitor()
walk(tree, s)
return s.scopes
示例4: visitModule
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def visitModule(self, node):
self.scopes = self.parseSymbols(node)
self.scope = self.scopes[node]
self.emit('SET_LINENO', 0)
if node.doc:
self.emit('LOAD_CONST', node.doc)
self.storeName('__doc__')
lnf = walk(node.node, self.NameFinder(), verbose=0)
self.locals.push(lnf.getLocals())
self.visit(node.node)
self.emit('LOAD_CONST', None)
self.emit('RETURN_VALUE')
示例5: visitGenExpr
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def visitGenExpr(self, node):
gen = GenExprCodeGenerator(node, self.scopes, self.class_name,
self.get_module())
walk(node.code, gen)
gen.finish()
self.set_lineno(node)
self._makeClosure(gen, 0)
# precomputation of outmost iterable
self.visit(node.code.quals[0].iter)
self.emit('GET_ITER')
self.emit('CALL_FUNCTION', 1)
示例6: __init__
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def __init__(self, tree):
self.graph = pyassem.PyFlowGraph("<expression>", tree.filename)
self.__super_init()
walk(tree, self)
示例7: findOp
# 需要导入模块: import compiler [as 别名]
# 或者: from compiler import walk [as 别名]
def findOp(node):
"""Find the op (DELETE, LOAD, STORE) in an AssTuple tree"""
v = OpFinder()
walk(node, v, verbose=0)
return v.op