本文整理汇总了Python中syntax_visitor.SyntaxVisitor类的典型用法代码示例。如果您正苦于以下问题:Python SyntaxVisitor类的具体用法?Python SyntaxVisitor怎么用?Python SyntaxVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SyntaxVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_While
def visit_While(self, stmt):
self.volatile_vars.push(stmt.merge.keys())
SyntaxVisitor.visit_While(self, stmt)
if self.does_block_return(stmt.body):
self.block_contains_return()
volatile_in_scope = self.volatile_vars.pop()
self.mark_safe_assignments(stmt.body, volatile_in_scope)
示例2: __init__
def __init__(self, fn):
SyntaxVisitor.__init__(self)
self.fn = fn
self.call_stack.append(fn)
self.bound = set(fn.arg_names)
self.seen_return = False
示例3: visit_block
def visit_block(self, stmts, branch_label = None):
self.push_scope()
if branch_label is not None:
self.push_scope(branch_label)
SyntaxVisitor.visit_block(self, stmts)
if branch_label is not None:
self.pop_scope()
self.pop_scope()
示例4: visit_If
def visit_If(self, stmt):
self.volatile_vars.push(stmt.merge.keys())
self.visit_expr(stmt.cond)
SyntaxVisitor.visit_If(self, stmt)
if self.does_block_return(stmt.true) or self.does_block_return(stmt.false):
self.mark_curr_block_returns()
volatile_in_scope = self.volatile_vars.pop()
self.mark_safe_assignments(stmt.true, volatile_in_scope)
self.mark_safe_assignments(stmt.false, volatile_in_scope)
示例5: __init__
def __init__(self):
SyntaxVisitor.__init__(self)
self.mutable_types = None
self.volatile_vars = ScopedSet()
self.depends_on = {}
self.safe_to_move = set([])
self.curr_block_id = None
self.block_contains_return = set([])
self.may_alias = None
示例6: visit_expr
def visit_expr(self, expr):
if isinstance(expr, (UntypedFn, TypedFn, Closure)) or isinstance(expr.type, (FnT, ClosureT)):
raise Yes()
SyntaxVisitor.visit_expr(expr)
示例7: __init__
def __init__(self):
SyntaxVisitor.__init__(self)
self.ranges = {}
self.old_values = ScopedDict()
self.old_values.push()
示例8: visit_stmt
def visit_stmt(self, stmt):
self.inc_counter()
self.stmt_paths[id(stmt)] = self.curr_path()
SyntaxVisitor.visit_stmt(self, stmt)
示例9: __init__
def __init__(self):
SyntaxVisitor.__init__(self)
self.bindings = {}
示例10: visit_expr
def visit_expr(self, expr):
abstract_shape = SyntaxVisitor.visit_expr(self, expr)
assert abstract_shape is not None, \
"Unsupported expression in shape inference: %s" % expr.node_type()
return abstract_shape
示例11: visit_expr
def visit_expr(self, expr):
assert expr is not None
assert expr.type is not None, \
"Missing type annotation on %s" % expr
SyntaxVisitor.visit_expr(self, expr)
示例12: visit_expr
def visit_expr(self, expr):
if isinstance(expr, Adverb):
raise self.Yes()
SyntaxVisitor.visit_expr(self, expr)
示例13: visit_fn
def visit_fn(self, fn):
self.volatile_vars.push(fn.arg_names)
self.may_alias = may_alias(fn)
SyntaxVisitor.visit_fn(self, fn)
return self.safe_to_move
示例14: __init__
def __init__(self, fn):
SyntaxVisitor.__init__(self)
self.fn = fn
self.bound = set(fn.arg_names)
示例15: visit_expr
def visit_expr(self, expr):
assert expr is not None
SyntaxVisitor.visit_expr(self, expr)