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

Python ootype.typeOf函数代码示例

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

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



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


示例16: test_new

def test_new():
    DT = Dict(Signed, Float)
    d = new(DT)
    assert typeOf(d) == DT
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:4,代码来源:test_oodict.py


示例17: new

def new(I):
    assert I.is_constant()
    i = ootype.new(I.const)
    r = SomeOOInstance(ootype.typeOf(i))
    return r
开发者ID:alkorzt,项目名称:pypy,代码行数:5,代码来源:builtin.py


示例18: is_inst

def is_inst(inst):
    return isinstance(ootype.typeOf(inst), (ootype.Instance, ootype.BuiltinType, ootype.StaticMethod))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:2,代码来源:ooopimpl.py


示例19: immutablevalue


#.........这里部分代码省略.........
                 if tp is r_dict:
                     s_eqfn = self.immutablevalue(x.key_eq)
                     s_hashfn = self.immutablevalue(x.key_hash)
                     result.dictdef.dictkey.update_rdict_annotations(s_eqfn,
                                                                     s_hashfn)
                 seen_elements = 0
                 while seen_elements != len(x):
                     items = x.items()
                     for ek, ev in items:
                         result.dictdef.generalize_key(self.immutablevalue(ek))
                         result.dictdef.generalize_value(self.immutablevalue(ev))
                         result.dictdef.seen_prebuilt_key(ek)
                     seen_elements = len(items)
                     # if the dictionary grew during the iteration,
                     # start over again
                 result.const_box = key
                 return result
         else:
             dictdef = DictDef(self, 
             s_ImpossibleValue,
             s_ImpossibleValue,
             is_r_dict = tp is r_dict)
             if tp is r_dict:
                 s_eqfn = self.immutablevalue(x.key_eq)
                 s_hashfn = self.immutablevalue(x.key_hash)
                 dictdef.dictkey.update_rdict_annotations(s_eqfn,
                     s_hashfn)
             for ek, ev in x.iteritems():
                 dictdef.generalize_key(self.immutablevalue(ek, False))
                 dictdef.generalize_value(self.immutablevalue(ev, False))
                 dictdef.seen_prebuilt_key(ek)
             result = SomeDict(dictdef)
     elif tp is weakref.ReferenceType:
         x1 = x()
         if x1 is None:
             result = SomeWeakRef(None)    # dead weakref
         else:
             s1 = self.immutablevalue(x1)
             assert isinstance(s1, SomeInstance)
             result = SomeWeakRef(s1.classdef)
     elif ishashable(x) and x in BUILTIN_ANALYZERS:
         _module = getattr(x,"__module__","unknown")
         result = SomeBuiltin(BUILTIN_ANALYZERS[x], methodname="%s.%s" % (_module, x.__name__))
     elif extregistry.is_registered(x, self.policy):
         entry = extregistry.lookup(x, self.policy)
         result = entry.compute_annotation_bk(self)
     elif isinstance(x, lltype._ptr):
         result = SomePtr(lltype.typeOf(x))
     elif isinstance(x, llmemory.fakeaddress):
         result = SomeAddress()
     elif isinstance(x, ootype._static_meth):
         result = SomeOOStaticMeth(ootype.typeOf(x))
     elif isinstance(x, ootype._class):
         result = SomeOOClass(x._INSTANCE)   # NB. can be None
     elif isinstance(x, ootype.instance_impl): # XXX
         result = SomeOOInstance(ootype.typeOf(x))
     elif isinstance(x, (ootype._record, ootype._string)):
         result = SomeOOInstance(ootype.typeOf(x))
     elif isinstance(x, (ootype._object)):
         result = SomeOOObject()
     elif callable(x):
         if hasattr(x, 'im_self') and hasattr(x, 'im_func'):
             # on top of PyPy, for cases like 'l.append' where 'l' is a
             # global constant list, the find_method() returns non-None
             s_self = self.immutablevalue(x.im_self, need_const)
             result = s_self.find_method(x.im_func.__name__)
         elif hasattr(x, '__self__') and x.__self__ is not None:
             # for cases like 'l.append' where 'l' is a global constant list
             s_self = self.immutablevalue(x.__self__, need_const)
             result = s_self.find_method(x.__name__)
             if result is None:
                 result = SomeObject()
         else:
             result = None
         if result is None:
             if (self.annotator.policy.allow_someobjects
                 and getattr(x, '__module__', None) == '__builtin__'
                 # XXX note that the print support functions are __builtin__
                 and tp not in (types.FunctionType, types.MethodType)):
                 result = SomeObject()
                 result.knowntype = tp # at least for types this needs to be correct
             else:
                 result = SomePBC([self.getdesc(x)])
     elif hasattr(x, '_freeze_') and x._freeze_():
         # user-defined classes can define a method _freeze_(), which
         # is called when a prebuilt instance is found.  If the method
         # returns True, the instance is considered immutable and becomes
         # a SomePBC().  Otherwise it's just SomeInstance().
         result = SomePBC([self.getdesc(x)])
     elif hasattr(x, '__class__') \
              and x.__class__.__module__ != '__builtin__':
         self.see_mutable(x)
         result = SomeInstance(self.getuniqueclassdef(x.__class__))
     elif x is None:
         return s_None
     else:
         result = SomeObject()
     if need_const:
         result.const = x
     return result
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:101,代码来源:bookkeeper.py


示例20: deref

 def deref(self, obj):
     assert isinstance(ootype.typeOf(obj), ootype.OOType)
     return obj
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:3,代码来源:typesystem.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python rclass.getclassrepr函数代码示例发布时间:2022-05-27
下一篇:
Python ootype.oostring函数代码示例发布时间: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