def createProvidedVariable(self, variable_name): # print("createProvidedVariable", self, variable_name) return Variables.LocalVariable( owner = self, variable_name = variable_name )
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]
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)
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)
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)