示例#1
0
 def typed_read(self, TP, byte_offset):
     if not is_alignment_correct(TP, byte_offset):
         raise CannotRead
     lldata = self._get_gc_data()
     byte_offset += self._get_gc_data_extra_offset()
     return llop.gc_load_indexed(TP, lldata, byte_offset,
                                 scale_factor, base_ofs)
示例#2
0
def str_storage_getitem(TP, s, byte_offset):
    # WARNING: the 'byte_offset' is, as its name says, measured in bytes;
    # however, it should be aligned for TP, otherwise on some platforms this
    # code will crash!
    lls = llstr(s)
    base_ofs = (llmemory.offsetof(STR, 'chars') +
                llmemory.itemoffsetof(STR.chars, 0))
    scale_factor = llmemory.sizeof(lltype.Char)
    return llop.gc_load_indexed(TP, lls, byte_offset, scale_factor, base_ofs)
示例#3
0
def str_storage_getitem(TP, s, byte_offset):
    # WARNING: the 'byte_offset' is, as its name says, measured in bytes;
    # however, it should be aligned for TP, otherwise on some platforms this
    # code will crash!
    lls = llstr(s)
    base_ofs = (llmemory.offsetof(STR, 'chars') +
                llmemory.itemoffsetof(STR.chars, 0))
    scale_factor = llmemory.sizeof(lltype.Char)
    return llop.gc_load_indexed(TP, lls, byte_offset,
                                scale_factor, base_ofs)
示例#4
0
文件: test_llop.py 项目: soIu/rpython
def str_gc_load(TYPE, buf, offset):
    base_ofs = (llmemory.offsetof(STR, 'chars') +
                llmemory.itemoffsetof(STR.chars, 0))
    scale_factor = llmemory.sizeof(lltype.Char)
    lls = llstr(buf)
    return llop.gc_load_indexed(TYPE, lls, offset, scale_factor, base_ofs)