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

Python annlowlevel.cast_base_ptr_to_instance函数代码示例

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

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



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

示例1: reraise

def reraise(lle):
    if we_are_translated():
        e = cast_base_ptr_to_instance(Exception, lle)
        raise e
    else:
        etype = rclass.ll_type(lle)
        raise LLException(etype, lle)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:jitexc.py


示例2: set_field_touched

 def set_field_touched(struc, value):
     T = fielddesc.RESTYPE
     if fielddesc.canbevirtual and fielddesc.gcref:
         vable_rti = struc.vable_rti
         vable_rti = cast_base_ptr_to_instance(VirtualizableRTI, vable_rti)
         vable_rti.touched_ptr_field(struc.vable_base, j)
     struc = lltype.cast_pointer(fielddesc.PTRTYPE, struc)
     setattr(struc, fielddesc.fieldname, value)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:rvirtualizable.py


示例3: test_cast_instance_to_base_ptr

 def test_cast_instance_to_base_ptr(self):
     class X(object):
         pass
     x = X()
     ptr = annlowlevel.cast_instance_to_base_ptr(x)
     assert lltype.typeOf(ptr) == annlowlevel.base_ptr_lltype()
     y = annlowlevel.cast_base_ptr_to_instance(X, ptr)
     assert y is x
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_annlowlevel.py


示例4: f

 def f():
     s = T()
     ls = cast_instance_to_base_ptr(s)
     as_num = rffi.cast(lltype.Signed, ls)
     # --- around this point, only 'as_num' is passed
     t = rffi.cast(rclass.OBJECTPTR, as_num)
     u = cast_base_ptr_to_instance(S, t)
     return u.x
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_ll2ctypes.py


示例5: test_cast_instance_to_base_obj

 def test_cast_instance_to_base_obj(self):
     class X(object):
         pass
     x = X()
     obj = annlowlevel.cast_instance_to_base_obj(x)
     assert lltype.typeOf(obj) == annlowlevel.base_obj_ootype()
     y = annlowlevel.cast_base_ptr_to_instance(X, obj)
     assert y is x
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_annlowlevel.py


示例6: f

 def f(x, y):
     if x > 20:
         a = None
     else:
         a = A(x, y)
     a1 = cast_instance_to_base_ptr(a)
     b = cast_base_ptr_to_instance(A, a1)
     return a is b
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:test_llann.py


示例7: debug_merge_point_from_boxes

def debug_merge_point_from_boxes(boxes):
    mp_no = boxes[0].getint()
    offset = boxes[2].getint()
    llcode = lltype.cast_opaque_ptr(lltype.Ptr(OBJECT),
                                    boxes[4].getref_base())
    pycode = cast_base_ptr_to_instance(PyCode, llcode)
    assert pycode is not None
    return W_DebugMergePoint(mp_no, offset, pycode)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:8,代码来源:interp_resop.py


示例8: get_field_touched

 def get_field_touched(struc):
     T = fielddesc.RESTYPE
     tgt = lltype.cast_pointer(fielddesc.PTRTYPE, struc)
     if fielddesc.canbevirtual and fielddesc.gcref:
         vable_rti = struc.vable_rti
         vable_rti = cast_base_ptr_to_instance(VirtualizableRTI, vable_rti)
         vable_base = struc.vable_base
         if vable_rti.is_field_virtual(vable_base, j):
             # this will force
             s = vable_rti.read_field(fielddesc, vable_base, j)
             setattr(tgt, fielddesc.fieldname, s)
             return s
     return getattr(tgt, fielddesc.fieldname)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:13,代码来源:rvirtualizable.py


示例9: wrap_greenkey

