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

Python lltype.cast_ptr_to_int函数代码示例

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

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



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

示例1: f

 def f():
     s1 = lltype.malloc(S)
     llop.keepalive(lltype.Void, s1)
     s2 = lltype.malloc(S)
     llop.keepalive(lltype.Void, s1)
     llop.keepalive(lltype.Void, s2)
     return lltype.cast_ptr_to_int(s1) + lltype.cast_ptr_to_int(s2)
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:7,代码来源:test_removenoops.py


示例2: cast_whatever_to_int

def cast_whatever_to_int(T, value):
    if isinstance(T, lltype.Ptr):
        return lltype.cast_ptr_to_int(value)
    elif T is llmemory.Address:
        return llmemory.cast_adr_to_int(value)
    else:
        return lltype.cast_primitive(lltype.Signed, value)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:rgenop.py


示例3: ll_unboxed_isinstance_const

def ll_unboxed_isinstance_const(obj, minid, maxid, answer_if_unboxed):
    if not obj:
        return False
    if lltype.cast_ptr_to_int(obj) & 1:
        return answer_if_unboxed
    else:
        return ll_issubclass_const(obj.typeptr, minid, maxid)
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:rtagged.py


示例4: ll_str

 def ll_str(self, i):
     if lltype.cast_ptr_to_int(i) & 1:
         from pypy.rpython.lltypesystem import rstr
         from pypy.rpython.rint import signed_repr
         llstr1 = signed_repr.ll_str(ll_unboxed_to_int(i))
         return rstr.ll_strconcat(rstr.unboxed_instance_str_prefix,
                   rstr.ll_strconcat(llstr1,
                                     rstr.unboxed_instance_str_suffix))
     else:
         return InstanceRepr.ll_str(self, i)
开发者ID:alkorzt,项目名称:pypy,代码行数:10,代码来源:rtagged.py


示例5: ll_inst_hash

def ll_inst_hash(ins):
    if not ins:
        return 0    # for None
    cached = ins.hash_cache
    if cached == 0:
        # XXX this should ideally be done in a GC-dependent way: we only
        # need a hash_cache for moving GCs, and we only need the '~' to
        # avoid Boehm keeping the object alive if the value is passed
        # around
       cached = ins.hash_cache = ~cast_ptr_to_int(ins)
    return cached
开发者ID:antoine1fr,项目名称:pygirl,代码行数:11,代码来源:rclass.py


示例6: tigetstr_llimpl

def tigetstr_llimpl(cap):
    check_setup_invoked()
    ll_cap = rffi.str2charp(cap)
    try:
        ll_res = c_tigetstr(ll_cap)
        num = lltype.cast_ptr_to_int(ll_res)
        if num == 0 or num == -1:
            raise interp_curses.TermError()
        res = rffi.charp2str(ll_res)
        return res
    finally:
        rffi.free_charp(ll_cap)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:12,代码来源:fficurses.py


示例7: _generalcast

def _generalcast(T, value):
    if isinstance(T, lltype.Ptr):
        return lltype.cast_pointer(T, value)
    elif T == llmemory.Address:
        return llmemory.cast_ptr_to_adr(value)
    else:
        T1 = lltype.typeOf(value)
        if T1 is llmemory.Address:
            value = llmemory.cast_adr_to_int(value)
        elif isinstance(T1, lltype.Ptr):
            value = lltype.cast_ptr_to_int(value)
        else:
            value = value
        return lltype.cast_primitive(T, value)    
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:llimpl.py


示例8: add_case

def add_case(block, exitcase):
    block = from_opaque_object(block)
    exitcase = from_opaque_object(exitcase)
    assert isinstance(exitcase, flowmodel.Constant)
    assert isinstance(block.exitswitch, flowmodel.Variable)
    case_link = flowmodel.Link([], None)
    exitvalue = exitcase.value
    if isinstance(lltype.typeOf(exitvalue), lltype.Ptr):
        # XXX hack!
        exitvalue = lltype.cast_ptr_to_int(exitvalue)
    case_link.exitcase = exitvalue
    case_link.llexitcase = exitvalue
    if block.exits and block.exits[-1].exitcase == 'default':
        exits = block.exits[:-1] + (case_link,) + block.exits[-1:]
    else:
        exits = block.exits + (case_link,)
    block.recloseblock(*exits)
    return to_opaque_object(case_link)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:18,代码来源:llimpl.py


示例9: _generalcast

def _generalcast(T, value):
    if lltype.typeOf(value) == T:
        return value
    elif isinstance(T, lltype.Ptr):
        return lltype.cast_pointer(T, value)
    elif T == llmemory.Address:
        return llmemory.cast_ptr_to_adr(value)
    elif isinstance(T, ootype.StaticMethod):
        fn = value._obj
        return ootype._static_meth(T, graph=fn.graph, _callable=fn._callable)
    else:
        T1 = lltype.typeOf(value)
        if T1 is llmemory.Address:
            value = llmemory.cast_adr_to_int(value)
        elif isinstance(T1, lltype.Ptr):
            value = lltype.cast_ptr_to_int(value)
        else:
            value = value
        return lltype.cast_primitive(T, value)    
