当前位置: 首页>>代码示例>>Python>>正文


Python refs.resolution函数代码示例

本文整理汇总了Python中typhon.objects.refs.resolution函数的典型用法代码示例。如果您正苦于以下问题:Python resolution函数的具体用法?Python resolution怎么用?Python resolution使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了resolution函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: recv

    def recv(self, atom, args):
        if atom is PRINT_1:
            item = resolution(args[0])
            self._print(item)
            return NullObject

        if atom is PRINTLN_1:
            item = resolution(args[0])
            self.println(item)
            return NullObject

        if atom is LNPRINT_1:
            item = resolution(args[0])
            self.lnPrint(item)
            return NullObject

        if atom is QUOTE_1:
            item = resolution(args[0])
            if isinstance(item, CharObject) or isinstance(item, StrObject):
                self.ub.append(item.toQuote())
            else:
                self.objPrint(item)
            return NullObject

        if atom is INDENT_1:
            return self.indent(args[0])

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:28,代码来源:printers.py

示例2: auditedBy

def auditedBy(auditor, specimen):
    """
    Whether an auditor has audited a specimen.
    """
    from typhon.objects.refs import resolution
    from typhon.objects.constants import wrapBool
    return wrapBool(resolution(specimen).auditedBy(auditor))
开发者ID:markrwilliams,项目名称:typhon,代码行数:7,代码来源:auditors.py

示例3: promoteToBigInt

def promoteToBigInt(o):
    from typhon.objects.refs import resolution
    i = resolution(o)
    if isinstance(i, BigInt):
        return i.bi
    if isinstance(i, IntObject):
        return rbigint.fromint(i.getInt())
    raise WrongType(u"Not promotable to big integer!")
开发者ID:washort,项目名称:typhon,代码行数:8,代码来源:data.py

示例4: unwrapList

def unwrapList(o, ej=None):
    from typhon.objects.refs import resolution
    l = resolution(o)
    if isinstance(l, ConstList):
        return l.objs
    if isinstance(l, FlexList):
        return l.strategy.fetch_all(l)
    throwStr(ej, u"Not a list!")
开发者ID:dckc,项目名称:typhon,代码行数:8,代码来源:lists.py

示例5: checkSlot

 def checkSlot(self):
     if self.committed:
         return True
     self.resolutionBox = resolution(self.resolutionBox)
     if isResolved(self.resolutionBox):
         self.commit()
         return True
     return False
开发者ID:monte-language,项目名称:typhon,代码行数:8,代码来源:proxy.py

示例6: unwrapBool

def unwrapBool(o):
    from typhon.objects.refs import resolution
    b = resolution(o)
    if b is TrueObject:
        return True
    if b is FalseObject:
        return False
    raise userError(u"Not a boolean!")
开发者ID:dckc,项目名称:typhon,代码行数:8,代码来源:constants.py

示例7: unwrapSet

def unwrapSet(o):
    from typhon.objects.refs import resolution
    m = resolution(o)
    if isinstance(m, ConstSet):
        return m.objectSet
    if isinstance(m, FlexSet):
        return m.objectSet
    raise WrongType(u"Not a set!")
开发者ID:dckc,项目名称:typhon,代码行数:8,代码来源:sets.py

示例8: unwrapMap

def unwrapMap(o):
    from typhon.objects.refs import resolution
    m = resolution(o)
    if isinstance(m, ConstMap):
        return m.objectMap
    if isinstance(m, FlexMap):
        return m.objectMap
    raise WrongType(u"Not a map!")
开发者ID:markrwilliams,项目名称:typhon,代码行数:8,代码来源:maps.py