def wrap_greenkey(space, jitdriver, greenkey, greenkey_repr):
    if greenkey is None:
        return space.w_None
    jitdriver_name = jitdriver.name
    if jitdriver_name == 'pypyjit':
        next_instr = greenkey[0].getint()
        is_being_profiled = greenkey[1].getint()
        ll_code = lltype.cast_opaque_ptr(lltype.Ptr(OBJECT),
                                         greenkey[2].getref_base())
        pycode = cast_base_ptr_to_instance(PyCode, ll_code)
        return space.newtuple([space.wrap(pycode), space.wrap(next_instr),
                               space.newbool(bool(is_being_profiled))])
    else:
        return space.wrap(greenkey_repr)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:14,代码来源:interp_resop.py


示例10: touch_update

    def touch_update(strucref):
        struc = lltype.cast_opaque_ptr(TOPPTR, strucref)
        vable_rti = struc.vable_rti
        vable_rti = cast_base_ptr_to_instance(VirtualizableRTI, vable_rti)
        vable_rti.touch(struc.vable_base)
        vable_base = struc.vable_base

        j = -1
        for fielddesc, _ in redirected_fielddescs:
            j += 1
            if fielddesc.canbevirtual and fielddesc.gcref:
                if vable_rti.is_field_virtual(vable_base, j):
                    continue
            v = vable_rti.read_field(fielddesc, vable_base, j)
            tgt = lltype.cast_pointer(fielddesc.PTRTYPE, struc)            
            setattr(tgt, fielddesc.fieldname, v)
        ACCESSPTR = TOPPTR.TO.vable_access
        struc.vable_access = lltype.cast_pointer(ACCESSPTR, access_touched)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:18,代码来源:rvirtualizable.py


示例11: try_cast_gcref_to_instance

def try_cast_gcref_to_instance(Class, gcref):
    # Before translation, unwraps the RPython instance contained in a _GcRef.
    # After translation, it is a type-check performed by the GC.
    if we_are_translated():
        from pypy.rpython.annlowlevel import base_ptr_lltype
        from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
        from pypy.rpython.lltypesystem import rclass
        if _is_rpy_instance(gcref):
            objptr = lltype.cast_opaque_ptr(base_ptr_lltype(), gcref)
            if objptr.typeptr:   # may be NULL, e.g. in rdict's dummykeyobj
                clsptr = _get_llcls_from_cls(Class)
                if rclass.ll_isinstance(objptr, clsptr):
                    return cast_base_ptr_to_instance(Class, objptr)
        return None
    else:
        if isinstance(gcref._x, Class):
            return gcref._x
        return None
开发者ID:ieure,项目名称:pypy,代码行数:18,代码来源:rgc.py


示例12: _get_signature

    def _get_signature(self, funcval):
        """
        given the funcval, return a tuple (argtypes, restype), where the
        actuall types are libffi.types.*

        The implementation is tricky because we have three possible cases:

        - translated: the easiest case, we can just cast back the pointer to
          the original Func instance and read .argtypes and .restype

        - completely untranslated: this is what we get from test_optimizeopt
          tests. funcval contains a FakeLLObject whose _fake_class is Func,
          and we can just get .argtypes and .restype

        - partially translated: this happens when running metainterp tests:
          funcval contains the low-level equivalent of a Func, and thus we
          have to fish inst_argtypes and inst_restype by hand.  Note that
          inst_argtypes is actually a low-level array, but we can use it
          directly since the only thing we do with it is to read its items
        """
        
        llfunc = funcval.box.getref_base()
        if we_are_translated():
            func = cast_base_ptr_to_instance(Func, llfunc)
            return func.argtypes, func.restype
        elif getattr(llfunc, '_fake_class', None) is Func:
            # untranslated
            return llfunc.argtypes, llfunc.restype
        else:
            # partially translated
            # llfunc contains an opaque pointer to something like the following:
            # <GcStruct pypy.rlib.libffi.Func { super, inst_argtypes, inst_funcptr,
            #                                   inst_funcsym, inst_restype }>
            #
            # Unfortunately, we cannot use the proper lltype.cast_opaque_ptr,
            # because we don't have the exact TYPE to cast to.  Instead, we
            # just fish it manually :-(
            f = llfunc._obj.container
            return f.inst_argtypes, f.inst_restype
