• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python refs.resolution函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: sendOnly

    def sendOnly(self, target, verb, args, namedArgs):
        """
        Send a message to an object.

        The message will be delivered on some subsequent turn.
        """

        namedArgs = resolution(namedArgs)
        if not isinstance(namedArgs, ConstMap):
            raise WrongType(u"namedArgs must be a ConstMap")
        # Signed, sealed, delivered, I'm yours.
        sendAtom = getAtom(verb, len(args))
        vat = currentVat.get()
        vat.sendOnly(target, sendAtom, args, namedArgs)
开发者ID:dckc,项目名称:typhon,代码行数:14,代码来源:safe.py


示例17: samenessFringe

def samenessFringe(original, path, fringe, sofar=None):
    """
    Walk an object graph, building up the fringe.

    Returns whether the graph is settled.
    """

    # Resolve the object.
    o = resolution(original)
    # Handle primitive cases first.
    if o in (NullObject, TrueObject, FalseObject):
        return True

    if (isinstance(o, CharObject) or isinstance(o, DoubleObject) or
        isinstance(o, IntObject) or isinstance(o, BigInt) or
        isinstance(o, StrObject) or isinstance(o, BytesObject) or
        isinstance(o, TraversalKey)):
        return True

    if isinstance(o, ConstMap) and o.empty():
        return True

    if sofar is None:
        sofar = {}
    elif o in sofar:
        return True

    if isinstance(o, ConstList):
        sofar[o] = None
        return listFringe(o, fringe, path, sofar)

    if selfless in o.auditorStamps():
        if transparentStamp in o.auditorStamps():
            sofar[o] = None
            return samenessFringe(o.call(u"_uncall", []), path, fringe, sofar)
        if semitransparentStamp in o.auditorStamps():
            sofar[o] = None
            p = o.call(u"_uncall", [])
            if not isinstance(p, SealedPortrayal):
                userError(u'Semitransparent portrayal was not a SealedPortrayal!')
            return samenessFringe(p, path, fringe, sofar)

    if isResolved(o):
        return True

    # Welp, it's unsettled.
    if fringe is not None:
        fringe.append(FringeNode(o, path))
    return False
开发者ID:monte-language,项目名称:typhon,代码行数:49,代码来源:equality.py


示例18: callWithMessage

    def callWithMessage(self, target, message):
        """
        Pass a message of `[verb :Str, args :List, namedArgs :Map]` to an
        object.
        """

        if len(message) != 3:
            raise userError(
                u"callWithPair/2 requires a [verb, args, namedArgs] triple")
        verb = unwrapStr(message[0])
        args = unwrapList(message[1])
        namedArgs = resolution(message[2])
        if not isinstance(namedArgs, ConstMap):
            raise WrongType(u"namedArgs must be a ConstMap")
        return target.call(verb, args, namedArgs)
开发者ID:dckc,项目名称:typhon,代码行数:15,代码来源:safe.py


示例19: nearGuard

def nearGuard(specimen, ej):
    """
    A guard over references to near values.

    This guard admits any near value, as well as any resolved reference to any
    near value.

    This guard is unretractable.
    """

    specimen = resolution(specimen)
    if isinstance(specimen, Promise):
        msg = u"Specimen is in non-near state %s" % specimen.state().repr
        throw(ej, StrObject(msg))
    return specimen
开发者ID:markrwilliams,项目名称:typhon,代码行数:15,代码来源:safe.py


示例20: samenessFringe

def samenessFringe(original, path, fringe, sofar=None):
    """
    Walk an object graph, building up the fringe.

    Returns whether the graph is settled.
    """

    # Resolve the object.
    o = resolution(original)
    # Handle primitive cases first.
    if o is NullObject:
        return True

    if (
        isinstance(o, BoolObject)
        or isinstance(o, CharObject)
        or isinstance(o, DoubleObject)
        or isinstance(o, IntObject)
        or isinstance(o, BigInt)
        or isinstance(o, StrObject)
        or isinstance(o, TraversalKey)
    ):
        return True

    if isinstance(o, ConstMap) and len(o.objectMap) == 0:
        return True

    if sofar is None:
        sofar = {}
    elif o in sofar:
        return True

    if isinstance(o, ConstList):
        sofar[o] = None
        return listFringe(o, fringe, path, sofar)

    if selfless in o.auditorStamps():
        if transparentStamp in o.auditorStamps():
            return samenessFringe(o.call(u"_uncall", []), path, fringe, sofar)
        # XXX Semitransparent support goes here

    if isResolved(o):
        return True

    # Welp, it's unsettled.
    if fringe is not None:
        fringe.append(FringeNode(o, path))
    return False
开发者ID:markrwilliams,项目名称:typhon,代码行数:48,代码来源:equality.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python currentVat.get函数代码示例发布时间:2022-05-27
下一篇:
Python equality.optSame函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap