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


Python lltype.cast_ptr_to_int函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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