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

Python ootype.cast_to_object函数代码示例

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

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



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

示例1: fn_null

 def fn_null():
     a = ootype.null(A)
     b = ootype.null(B)
     obj1 = ootype.cast_to_object(a)
     obj2 = ootype.cast_to_object(b)
     assert obj1 == obj2
     assert ootype.cast_from_object(A, obj1) == a
     assert ootype.cast_from_object(B, obj2) == b
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_rclass.py


示例2: get_exception

 def get_exception(self):
     exc_value = self.get_inputargs().get_exc_value()
     if exc_value:
         exc_obj = dotnet.cast_from_native_object(exc_value)
         exc_inst = ootype.cast_from_object(ootype.ROOT, exc_obj)
         cls = ootype.classof(exc_value)
         return ootype.cast_to_object(cls)
     return ootype.cast_to_object(ootype.nullruntimeclass)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:runner.py


示例3: test_unwrap_object

 def test_unwrap_object(self):
     A = ootype.Instance("A", ootype.ROOT, {})
     a1 = ootype.new(A)
     a2 = ootype.new(A)
     obj1 = ootype.cast_to_object(a1)
     obj2 = ootype.cast_to_object(a2)
     def fn(flag):
         if flag:
             obj = obj1
         else:
             obj = obj2
         a3 = ootype.cast_from_object(A, obj)
         return a3 is a1
     res = self.interpret(fn, [True], backendopt=False)
     assert res is True
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:15,代码来源:constant.py


示例4: wrap

def wrap(cpu, value, in_const_box=False):
    if isinstance(lltype.typeOf(value), lltype.Ptr):
        if lltype.typeOf(value).TO._gckind == 'gc':
            value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
            if in_const_box:
                return history.ConstPtr(value)
            else:
                return history.BoxPtr(value)
        else:
            adr = llmemory.cast_ptr_to_adr(value)
            value = cpu.cast_adr_to_int(adr)
            # fall through to the end of the function
    elif isinstance(lltype.typeOf(value), ootype.OOType):
        value = ootype.cast_to_object(value)
        if in_const_box:
            return history.ConstObj(value)
        else:
            return history.BoxObj(value)
    elif isinstance(value, float):
        if in_const_box:
            return history.ConstFloat(value)
        else:
            return history.BoxFloat(value)
    else:
        value = intmask(value)
    if in_const_box:
        return history.ConstInt(value)
    else:
        return history.BoxInt(value)
开发者ID:enyst,项目名称:plexnet,代码行数:29,代码来源:warmstate.py


示例5: fn_mix_null

 def fn_mix_null(flag):
     a = ootype.new(A)
     obj = ootype.cast_to_object(a)
     if flag:
         return obj
     else:
         return ootype.NULL
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_rclass.py


示例6: boxresult

def boxresult(RESULT, result):
    if isinstance(RESULT, ootype.OOType):
        return history.BoxObj(ootype.cast_to_object(result))
    elif RESULT is lltype.Float:
        return history.BoxFloat(result)
    else:
        return history.BoxInt(lltype.cast_primitive(ootype.Signed, result))
开发者ID:ieure,项目名称:pypy,代码行数:7,代码来源:runner.py


示例7: fn_is_true

 def fn_is_true(flag):
     if flag:
         a = ootype.new(A)
     else:
         a = ootype.null(A)
     obj = ootype.cast_to_object(a)
     return bool(obj)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_rclass.py


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


示例9: fn_record

 def fn_record():
     b = ootype.new(B)
     b.x = 42
     obj = ootype.cast_to_object(b)
     b2 = ootype.cast_from_object(B, obj)
     assert b2.x == 42
     assert b is b2
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_rclass.py


示例10: fn_instance

 def fn_instance():
     a = ootype.new(A)
     obj = ootype.cast_to_object(a)
     a2 = ootype.cast_from_object(A, obj)
     a3 = ootype.cast_from_object(ootype.ROOT, obj)
     assert a is a2
     assert a is a3
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_rclass.py


示例11: wrap

def wrap(cpu, value, in_const_box=False):
    if isinstance(lltype.typeOf(value), lltype.Ptr):
        if lltype.typeOf(value).TO._gckind == 'gc':
            value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
            if in_const_box:
                return history.ConstPtr(value)
            else:
                return history.BoxPtr(value)
        else:
            adr = llmemory.cast_ptr_to_adr(value)
            value = heaptracker.adr2int(adr)
            # fall through to the end of the function
    elif isinstance(lltype.typeOf(value), ootype.OOType):
        value = ootype.cast_to_object(value)
        if in_const_box:
            return history.ConstObj(value)
        else:
            return history.BoxObj(value)
    elif isinstance(value, float):
        value = longlong.getfloatstorage(value)
        if in_const_box:
            return history.ConstFloat(value)
        else:
            return history.BoxFloat(value)
    elif isinstance(value, str) or isinstance(value, unicode):
        assert len(value) == 1     # must be a character
        value = ord(value)
    else:
        value = intmask(value)
    if in_const_box:
        return history.ConstInt(value)
    else:
        return history.BoxInt(value)
