예제 #1
0
파일: safe.py 프로젝트: zarutian/typhon
 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)
예제 #2
0
 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)
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 def testFinalImmutabilityLocal(self):
     env = Environment([], [], 1, 0, 0)
     env.createSlotLocal(0, FinalSlot(NullObject, NullObject),
                         theFinalSlotGuardMaker)
     self.assertRaises(UserException, env.putValueLocal, 0, NullObject)
예제 #6
0
 def testFinalImmutabilityFrame(self):
     env = Environment([
         Binding(FinalSlot(NullObject, NullObject), theFinalSlotGuardMaker)
     ], [], 0, 0, 0)
     self.assertRaises(UserException, env.putValueFrame, 0, NullObject)