def assign_convert(ast, visitor=None): """ make a copy of the AST that converts all writable variables into using cells. In addition, compute the state of the environment for every AST node that needs to know. The vars arguments in all the visit_* methods contain the variables that need to use cells. The env_structure is an instance of SymList (or None) describing the environment at that AST node. """ if visitor is None: visitor = AssignConvertVisitor() return ast.visit(visitor, variable_set(), None)
def make_symbols(d): v = variable_set() for i, j in d.iteritems(): v[ModuleVar(W_Symbol.make(i), None, W_Symbol.make(i))] = j return v
def _mutated_vars(self): from pycket.interpreter import variable_set x = variable_set() for b in self.direct_children(): x.update(b.mutated_vars()) return x
def body_muts(self, node): assert isinstance(node, SequencedBodyAST) muts = variable_set() for b in node.body: muts.update(b.mutated_vars(self.mutated_vars_cache)) return muts
def body_muts(node): assert isinstance(node, SequencedBodyAST) muts = variable_set() for b in node.body: muts.update(b.mutated_vars()) return muts
def assign_convert(ast, visitor=None): if visitor is None: visitor = AssignConvertVisitor() return ast.visit(visitor, variable_set(), None)