Esempio n. 1
0
    def createProvidedVariable(self, variable_name):
        # print("createProvidedVariable", self, variable_name)

        return Variables.LocalVariable(
            owner         = self,
            variable_name = variable_name
        )
Esempio n. 2
0
    def getLocalVariable(self, owner, variable_name):
        if variable_name not in self.local_variables:
            result = Variables.LocalVariable(owner=owner, variable_name=variable_name)

            self.local_variables[variable_name] = result

        return self.local_variables[variable_name]
Esempio n. 3
0
    def createProvidedVariable(self, variable_name):
        # print("createProvidedVariable", self, variable_name)

        if self.local_locals:
            return Variables.LocalVariable(owner=self,
                                           variable_name=variable_name)
        else:
            # Make sure the provider knows it has to provide a variable of this
            # name for the assignment.
            self.provider.getVariableForAssignment(variable_name=variable_name)

            return self.getClosureVariable(variable_name=variable_name)
Esempio n. 4
0
    def demoteClosureVariable(self, variable):
        assert variable.isLocalVariable()

        self.taken.remove(variable)

        assert variable.getOwner() is not self

        new_variable = Variables.LocalVariable(
            owner=self, variable_name=variable.getName())

        self.providing[variable.getName()] = new_variable

        updateVariableUsage(provider=self,
                            old_variable=variable,
                            new_variable=new_variable)

        VariableRegistry.addVariableUsage(new_variable, self)
Esempio n. 5
0
    def demoteClosureVariable(self, variable):
        assert variable.isLocalVariable()

        self.taken.remove(variable)

        assert variable.getOwner() is not self

        new_variable = Variables.LocalVariable(
            owner=self, variable_name=variable.getName())
        for variable_trace in variable.traces:
            if variable_trace.getOwner() is self:
                new_variable.addTrace(variable_trace)
        new_variable.updateUsageState()

        self.providing[variable.getName()] = new_variable

        updateVariableUsage(provider=self,
                            old_variable=variable,
                            new_variable=new_variable)