def __init__(self, rtyper, item_repr, listitem=None): self.rtyper = rtyper self.LIST = GcForwardReference() self.lowleveltype = Ptr(self.LIST) if not isinstance(item_repr, Repr): # not computed yet, done by setup() assert callable(item_repr) self._item_repr_computer = item_repr else: self.external_item_repr, self.item_repr = externalvsinternal( rtyper, item_repr) self.listitem = listitem self.list_cache = {}
Bool, Void, GcArray, nullptr, pyobjectptr, cast_primitive, typeOf,\ staticAdtMethod, GcForwardReference from pypy.rpython.rmodel import Repr from pypy.rpython.lltypesystem import llmemory from pypy.tool.sourcetools import func_with_new_name # ____________________________________________________________ # # Concrete implementation of RPython strings: # # struct str { # hash: Signed # chars: array of Char # } STR = GcForwardReference() UNICODE = GcForwardReference() def new_malloc(TP, name): def mallocstr(length): ll_assert(length >= 0, "negative string length") r = malloc(TP, length) if not we_are_translated() or not malloc_zero_filled: r.hash = 0 return r mallocstr._annspecialcase_ = 'specialize:semierased' return func_with_new_name(mallocstr, name) mallocstr = new_malloc(STR, 'mallocstr') mallocunicode = new_malloc(UNICODE, 'mallocunicode')
from pypy.rpython.lltypesystem.lltype import \ GcStruct, Signed, Array, Char, UniChar, Ptr, malloc, \ Bool, Void, GcArray, nullptr, pyobjectptr, cast_primitive, typeOf,\ staticAdtMethod, GcForwardReference from pypy.rpython.rmodel import Repr # ____________________________________________________________ # # Concrete implementation of RPython strings: # # struct str { # hash: Signed # chars: array of Char # } STR = GcForwardReference() UNICODE = GcForwardReference() def new_malloc(TP): def mallocstr(length): ll_assert(length >= 0, "negative string length") r = malloc(TP, length) if not we_are_translated() or not malloc_zero_filled: r.hash = 0 return r mallocstr._annspecialcase_ = 'specialize:semierased' return mallocstr
) from pypy.rpython.rmodel import Repr from pypy.rpython.lltypesystem import llmemory from pypy.tool.sourcetools import func_with_new_name from pypy.rpython.lltypesystem.lloperation import llop # ____________________________________________________________ # # Concrete implementation of RPython strings: # # struct str { # hash: Signed # chars: array of Char # } STR = GcForwardReference() UNICODE = GcForwardReference() def new_malloc(TP, name): def mallocstr(length): ll_assert(length >= 0, "negative string length") r = malloc(TP, length) if not we_are_translated() or not malloc_zero_filled: r.hash = 0 return r mallocstr._annspecialcase_ = "specialize:semierased" return func_with_new_name(mallocstr, name)
from pypy.rpython.lltypesystem.lltype import \ GcStruct, Signed, Array, Char, UniChar, Ptr, malloc, \ Bool, Void, GcArray, nullptr, pyobjectptr, cast_primitive, typeOf,\ staticAdtMethod, GcForwardReference from pypy.rpython.rmodel import Repr # ____________________________________________________________ # # Concrete implementation of RPython strings: # # struct str { # hash: Signed # chars: array of Char # } STR = GcForwardReference() UNICODE = GcForwardReference() def new_malloc(TP): def mallocstr(length): ll_assert(length >= 0, "negative string length") r = malloc(TP, length) if not we_are_translated() or not malloc_zero_filled: r.hash = 0 return r mallocstr._annspecialcase_ = 'specialize:semierased' return mallocstr mallocstr = new_malloc(STR) mallocunicode = new_malloc(UNICODE)