示例9: takeTurn

    def takeTurn(self):
        from typhon.objects.exceptions import sealException
        from typhon.objects.refs import Promise, resolution

        with self._pendingLock:
            resolver, target, atom, args, namedArgs = self._pending.pop(0)

        # Set up our Miranda FAIL.
        if namedArgs.extractStringKey(u"FAIL", None) is None:
            if resolver is not None:
                FAIL = resolver.makeSmasher()
            else:
                from typhon.objects.ejectors import theThrower
                FAIL = theThrower
            namedArgs = namedArgs.withStringKey(u"FAIL", FAIL)

        # If the target is a promise, then we should send to it instead of
        # calling. Try to resolve it as much as possible first, though.
        target = resolution(target)

        # self.log(u"Taking turn: %s<-%s(%s) (resolver: %s)" %
        #          (target.toQuote(), atom.verb,
        #           u", ".join([arg.toQuote() for arg in args]),
        #           u"yes" if resolver is not None else u"no"))
        try:
            if isinstance(target, Promise):
                if resolver is None:
                    target.sendOnly(atom, args, namedArgs)
                else:
                    result = target.send(atom, args, namedArgs)
                    # The resolver may have already been invoked, so we'll use
                    # .resolveRace/1 instead of .resolve/1. ~ C.
                    resolver.resolveRace(result)
            else:
                result = target.callAtom(atom, args, namedArgs)
                if resolver is not None:
                    # Same logic as above.
                    resolver.resolveRace(result)
        except UserException as ue:
            if resolver is not None:
                resolver.smash(sealException(ue))
            else:
                self.log(u"Uncaught user exception while taking turn"
                         u" (and no resolver): %s" %
                         ue.formatError().decode("utf-8"),
                         tags=["serious"])
        except VatCheckpointed:
            self.log(u"Ran out of checkpoints while taking turn",
                     tags=["serious"])
            if resolver is not None:
                resolver.smash(sealException(userError(u"Vat ran out of checkpoints")))
        except Ejecting:
            self.log(u"Ejector tried to escape vat turn boundary",
                     tags=["serious"])
            if resolver is not None:
                resolver.smash(sealException(userError(u"Ejector tried to escape from vat")))
开发者ID:monte-language,项目名称:typhon,代码行数:56,代码来源:vats.py

示例10: __init__

    def __init__(self, ref):
        self.ref = resolution(ref)
        self.fringe = []

        # Compute a "sameYet" hash, which represents a snapshot of how this
        # key's traversal had resolved at the time of key creation.
        snapHash = samenessHash(self.ref, HASH_DEPTH, self.fringe)
        for f in self.fringe:
            snapHash ^= f.fringeHash()
        self.snapHash = snapHash
开发者ID:dckc,项目名称:typhon,代码行数:10,代码来源:equality.py

示例11: promoteToDouble

def promoteToDouble(o):
    from typhon.objects.refs import resolution
    n = resolution(o)
    if isinstance(n, IntObject):
        return float(n.getInt())
    if isinstance(n, DoubleObject):
        return n.getDouble()
    if isinstance(n, BigInt):
        return n.bi.tofloat()
    raise WrongType(u"Failed to promote to double")
开发者ID:washort,项目名称:typhon,代码行数:10,代码来源:data.py

示例12: unwrapInt

def unwrapInt(o):
    from typhon.objects.refs import resolution
    i = resolution(o)
    if isinstance(i, IntObject):
        return i.getInt()
    if isinstance(i, BigInt):
        try:
            return i.bi.toint()
        except OverflowError:
            pass
    raise WrongType(u"Not an integer!")
开发者ID:washort,项目名称:typhon,代码行数:11,代码来源:data.py

示例13: coerce

 def coerce(self, specimen, ej):
     specimen = resolution(specimen)
     val = self.subCoerce(specimen)
     if val is None:
         newspec = specimen.call(u"_conformTo", [self])
         val = self.subCoerce(newspec)
         if val is None:
             throw(ej, StrObject(u"%s does not conform to %s" % (specimen.toQuote(), self.toQuote())))
         else:
             return val
     else:
         return val
开发者ID:markrwilliams,项目名称:typhon,代码行数:12,代码来源:guards.py

示例14: isInt

def isInt(obj):
    from typhon.objects.refs import resolution
    obj = resolution(obj)
    if isinstance(obj, IntObject):
        return True
    if isinstance(obj, BigInt):
        try:
            obj.bi.toint()
            return True
        except OverflowError:
            return False
    return False
开发者ID:dckc,项目名称:typhon,代码行数:12,代码来源:data.py

示例15: objPrint

 def objPrint(self, item):
     item = resolution(item)
     if isinstance(item, Promise):
         self.ub.append(u"<promise>")
         return
     elif item in self.context:
         self.ub.append(u"<**CYCLE**>")
         return
     self.context[item] = None
     try:
         item.call(u"_printOn", [self])
     except UserException, e:
         self.ub.append(u"<** %s throws %s when printed**>" % (item.toString(), e.error()))
开发者ID:markrwilliams,项目名称:typhon,代码行数:13,代码来源:printers.py


注:本文中的typhon.objects.refs.resolution函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。