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

Python atoms.getAtom函数代码示例

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

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



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

示例1: call

    def call(self, verb, arguments, namedArgs=None, span=None):
        """
        Pass a message immediately to this object.

        This is the correct method to call if you have a verb.
        """

        arity = len(arguments)
        atom = getAtom(verb, arity)
        return self.callAtom(atom, arguments, namedArgs, span)
开发者ID:monte-language,项目名称:typhon,代码行数:10,代码来源:root.py


示例2: call

 def call(self, verb, arguments, namedArgs=None):
     """
     Pass a message immediately to this object.
     """
     from typhon.objects.collections.maps import EMPTY_MAP
     if namedArgs is None:
         namedArgs = EMPTY_MAP
     arity = len(arguments)
     atom = getAtom(verb, arity)
     return self.callAtom(atom, arguments, namedArgs)
开发者ID:markrwilliams,项目名称:typhon,代码行数:10,代码来源:root.py


示例3: visitMethodExpr

 def visitMethodExpr(self, doc, verb, patts, namedPatts, guard, body,
                     localSize, span):
     atom = getAtom(verb, len(patts))
     patts = [self.visitPatt(patt) for patt in patts]
     namedPatts = [self.visitNamedPatt(namedPatt) for namedPatt in
             namedPatts]
     guard = self.visitExpr(guard)
     body = self.visitExpr(body)
     return self.dest.MethodExpr(doc, atom, patts, namedPatts, guard, body,
                                 localSize, span)
开发者ID:monte-language,项目名称:typhon,代码行数:10,代码来源:structure.py


示例4: mirandaMethods

    def mirandaMethods(self, atom, arguments, namedArgsMap):
        from typhon.objects.collections.maps import EMPTY_MAP
        if atom is _CONFORMTO_1:
            # Welcome to _conformTo/1.
            # to _conformTo(_): return self
            return self

        if atom is _GETALLEGEDINTERFACE_0:
            # Welcome to _getAllegedInterface/0.
            interface = self.optInterface()
            if interface is None:
                from typhon.objects.interfaces import ComputedInterface
                interface = ComputedInterface(self)
            return interface

        if atom is _PRINTON_1:
            # Welcome to _printOn/1.
            from typhon.objects.constants import NullObject
            self.printOn(arguments[0])
            return NullObject

        if atom is _RESPONDSTO_2:
            from typhon.objects.constants import wrapBool
            from typhon.objects.data import unwrapInt, unwrapStr
            verb = unwrapStr(arguments[0])
            arity = unwrapInt(arguments[1])
            atom = getAtom(verb, arity)
            result = (atom in self.respondingAtoms() or
                      atom in mirandaAtoms)
            return wrapBool(result)

        if atom is _SEALEDDISPATCH_1:
            # to _sealedDispatch(_): return null
            from typhon.objects.constants import NullObject
            return NullObject

        if atom is _UNCALL_0:
            from typhon.objects.constants import NullObject
            return NullObject

        if atom is _WHENMORERESOLVED_1:
            # Welcome to _whenMoreResolved.
            # This method's implementation, in Monte, should be:
            # to _whenMoreResolved(callback): callback<-(self)
            from typhon.vats import currentVat
            vat = currentVat.get()
            vat.sendOnly(arguments[0], RUN_1, [self], EMPTY_MAP)
            from typhon.objects.constants import NullObject
            return NullObject
        return None
开发者ID:monte-language,项目名称:typhon,代码行数:50,代码来源:root.py


示例5: 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


