Ejemplo n.º 1
0
 def __init__(self):
     self.env = global_env()
Ejemplo n.º 2
0
 def reset(self):
     self.env = global_env()
Ejemplo n.º 3
0
from collections import defaultdict
from contextlib import contextmanager
from tc.common import BaseVisitor
from tc.globals import global_env
from tc.parser import Assignment

global_functions = global_env().functions.keys()

TOP = 'PROGRAM'


class VarDefLocator(BaseVisitor):
    """Finds all variable declarations/assignments in the program."""

    def __init__(self):
        self.defs = set()

    def reset(self):
        self.defs = set()

    def run(self, statements):
        for stmt in statements:
            self.visit(stmt)
        return self.defs

    def visit_block(self, node):
        for stmt in node.statements:
            self.visit(stmt)

    def visit_function_def(self, node):
        for p in node.parameters: