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


Python atoms.getAtom函数代码示例

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


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


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