开发者ID:ieure,项目名称:pypy,代码行数:39,代码来源:fficall.py


示例13: get_location_str

 def get_location_str(boxes):
     ll_code = lltype.cast_opaque_ptr(lltype.Ptr(OBJECT),
                                      boxes[2].getref_base())
     pycode = cast_base_ptr_to_instance(PyCode, ll_code)
     return pycode.co_name
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:5,代码来源:test_jit_hook.py


示例14: get_exception_obj

 def get_exception_obj(self, evaluebox):
     # only works when translated
     obj = evaluebox.getref(lltype.Ptr(rclass.OBJECT))
     return cast_base_ptr_to_instance(Exception, obj)
开发者ID:enyst,项目名称:plexnet,代码行数:4,代码来源:typesystem.py


示例15: we_are_translated

                    return
                except self.DoneWithThisFrameInt, e:
                    assert result_kind == 'int'
                    return lltype.cast_primitive(RESULT, e.result)
                except self.DoneWithThisFrameRef, e:
                    assert result_kind == 'ref'
                    return ts.cast_from_ref(RESULT, e.result)
                except self.DoneWithThisFrameFloat, e:
                    assert result_kind == 'float'
                    return e.result
                except self.ExitFrameWithExceptionRef, e:
                    value = ts.cast_to_baseclass(e.value)
                    if not we_are_translated():
                        raise LLException(ts.get_typeptr(value), value)
                    else:
                        value = cast_base_ptr_to_instance(Exception, value)
                        raise Exception, value

        self.ll_portal_runner = ll_portal_runner # for debugging
        self.portal_runner_ptr = self.helper_func(self.PTR_PORTAL_FUNCTYPE,
                                                  ll_portal_runner)
        self.cpu.portal_calldescr = self.cpu.calldescrof(
            self.PTR_PORTAL_FUNCTYPE.TO,
            self.PTR_PORTAL_FUNCTYPE.TO.ARGS,
            self.PTR_PORTAL_FUNCTYPE.TO.RESULT)

        vinfo = self.metainterp_sd.virtualizable_info

        def assembler_call_helper(failindex, virtualizableref):
            fail_descr = self.cpu.get_fail_descr_from_number(failindex)
            while True:
开发者ID:alkorzt,项目名称:pypy,代码行数:31,代码来源:warmspot.py


示例16: force_now

 def force_now(self, virtualizable):
     rti = virtualizable.vable_rti
     virtualizable.vable_rti = self.null_vable_rti
     if we_are_translated():
         rti = cast_base_ptr_to_instance(AbstractVableRti, rti)
     rti.force_now(virtualizable)
开发者ID:enyst,项目名称:plexnet,代码行数:6,代码来源:virtualizable.py


示例17: get_field_untouched

 def get_field_untouched(struc):
     vable_rti = struc.vable_rti
     vable_rti = cast_base_ptr_to_instance(VirtualizableRTI, vable_rti)
     return vable_rti.read_field(fielddesc, struc.vable_base, j)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:4,代码来源:rvirtualizable.py


示例18: show

 def show(gcref):
     ptr = lltype.cast_opaque_ptr(lltype.Ptr(rclass.OBJECT), gcref)
     return cast_base_ptr_to_instance(Opaque, ptr)
开发者ID:ieure,项目名称:pypy,代码行数:3,代码来源:test_ll2ctypes.py


示例19: set_field_untouched

 def set_field_untouched(struc, value):
     vable_rti = struc.vable_rti
     vable_rti = cast_base_ptr_to_instance(VirtualizableRTI, vable_rti)
     vable_rti.touch_update(lltype.cast_opaque_ptr(llmemory.GCREF, struc))
     set_field_touched(struc, value)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:5,代码来源:rvirtualizable.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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