示例6: send

    def send(self, target, verb, args, namedArgs):
        """
        Send a message to an object, returning a promise for the message
        delivery.

        The promise will be fulfilled after successful delivery, or smashed
        upon error.

        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()
        return vat.send(target, sendAtom, args, namedArgs)
开发者ID:dckc,项目名称:typhon,代码行数:18,代码来源:safe.py


示例7: inner

    def inner(f):
        name = f.__name__.decode("utf-8")
        doc = f.__doc__.decode("utf-8") if f.__doc__ else None

        if singleAtom is None:
            arity = len(inspect.getargspec(f).args)
            theAtom = getAtom(name, arity)
        else:
            arity = singleAtom.arity
            theAtom = singleAtom
        unrolledArity = unrolling_iterable(range(arity))

        class runnableObject(Object):

            def toString(self):
                return u"<%s>" % name

            def auditorStamps(self):
                from typhon.objects.collections.helpers import asSet
                return asSet(_stamps)

            def isSettled(self, sofar=None):
                return True

            def docString(self):
                return doc

            def respondingAtoms(self):
                return {theAtom: doc}

            def recv(self, atom, listArgs):
                if atom is theAtom:
                    args = ()
                    for i in unrolledArity:
                        args += (listArgs[i],)
                    return f(*args)
                else:
                    raise Refused(self, atom, listArgs)

        return runnableObject
开发者ID:monte-language,项目名称:typhon,代码行数:40,代码来源:root.py


示例8: alterMethods

def alterMethods(cls):
    """
    Alter Monte methods on behalf of AutoHelp.

    Return the signatures of the altered methods.

    NOT_RPYTHON
    """

    atoms = {}
    imports = set()
    execNames = {"Refused": Refused}

    def nextName(nameIndex=[0]):
        name = "_%d" % nameIndex[0]
        nameIndex[0] += 1
        return name

    def namedLiteral(lit):
        name = nextName()
        execNames[name] = lit
        return name

    dispatchClauses = []
    methods = harvestMethods(cls)
    for attr, (f, verb, args, kwargs, rv) in methods.iteritems():
        assignments = []
        if isStarArgs(args):
            atomTest = "atom.verb == %r" % verb
            call = "self.%s(args)" % attr
        else:
            atom = getAtom(verb, len(args))
            atomName = namedLiteral(atom)
            ds = f.__doc__
            if ds is not None:
                ds = ds.decode("utf-8")
            atoms[atom] = ds
            atomTest = "atom is %s" % atomName
            argNames = []
            for i, arg in enumerate(args):
                argName = nextName()
                argNames.append(argName)
                assignments.append("%s = args[%d]" % (argName, i))
                if arg != "Any":
                    unwrapperModule = wrappers[arg]
                    pred = "is" + arg
                    imports.add("from %s import %s" % (unwrapperModule, pred))
                    atomTest += " and %s(args[%d])" % (pred, i)
                    unwrapper = "unwrap" + arg
                    imports.add("from %s import %s" % (unwrapperModule,
                        unwrapper))
                    assignments.append("%s = %s(%s)" % (argName, unwrapper,
                        argName))
                else:
                    imports.add("from typhon.objects.refs import resolution")
                    assignments.append("%s = resolution(%s)" % (argName,
                                                                argName))
            for k, v in kwargs.iteritems():
                # Look up the default value. We're going to pop this in and
                # use None as a sentinel value in .extractStringKey(). ~ C.
                default = getKwargDefault(f, k)
                defaultName = namedLiteral(default)
                kwargName = nextName()
                argNames.append("%s=%s" % (k, kwargName))
                assignments.append("%s = namedArgs.extractStringKey(%r, None)"
                        % (kwargName, k.decode("utf-8")))
                # If the kwarg is None, then it wasn't passed in; use the
                # default. Otherwise, invoke the unwrapper if one exists.
                assignments.append("if %s is None: %s = %s"
                        % (kwargName, kwargName, defaultName))
                if v != "Any":
                    unwrapperModule = wrappers[v]
                    unwrapper = "unwrap" + v
                    imports.add("from %s import %s"
                            % (unwrapperModule, unwrapper))
                    assignments.append("else: %s = %s(%s)"
                            % (kwargName, unwrapper, kwargName))
            call = "self.%s(%s)" % (attr, ",".join(argNames))
        retvals = []
        if rv == "Any":
            # No wrapping.
            retvals.append("return rv")
        elif rv == "Void":
            # Enforced correctness. Disobedience will not be tolerated.
            retvals.append("assert rv is None, 'habanero'")
            retvals.append("from typhon.objects.constants import NullObject")
            retvals.append("return NullObject")
        else:
            wrapperModule = wrappers[rv]
            wrapper = "wrap" + rv
            imports.add("from %s import %s" % (wrapperModule, wrapper))
            retvals.append("return %s(rv)" % wrapper)
        # We need to use newlines for the assignments since kwarg assignments
        # are conditional.
        dispatchClauses.append("""
 if %s:
  %s
  rv = %s
  %s
