From: Finn B. <bc...@us...> - 2000-12-06 20:49:32
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory slayer.i.sourceforge.net:/tmp/cvs-serv32545 Modified Files: SimpleCompiler.py Log Message: LocalFrame.__init__(): Allow ImportAll and ExecStmt to modify the locals. This is done by letting the global access use the slower getname instead of getglobal. This should in principle only be done when the function contain ImportAll or ExecStmt statements, but right now we always use the slow version. Index: SimpleCompiler.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/SimpleCompiler.py,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** SimpleCompiler.py 2000/11/30 08:54:55 2.10 --- SimpleCompiler.py 2000/12/06 20:49:28 2.11 *************** *** 75,78 **** --- 75,86 ---- (self.ivalue, value.asAny())) + class DynamicStringReference2(DynamicStringReference): + def setCode(self, value): + return jast.Invoke(self.iframe, "setglobal", + (self.ivalue, value.asAny())) + + def noValue(self): + # Reference to builtin + return self.frame.parent.factory.makePyObject(self.getCode()) *************** *** 100,104 **** def __init__(self, parent, newReference=DynamicIntReference): self.frame = jast.Identifier("frame") ! self.globalNamespace = parent.globalNamespace self.parent = parent self.newReference = newReference --- 108,119 ---- def __init__(self, parent, newReference=DynamicIntReference): self.frame = jast.Identifier("frame") ! ! # This should only use SlowGlobals if the function uses ! # ImportAll or ExecStmt. If not it should use ! # parent.globalNamespace. ! ! self.globalNamespace = SlowGlobals(parent) ! #self.globalNamespace = parent.globalNamespace ! self.parent = parent self.newReference = newReference *************** *** 201,204 **** --- 216,220 ---- def __init__(self, parent): LocalFrame.__init__(self, parent) + self.globalNamespace = parent.globalNamespace def getReference(self, name): *************** *** 231,234 **** --- 247,256 ---- self.names[name] = ret return ret + + class SlowGlobals(BasicGlobals): + def __init__(self, parent, newReference=DynamicStringReference2): + self.names = {} + self.newReference = newReference + self.parent = parent |