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


Python ootype.typeOf函数代码示例

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


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

示例1: test_oounicode

def test_oounicode():
    u = ootype.oounicode(u'a', -1)
    assert isinstance(u, ootype._string)
    assert ootype.typeOf(u) is ootype.Unicode

    s = ootype.make_string('a string')
    u = ootype.oounicode(s, -1)
    assert isinstance(u, ootype._string)
    assert ootype.typeOf(u) is ootype.Unicode

    s = ootype.make_string('non-ascii string: \xe0')
    py.test.raises(UnicodeDecodeError, ootype.oounicode, s, -1)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:12,代码来源:test_oostring.py

示例2: constant

 def constant(value):
     if isinstance(lltype.typeOf(value), lltype.Ptr):
         return ConstPtr(value)
     elif isinstance(ootype.typeOf(value), ootype.OOType):
         return ConstObj(ootype.cast_to_object(value))
     else:
         return ConstInt(value)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_optimizefindnode.py

示例3: ll_tuplenext

def ll_tuplenext(iter):
    # for iterating over length 1 tuples only!
    t = iter.iterable
    if t:
        iter.iterable = ootype.null(ootype.typeOf(t))
        return t.item0
    else:
        raise StopIteration
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:rtuple.py

示例4: get_primitive_constant

def get_primitive_constant(TYPE, value):
    if is_primitive(TYPE):
        return TYPE, value
    if TYPE is ootype.Object:
        obj = value.obj
        T2 = ootype.typeOf(obj)
        if obj is not None and is_primitive(T2):
            return T2, obj
    return None, None
开发者ID:enyst,项目名称:plexnet,代码行数:9,代码来源:constant.py

示例5: static_meth_to_signature

 def static_meth_to_signature(self, sm):
     from pypy.translator.oosupport import metavm
     graph = getattr(sm, 'graph', None)
     if graph:
         return self.graph_to_signature(graph)
     module, name = metavm.get_primitive_name(sm)
     func_name = '[pypylib]pypy.builtin.%s::%s' % (module, name)
     T = ootype.typeOf(sm)
     return self.format_signatue(func_name, T.ARGS, T.RESULT)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:cts.py

示例6: __init__

 def __init__(self, rtyper, methdescs):
     samplemdesc = methdescs.iterkeys().next()
     concretetable, uniquerows = get_concrete_calltable(rtyper, samplemdesc.funcdesc.getcallfamily())
     self.row_mapping = {}
     for row in uniquerows:
         sample_as_static_meth = row.itervalues().next()
         SM = ootype.typeOf(sample_as_static_meth)
         M = ootype.Meth(SM.ARGS[1:], SM.RESULT)  # cut self
         self.row_mapping[row.attrname] = row, M
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:rpbc.py

示例7: genconst

 def genconst(self, llvalue):
     T = ootype.typeOf(llvalue)
     if T is ootype.Signed:
         return IntConst(llvalue)
     elif T is ootype.Bool:
         return IntConst(int(llvalue))
     elif isinstance(T, ootype.OOType):
         return ObjectConst(box(llvalue))
     else:
         assert False, "XXX not implemented"
开发者ID:antoine1fr,项目名称:pygirl,代码行数:10,代码来源:rgenop.py

示例8: attach_class_attr_accessor

    def attach_class_attr_accessor(self, mangled, oovalue):
        def ll_getclassattr(self):
            return oovalue

        M = ootype.Meth([], ootype.typeOf(oovalue))
        ll_getclassattr = func_with_new_name(ll_getclassattr,
                                             'll_get_' + mangled)
        graph = self.rtyper.annotate_helper(ll_getclassattr, [self.lowleveltype])
        m = ootype.meth(M, _name=mangled, _callable=ll_getclassattr,
                        graph=graph)
        ootype.addMethods(self.lowleveltype, {mangled: m})
开发者ID:alkorzt,项目名称:pypy,代码行数:11,代码来源:rclass.py

示例9: clrepr

def clrepr(item, symbol=False):
    """ This is the main repr function and is the only one that should be
    used to represent python values in lisp.
    """
    if item is None:
        return "nil"

    fun = bltn_dispatch.get(type(item), None)
    if fun is not None:
        return fun(item, symbol)

    if typeOf(item) is Class:
        return "'" + item._INSTANCE._name
    return repr_unknown(item)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:clrepr.py

示例10: _dont_store

    def _dont_store(self, to_load, to_store):
        # ugly workaround to make the exceptiontransformer work with
        # valuetypes: when exceptiontransforming a function whose result is a
        # .NET valuetype, it tries to store a null into the return variable.
        # Since it is not possible to store a null into a valuetype, and that
        # in that case the value is not used anyway, we simply ignore it.
        from pypy.translator.cli.dotnet import NativeInstance

        if isinstance(to_load, flowmodel.Constant):
            value = to_load.value
            is_null = (not isinstance(value, CDefinedIntSymbolic)) and (not value)
            T = ootype.typeOf(to_load.value)
            if isinstance(T, NativeInstance) and T._is_value_type and is_null:
                return True
        return OOFunction._dont_store(self, to_load, to_store)
开发者ID:alkorzt,项目名称:pypy,代码行数:15,代码来源:function.py

示例11: __init__

 def __init__(self, SELFTYPE, methname):
     _, meth = SELFTYPE._lookup(methname)
     METH = ootype.typeOf(meth)
     self.SELFTYPE = SELFTYPE
     self.METH = METH
     self.methname = methname
     RESULT = METH.RESULT
     getargs = make_getargs(METH.ARGS)
     def callmeth(selfbox, argboxes):
         selfobj = selfbox.getref(SELFTYPE)
         meth = getattr(selfobj, methname)
         methargs = getargs(argboxes)
         res = llimpl.call_maybe_on_top_of_llinterp(meth, methargs)
         if RESULT is not ootype.Void:
             return boxresult(RESULT, res)
     self.callmeth = callmeth
开发者ID:ieure,项目名称:pypy,代码行数:16,代码来源:runner.py

示例12: __init__

 def __init__(self, SELFTYPE, methname):
     from pypy.jit.backend.llgraph.runner import boxresult, make_getargs
     _, meth = SELFTYPE._lookup(methname)
     METH = ootype.typeOf(meth)
     getargs = make_getargs(METH.ARGS)
     def callmeth(selfbox, argboxes):
         selfobj = selfbox.getref(SELFTYPE)
         meth = getattr(selfobj, methname)
         methargs = getargs(argboxes)
         res = meth(*methargs)
         if METH.RESULT is not ootype.Void:
             return boxresult(METH.RESULT, res)
     self.callmeth = callmeth
     self.selfclass = ootype.runtimeClass(SELFTYPE)
     self.methname = methname
     self.has_result = (METH.RESULT != ootype.Void)
     self.key = key_manager.getkey((SELFTYPE, methname))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:17,代码来源:runner.py

示例13: is_inst

def is_inst(inst):
    T = ootype.typeOf(inst)
    return T is ootype.Object or T is ootype.Class or\
        isinstance(T, (ootype.Instance,
                       ootype.BuiltinType,
                       ootype.StaticMethod,))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:6,代码来源:ooopimpl.py

示例14: test_simple_empty_base

def test_simple_empty_base():
    def dummyfn():
        x = EmptyBase()
        return x
    result = interpret(dummyfn, [])
    assert isinstance(ootype.typeOf(result), ootype.Instance)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:6,代码来源:test_ooclean.py

示例15: render

 def render(self, generator, op):
     generator.load(Constant(self.value, ootype.typeOf(self.value)))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:2,代码来源:metavm.py


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