def run(self, guard, specimen, ej): if guard != NullObject: val = guard.call(u"coerce", [specimen, ej]) g = guard else: val = specimen g = anyGuard return FinalSlot(val, g)
def recv(self, atom, args): if atom is RUN_3: guard, specimen, ej = args[0], args[1], args[2] if guard != NullObject: val = guard.coerce(specimen, ej) g = guard else: val = specimen g = anyGuard return FinalSlot(val, g) if atom is ASTYPE_0: return theFinalSlotGuardMaker raise Refused(self, atom, args)
def commit(self): if self.committed: raise userError(u"already commited") self.committed = True if isinstance(self.resolutionBox, FinalSlot): res = self.resolutionBox.get() else: res = UnconnectedRef( StrObject(u"Resolution promise of a proxy handled by " + self.handler.toString() + u" didn't resolve to a FinalSlot, but " + self.resolutionBox.toString() + u" instead.")) self.resolutionBox = FinalSlot(res, anyGuard) self.handler = None return res
def commit(self): # A FarRef can only stop proxying if it becomes disconnected, when it # resolves to a DisconnectedRef. handler = self.handler resolution = Proxy.commit(self) if not isinstance(resolution, UnconnectedRef): problem = StrObject(u"Attempt to resolve a far ref handled by " + handler.toString() + u"to a different identity (" + resolution.toString() + u")") else: problem = resolution._problem resolution = DisconnectedRef(handler, self.resolutionIdentity, problem) self.resolutionBox = FinalSlot(resolution, anyGuard) self.resolutionIdentity = None
def testFinalImmutabilityLocal(self): env = Environment([], [], 1, 0, 0) env.createSlotLocal(0, FinalSlot(NullObject, NullObject), theFinalSlotGuardMaker) self.assertRaises(UserException, env.putValueLocal, 0, NullObject)
def testFinalImmutabilityFrame(self): env = Environment([ Binding(FinalSlot(NullObject, NullObject), theFinalSlotGuardMaker) ], [], 0, 0, 0) self.assertRaises(UserException, env.putValueFrame, 0, NullObject)