开发者ID:ieure,项目名称:pypy,代码行数:33,代码来源:warmstate.py


示例12: test_convert_string_to_object

 def test_convert_string_to_object(self):
     s = self.string_to_ll("hello world")
     obj = ootype.cast_to_object(s)
     def fn():
         s1 = ootype.cast_from_object(ootype.String, obj)
         return s1
     res = self.interpret(fn, [], backendopt=False)
     assert res == 'hello world'
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:constant.py


示例13: fn

 def fn():
     a = ootype.new(A)
     ahash = ootype.identityhash(a)
     obj = ootype.cast_to_object(a)
     native = cast_to_native_object(obj)
     name = native.GetType().get_Name()
     obj2 = cast_from_native_object(native)
     a2 = ootype.cast_from_object(A, obj2)
     a2hash = ootype.identityhash(a2)
     return name, ahash == a2hash
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:10,代码来源:test_dotnet.py


示例14: __init__

 def __init__(self, cpu, cliloop):
     self.setoptions()
     self.cpu = cpu
     self.name = cliloop.get_fresh_cli_name()
     self.cliloop = cliloop
     self.boxes = {}       # box --> local var
     self.branches = []
     self.branchlabels = []
     self.consts = {}      # object --> index
     self.meth_wrapper = self._get_meth_wrapper()
     self.il = self.meth_wrapper.get_il_generator()
     self.av_consts = MethodArgument(0, System.Type.GetType("System.Object[]"))
     t_InputArgs = dotnet.typeof(InputArgs)
     self.av_inputargs = MethodArgument(1,t_InputArgs )
     self.av_ovf_flag = BoxInt()
     self.exc_value_field = t_InputArgs.GetField('exc_value')
     if cpu.rtyper:
         self.av_OverflowError = ConstObj(ootype.cast_to_object(cpu.ll_ovf_exc))
         self.av_ZeroDivisionError = ConstObj(ootype.cast_to_object(cpu.ll_zero_exc))
     else:
         self.av_OverflowError = None
         self.av_ZeroDivisionError = None
     self.box2type = {}
开发者ID:alkorzt,项目名称:pypy,代码行数:23,代码来源:method.py


示例15: get_const

 def get_const(self, name, typ):
     if self._consts is None:
         return name
     obj = self._consts[name]
     if self.type_system == 'lltype':
         if typ == 'ptr':
             return ConstPtr(obj)
         else:
             assert typ == 'class'
             return ConstAddr(llmemory.cast_ptr_to_adr(obj),
                              self.cpu)
     else:
         if typ == 'ptr':
             return ConstObj(obj)
         else:
             assert typ == 'class'
             return ConstObj(ootype.cast_to_object(obj))
开发者ID:enyst,项目名称:plexnet,代码行数:17,代码来源:oparser.py


示例16: do_runtimenew

 def do_runtimenew(self, classbox):
     classobj = classbox.getref(ootype.Class)
     res = ootype.runtimenew(classobj)
     return BoxObj(ootype.cast_to_object(res))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:runner.py


示例17: get_overflow_error

 def get_overflow_error(self):
     exc_type = ootype.cast_to_object(ootype.classof(self.ll_ovf_exc))
     exc_value = ootype.cast_to_object(self.ll_ovf_exc)
     return exc_type, exc_value
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:runner.py


示例18: constclass

 def constclass(cls_vtable):
     if self.type_system == 'lltype':
         return ConstAddr(llmemory.cast_ptr_to_adr(cls_vtable),
                          self.cpu)
     else:
         return ConstObj(ootype.cast_to_object(cls_vtable))
开发者ID:alkorzt,项目名称:pypy,代码行数:6,代码来源:test_optimizefindnode.py


示例19: set_overflow_error

 def set_overflow_error(self):
     exc_obj = ootype.cast_to_object(self.ll_ovf_exc)
     exc_value = dotnet.cast_to_native_object(exc_obj)
     self.get_inputargs().set_exc_value(exc_value)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:runner.py


示例20: typedescr2classbox

 def typedescr2classbox(self, descr):
     assert isinstance(descr, TypeDescr)
     return ConstObj(ootype.cast_to_object(descr.ooclass))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:3,代码来源:runner.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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