开发者ID:antoine1fr,项目名称:pygirl,代码行数:19,代码来源:llimpl.py


示例10: ll_str

 def ll_str(self, i): # doesn't work for non-gc classes!
     from pypy.rpython.lltypesystem import rstr
     from pypy.rpython.lltypesystem.ll_str import ll_int2hex
     from pypy.rlib.rarithmetic import r_uint
     if not i:
         return rstr.null_str
     instance = cast_pointer(OBJECTPTR, i)
     uid = r_uint(cast_ptr_to_int(i))
     nameLen = len(instance.typeptr.name)
     nameString = rstr.mallocstr(nameLen-1)
     i = 0
     while i < nameLen - 1:
         nameString.chars[i] = instance.typeptr.name[i]
         i += 1
     res =                        rstr.instance_str_prefix
     res = rstr.ll_strconcat(res, nameString)
     res = rstr.ll_strconcat(res, rstr.instance_str_infix)
     res = rstr.ll_strconcat(res, ll_int2hex(uid, False))
     res = rstr.ll_strconcat(res, rstr.instance_str_suffix)
     return res
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:20,代码来源:rclass.py


示例11: gc_malloc_fnaddr

def gc_malloc_fnaddr():
    """Returns the address of the Boehm 'malloc' function."""
    if we_are_translated():
        gc_malloc_ptr = llhelper(GC_MALLOC, gc_malloc)
        return lltype.cast_ptr_to_int(gc_malloc_ptr)
    else:
        # <pedronis> don't do this at home
        import threading
        if not isinstance(threading.currentThread(), threading._MainThread):
            import py
            py.test.skip("must run in the main thread")
        try:
            from ctypes import cast, c_void_p, util
            path = util.find_library('gc')
            if path is None:
                raise ImportError("Boehm (libgc) not found")
            boehmlib = ctypes.cdll.LoadLibrary(path)
        except ImportError, e:
            import py
            py.test.skip(str(e))
        else:
开发者ID:antoine1fr,项目名称:pygirl,代码行数:21,代码来源:rgenop.py


示例12: test_gcref_casts

    def test_gcref_casts(self):
        p0 = ctypes.c_void_p(0)
        ref0 = ctypes2lltype(llmemory.GCREF, p0)

        assert lltype.cast_ptr_to_int(ref0) == 0
        assert llmemory.cast_ptr_to_adr(ref0) == llmemory.NULL

        NODE = lltype.GcStruct('NODE')
        assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref0) == lltype.nullptr(NODE)

        node = lltype.malloc(NODE)
        ref1 = lltype.cast_opaque_ptr(llmemory.GCREF, node)

        intval  = rffi.cast(lltype.Signed, node)
        intval1 = rffi.cast(lltype.Signed, ref1)

        assert intval == intval1

        ref2 = ctypes2lltype(llmemory.GCREF, intval1)

        assert lltype.cast_opaque_ptr(lltype.Ptr(NODE), ref2) == node
开发者ID:alkorzt,项目名称:pypy,代码行数:21,代码来源:test_ll2ctypes.py


示例13: g

 def g(p):
     return lltype.cast_ptr_to_int(p)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:2,代码来源:test_portal.py


示例14: f

 def f(p):
     n = lltype.cast_ptr_to_int(p)
     return n
开发者ID:enyst,项目名称:plexnet,代码行数:3,代码来源:test_basic.py


示例15: f

 def f():
     p = lltype.malloc(GCS1)
     return lltype.cast_ptr_to_int(p)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:3,代码来源:test_annotator.py


示例16: cast_gcref_to_int

def cast_gcref_to_int(gcref):
    if we_are_translated():
        return lltype.cast_ptr_to_int(gcref)
    else:
        return id(gcref._x)
开发者ID:ieure,项目名称:pypy,代码行数:5,代码来源:rgc.py


示例17: ll_unboxed_to_int

def ll_unboxed_to_int(p):
    return lltype.cast_ptr_to_int(p) >> 1
开发者ID:alkorzt,项目名称:pypy,代码行数:2,代码来源:rtagged.py


示例18: op_cast_ptr_to_int

 def op_cast_ptr_to_int(self, ptr1):
     checkptr(ptr1)
     return lltype.cast_ptr_to_int(ptr1)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:3,代码来源:llinterp.py


示例19: ll_str

 def ll_str(self, p):
     from pypy.rpython.lltypesystem.rstr import ll_str
     id = lltype.cast_ptr_to_int(p)
     return ll_str.ll_int2hex(r_uint(id), True)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:rptr.py


示例20: test_instantiate

def test_instantiate():
    def fn1(n):
        return C(n)
    res = interpret(fn1, [42], taggedpointers=True)
    value = lltype.cast_ptr_to_int(res)
    assert value == 42 * 2 + 1    # for now
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:6,代码来源:test_rtagged.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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