def optInterface(self): return getGlobalValue(u"Char")
def optInterface(self): return getGlobalValue(u"Bytes")
def optInterface(self): return getGlobalValue(u"Double")
def optInterface(self): return getGlobalValue(u"Int")
def optInterface(self): return getGlobalValue(u"Void")
def deepFrozenSupersetOf(guard): from typhon.objects.collections.helpers import monteMap from typhon.objects.collections.lists import unwrapList from typhon.objects.constants import wrapBool from typhon.objects.ejectors import Ejector from typhon.objects.refs import Promise from typhon.objects.guards import (AnyOfGuard, BoolGuard, BytesGuard, CharGuard, DoubleGuard, FinalSlotGuard, IntGuard, SameGuard, StrGuard, SubrangeGuard, VoidGuard) from typhon.prelude import getGlobalValue if guard is deepFrozenGuard: return True if guard is deepFrozenStamp: return True if isinstance(guard, Promise): guard = guard.resolution() if isinstance(guard, BoolGuard): return True if isinstance(guard, BytesGuard): return True if isinstance(guard, CharGuard): return True if isinstance(guard, DoubleGuard): return True if isinstance(guard, IntGuard): return True if isinstance(guard, StrGuard): return True if isinstance(guard, VoidGuard): return True if isinstance(guard, SameGuard): with Ejector() as ej: try: v = guard.value checkDeepFrozen(v, monteMap(), ej, v) return True except Ejecting: return False if isinstance(guard, FinalSlotGuard): return deepFrozenSupersetOf(guard.valueGuard) for superGuardName in [u"List", u"NullOk", u"Set"]: superGuard = getGlobalValue(superGuardName) if superGuard is None: continue with Ejector() as ej: try: subGuard = superGuard.call(u"extractGuard", [guard, ej]) return deepFrozenSupersetOf(subGuard) except Ejecting as e: # Just keep going. if e.ejector is not ej: raise for pairGuardName in [u"Map", u"Pair"]: pairGuard = getGlobalValue(pairGuardName) if pairGuard is None: continue with Ejector() as ej: try: guardPair = pairGuard.call(u"extractGuards", [guard, ej]) l = unwrapList(guardPair, ej) if len(l) == 2: return deepFrozenSupersetOf(l[0]) and deepFrozenSupersetOf( l[1]) except Ejecting as e: if e.ejector is not ej: raise if (SubrangeGuard(deepFrozenGuard).call(u"passes", [guard]) is wrapBool(True)): return True if isinstance(guard, AnyOfGuard): for g in guard.subguards: if not deepFrozenSupersetOf(g): return False return True return False
def deepFrozenSupersetOf(guard): from typhon.objects.collections.helpers import monteMap from typhon.objects.collections.lists import ConstList from typhon.objects.constants import wrapBool from typhon.objects.ejectors import Ejector from typhon.objects.refs import Promise from typhon.objects.guards import ( AnyOfGuard, BoolGuard, BytesGuard, CharGuard, DoubleGuard, FinalSlotGuard, IntGuard, SameGuard, StrGuard, SubrangeGuard, VoidGuard) from typhon.prelude import getGlobalValue if guard is deepFrozenGuard: return True if guard is deepFrozenStamp: return True if isinstance(guard, Promise): guard = guard.resolution() if isinstance(guard, BoolGuard): return True if isinstance(guard, BytesGuard): return True if isinstance(guard, CharGuard): return True if isinstance(guard, DoubleGuard): return True if isinstance(guard, IntGuard): return True if isinstance(guard, StrGuard): return True if isinstance(guard, VoidGuard): return True if isinstance(guard, SameGuard): ej = Ejector() try: v = guard.value checkDeepFrozen(v, monteMap(), ej, v) return True except Ejecting: return False if isinstance(guard, FinalSlotGuard): return deepFrozenSupersetOf(guard.valueGuard) for superGuardName in [u"List", u"NullOk", u"Set"]: superGuard = getGlobalValue(superGuardName) if superGuard is None: continue ej = Ejector() try: subGuard = superGuard.call(u"extractGuard", [guard, ej]) return deepFrozenSupersetOf(subGuard) except Ejecting: # XXX lets other ejectors get through pass for pairGuardName in [u"Map", u"Pair"]: pairGuard = getGlobalValue(pairGuardName) if pairGuard is None: continue ej = Ejector() try: guardPair = pairGuard.call(u"extractGuards", [guard, ej]) if isinstance(guardPair, ConstList) and guardPair.size() == 2: return ( (deepFrozenSupersetOf(guardPair.strategy.fetch( guardPair, 0))) and (deepFrozenSupersetOf(guardPair.strategy.fetch( guardPair, 1)))) except Ejecting: # XXX lets other ejectors get through pass if (SubrangeGuard(deepFrozenGuard).call(u"passes", [guard]) is wrapBool(True)): return True if isinstance(guard, AnyOfGuard): for g in guard.subguards: if not deepFrozenSupersetOf(g): return False return True return False