""" % (atomTest, "\n  ".join(assignments), call, ";".join(retvals)))
#.........这里部分代码省略.........
开发者ID:monte-language,项目名称:typhon,代码行数:101,代码来源:autohelp.py


示例9: import

from typhon import ruv
from typhon.atoms import getAtom
from typhon.autohelp import autohelp, method
from typhon.objects.files import FileFount, FileDrain
from typhon.objects.networking.streams import StreamDrain, StreamFount
from typhon.objects.networking.streamcaps import (FileSink, FileSource,
                                                  StreamSink, StreamSource)
from typhon.objects.root import Object, runnable
from typhon.vats import currentVat


RUN_0 = getAtom(u"run", 0)


@runnable(RUN_0)
def makeStdIn():
    vat = currentVat.get()
    uv_loop = vat.uv_loop
    stdinKind = ruv.guess_handle(0)
    if stdinKind == ruv.HANDLE_TTY:
        stdin = ruv.alloc_tty(uv_loop, 0, True)
        return StreamFount(ruv.rffi.cast(ruv.stream_tp, stdin), vat)
    else:
        return FileFount(ruv.alloc_fs(), 0, vat)


@runnable(RUN_0)
def makeStdOut():
    vat = currentVat.get()
    uv_loop = vat.uv_loop
    stdoutKind = ruv.guess_handle(1)
开发者ID:dckc,项目名称:typhon,代码行数:31,代码来源:stdio.py


示例10: import

from rpython.rtyper.lltypesystem.lltype import nullptr
from rpython.rtyper.lltypesystem.rffi import getintfield

from typhon import ruv
from typhon.atoms import getAtom
from typhon.autohelp import autohelp
from typhon.errors import Refused
from typhon.objects.collections.lists import ConstList
from typhon.objects.data import (bytesToString, unwrapBytes, BytesObject,
                                 StrObject)
from typhon.objects.refs import LocalResolver, makePromise
from typhon.objects.root import Object, runnable
from typhon.vats import currentVat, scopedVat


GETADDRESS_0 = getAtom(u"getAddress", 0)
GETFAMILY_0 = getAtom(u"getFamily", 0)
GETSOCKETTYPE_0 = getAtom(u"getSocketType", 0)
RUN_2 = getAtom(u"run", 2)


socktypes = {
    s.SOCK_DGRAM: u"datagram",
    s.SOCK_RAW: u"raw",
    s.SOCK_RDM: u"reliable datagram",
    s.SOCK_SEQPACKET: u"packet",
    s.SOCK_STREAM: u"stream",
}


class AddrInfo(Object):
开发者ID:markrwilliams,项目名称:typhon,代码行数:31,代码来源:dns.py


示例11: getAtom

from typhon.errors import Ejecting, Refused, UserException, userError
from typhon.log import log
from typhon.objects.auditors import deepFrozenStamp
from typhon.objects.constants import NullObject, unwrapBool, wrapBool
from typhon.objects.collections.lists import ConstList
from typhon.objects.data import StrObject, unwrapStr
from typhon.objects.ejectors import Ejector
from typhon.objects.guards import anyGuard
from typhon.objects.printers import Printer
from typhon.objects.root import Object
from typhon.objects.slots import finalBinding
from typhon.smallcaps.machine import SmallCaps

# XXX AuditionStamp, Audition guard

ASK_1 = getAtom(u"ask", 1)
GETGUARD_1 = getAtom(u"getGuard", 1)
GETOBJECTEXPR_0 = getAtom(u"getObjectExpr", 0)
GETFQN_0 = getAtom(u"getFQN", 0)


pemci = u".".join([
    u"lo lebna cu rivbi",
    u"lo nu fi ri facki",
    u"fa le vi larmuzga",
    u"fe le zi ca du'u",
    u"le lebna pu jbera",
    u"lo catlu pe ro da",
])

def boolStr(b):
开发者ID:markrwilliams,项目名称:typhon,代码行数:31,代码来源:user.py


示例12: getAtom

 def getAtom(self):
     return getAtom(self._verb, len(self._ps))
开发者ID:dckc,项目名称:typhon,代码行数:2,代码来源:nodes.py


示例13: Copyright

# Copyright (C) 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from typhon.atoms import getAtom
from typhon.objects.data import StrObject
from typhon.objects.root import runnable

GETFQNPREFIX_0 = getAtom(u"getFQNPrefix", 0)

@runnable(GETFQNPREFIX_0)
def MetaContext():
    """
    Obtain the fully qualified name prefix.
    """

    return StrObject(u"unknown$monte$source$")
开发者ID:markrwilliams,项目名称:typhon,代码行数:27,代码来源:meta.py


示例14: testIdempotency

 def testIdempotency(self):
     first = getAtom(u"test", 5)
     second = getAtom(u"test", 5)
     self.assertTrue(first is second)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_atom.py


示例15: getAtom

from typhon.atoms import getAtom
from typhon.autohelp import autohelp
from typhon.objects.auditors import deepFrozenStamp
from typhon.objects.collections.lists import wrapList
from typhon.objects.data import StrObject
from typhon.objects.ejectors import throwStr
from typhon.objects.root import Object, runnable


RUN_2 = getAtom(u"run", 2)


def sealException(ue):
    val = ue.getPayload()
    trail = ue.trail
    if isinstance(val, SealedException):
        return val
    return SealedException(val, trail)


@autohelp
class SealedException(Object):
    """
    An exception.

    Sealed within this object are the details of an exceptional occurrence.
    """

    def __init__(self, value, trail):
        self.value = value
        self.trail = trail
开发者ID:dckc,项目名称:typhon,代码行数:31,代码来源:exceptions.py


示例16: getAtom

from typhon.atoms import getAtom
from typhon.autohelp import autohelp
from typhon.errors import Refused
from typhon.objects.constants import NullObject
from typhon.objects.collections.sets import ConstSet, monteSet
from typhon.objects.data import IntObject, StrObject
from typhon.objects.root import Object


GETARITY_0 = getAtom(u"getArity", 0)
GETDOCSTRING_0 = getAtom(u"getDocstring", 0)
GETMETHODS_0 = getAtom(u"getMethods", 0)
GETVERB_0 = getAtom(u"getVerb", 0)


@autohelp
class ComputedMethod(Object):
    """
    A method description.
    """

    _immutable_ = True

    def __init__(self, arity, docstring, verb):
        self.arity = arity
        self.docstring = docstring
        self.verb = verb

    def toString(self):
        return u"<computed message %s/%d>" % (self.verb, self.arity)
开发者ID:markrwilliams,项目名称:typhon,代码行数:30,代码来源:interfaces.py


示例17: import

from rpython.rlib.rstring import ParseStringError
from rpython.rlib.rstruct.ieee import unpack_float

from typhon.atoms import getAtom
from typhon.autohelp import autohelp, method
from typhon.objects.auditors import deepFrozenStamp
from typhon.objects.collections.lists import listFromIterable
from typhon.objects.collections.maps import ConstMap
from typhon.objects.data import (bytesToString, unwrapInt,
        unwrapChar)
from typhon.objects.ejectors import throwStr
from typhon.objects.root import Object, audited, runnable
from typhon.profile import profileTyphon


FROMPAIRS_1 = getAtom(u"fromPairs", 1)


@autohelp
@audited.DF
class MakeBytes(Object):
    """
    The maker of `Bytes`.
    """

    def toString(self):
        return u"<makeBytes>"

    @method("Bytes", "Str")
    def fromStr(self, s):
        return "".join([chr(ord(c)) for c in s])
开发者ID:dckc,项目名称:typhon,代码行数:31,代码来源:makers.py


示例18: getAtom

# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from rpython.rlib.jit import promote, unroll_safe
from rpython.rlib.objectmodel import always_inline

from typhon.atoms import getAtom
from typhon.objects.auditors import deepFrozenGuard, deepFrozenStamp
from typhon.objects.data import StrObject
from typhon.objects.guards import anyGuard
from typhon.objects.slots import Binding, finalBinding, VarSlot


GET_0 = getAtom(u"get", 0)
PUT_1 = getAtom(u"put", 1)


@always_inline
def bindingToSlot(binding):
    if isinstance(binding, Binding):
        return binding.get()
    from typhon.objects.collections.maps import EMPTY_MAP
    return binding.callAtom(GET_0, [], EMPTY_MAP)


@always_inline
def bindingToValue(binding):
    from typhon.objects.collections.maps import EMPTY_MAP
    if isinstance(binding, Binding):
开发者ID:washort,项目名称:typhon,代码行数:31,代码来源:env.py


示例19: visitCallExpr

 def visitCallExpr(self, obj, verb, args, namedArgs, span):
     obj = self.visitExpr(obj)
     atom = getAtom(verb, len(args))
     args = [self.visitExpr(arg) for arg in args]
     namedArgs = [self.visitNamedArg(namedArg) for namedArg in namedArgs]
     return self.dest.CallExpr(obj, atom, args, namedArgs, span)
开发者ID:monte-language,项目名称:typhon,代码行数:6,代码来源:structure.py


示例20: getAtom

# under the License.

import inspect

from rpython.rlib import rgc
from rpython.rlib.unroll import unrolling_iterable
from rpython.rlib.jit import jit_debug, promote, unroll_safe
from rpython.rlib.objectmodel import compute_identity_hash, specialize
from rpython.rlib.rstackovf import StackOverflow, check_stack_overflow

from typhon.atoms import getAtom
from typhon.errors import Refused, UserException, userError
from typhon.profile import profileTyphon


RUN_1 = getAtom(u"run", 1)
_CONFORMTO_1 = getAtom(u"_conformTo", 1)
_GETALLEGEDINTERFACE_0 = getAtom(u"_getAllegedInterface", 0)
_PRINTON_1 = getAtom(u"_printOn", 1)
_RESPONDSTO_2 = getAtom(u"_respondsTo", 2)
_SEALEDDISPATCH_1 = getAtom(u"_sealedDispatch", 1)
_UNCALL_0 = getAtom(u"_uncall", 0)
_WHENMORERESOLVED_1 = getAtom(u"_whenMoreResolved", 1)


def makeMirandaArgs():
    from typhon.objects.collections.maps import monteMap
    from typhon.objects.data import StrObject
    from typhon.objects.ejectors import theThrower

    # XXX monteMap()
开发者ID:monte-language,项目名称:typhon,代码行数:31,代码来源:root.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python errors.userError函数代码示例发布时间:2022-05-27
下一篇:
Python types.SimpleNamespace类代码示例发布时间: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