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


Python lltype.cast_primitive函数代码示例

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


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

示例1: f

 def f(x):
     x = cast_primitive(UnsignedLongLong, x)
     x <<= 60
     x /= 3
     x <<= 1
     x = cast_primitive(SignedLongLong, x)
     x >>= 32
     return cast_primitive(Signed, x)
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:cast.py

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

示例3: revealconst

 def revealconst(self, T):
     if isinstance(T, lltype.Ptr):
         return lltype.cast_int_to_ptr(T, self.get_integer_value())
     elif T is llmemory.Address:
         return llmemory.cast_int_to_adr(self.get_integer_value())
     else:
         return lltype.cast_primitive(T, self.get_integer_value())
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:7,代码来源:genvarorconst.py

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

示例5: cast_int_to_whatever

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

示例6: convert_const

 def convert_const(self, value):
     if isinstance(value, objectmodel.Symbolic):
         return value
     T = typeOf(value)
     if isinstance(T, Number) or T is Bool:
         return cast_primitive(self.lowleveltype, value)
     raise TyperError("not an integer: %r" % (value,))
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:rint.py

示例7: ll_array_set

def ll_array_set(ITEM, it0, it1):
    if it0.size == 0:
        return # empty LHS..
    ll_assert(it0.size == it1.size, "it0.size == it1.size")
    while it0.index < it0.size:
        it0.dataptr[0] = cast_primitive(ITEM, it1.dataptr[0])
        it0.ll_next()
        it1.ll_next()
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:rarray.py

示例8: ll_str2unicode

 def ll_str2unicode(str):
     lgt = len(str.chars)
     s = mallocunicode(lgt)
     for i in range(lgt):
         if ord(str.chars[i]) > 127:
             raise UnicodeDecodeError
         s.chars[i] = cast_primitive(UniChar, str.chars[i])
     return s
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:rstr.py

示例9: os_open_lltypeimpl

def os_open_lltypeimpl(path, flags, mode):
    l_path = rffi.str2charp(path)
    mode = lltype.cast_primitive(mode_t, mode)
    result = os_open(l_path, flags, mode)
    rffi.free_charp(l_path)
    if result == -1:
        raise OSError(rffi.c_errno, "os_open failed")
    return result
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:8,代码来源:ll_os.py

示例10: ll_encode_latin1

 def ll_encode_latin1(self, s):
     length = len(s.chars)
     result = mallocstr(length)
     for i in range(length):
         c = s.chars[i]
         if ord(c) > 255:
             raise UnicodeEncodeError("character not in latin1 range")
         result.chars[i] = cast_primitive(Char, c)
     return result
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:rstr.py

示例11: ll_str

 def ll_str(self, value):
     sb = ootype.new(ootype.StringBuilder)
     lgt = value.ll_strlen()
     sb.ll_allocate(lgt)
     for i in range(lgt):
         c = value.ll_stritem_nonneg(i)
         if ord(c) > 127:
             raise UnicodeEncodeError("%d > 127, not ascii" % ord(c))
         sb.ll_append_char(cast_primitive(Char, c))
     return sb.ll_build()
开发者ID:alkorzt,项目名称:pypy,代码行数:10,代码来源:rstr.py

示例12: unwrap

def unwrap(TYPE, box):
    if TYPE is lltype.Void:
        return None
    if isinstance(TYPE, lltype.Ptr):
        return box.getref(TYPE)
    if isinstance(TYPE, ootype.OOType):
        return box.getref(TYPE)
    if TYPE == lltype.Float:
        return box.getfloat()
    else:
        return lltype.cast_primitive(TYPE, box.getint())
开发者ID:enyst,项目名称:plexnet,代码行数:11,代码来源:warmstate.py

示例13: set_future_value

def set_future_value(cpu, j, value, typecode):
    if typecode == 'ref':
        refvalue = cpu.ts.cast_to_ref(value)
        cpu.set_future_value_ref(j, refvalue)
    elif typecode == 'int':
        intvalue = lltype.cast_primitive(lltype.Signed, value)
        cpu.set_future_value_int(j, intvalue)
    elif typecode == 'float':
        assert isinstance(value, float)
        cpu.set_future_value_float(j, value)
    else:
        assert False
开发者ID:enyst,项目名称:plexnet,代码行数:12,代码来源:warmstate.py

示例14: genconst

 def genconst(self, llvalue):
     T = lltype.typeOf(llvalue)
     if T is llmemory.Address:
         return AddrConst(llvalue)
     elif isinstance(T, lltype.Primitive):
         return IntConst(lltype.cast_primitive(lltype.Signed, llvalue))
     elif isinstance(T, lltype.Ptr):
         lladdr = llmemory.cast_ptr_to_adr(llvalue)
         if T.TO._gckind == 'gc':
             self.keepalive_gc_refs.append(lltype.cast_opaque_ptr(llmemory.GCREF, llvalue))
         return AddrConst(lladdr)
     else:
         assert 0, "XXX not implemented"
开发者ID:antoine1fr,项目名称:pygirl,代码行数:13,代码来源:rgenop.py

示例15: get_string

 def get_string(self, builder, r):
     current = getattr(builder, self.builder_cache)
     if current and r.random() < .8:
         v_string = r.choice(current)
         string = v_string.getref(self.ptr)
     else:
         string = self.alloc(builder.get_index(500, r).getint())
         v_string = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, string))
         current.append(v_string)
     for i in range(len(string.chars)):
         char = r.random_integer() % self.max
         string.chars[i] = lltype.cast_primitive(self.primitive, char)
     return v_string
开发者ID:alkorzt,项目名称:pypy,代码行数:13,代码来源:test_ll_random.py


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