def TUPLE_TYPE(field_lltypes): if len(field_lltypes) == 0: return ootype.Void # empty tuple else: fields = [('item%d' % i, TYPE) for i, TYPE in enumerate(field_lltypes)] hints = {'immutable': True, 'noidentity': True} return ootype.Record(fields, _hints=hints)
def __init__(self, r_list): self.r_list = r_list self.external_item_repr = r_list.external_item_repr self.lowleveltype = ootype.Record( {"iterable": r_list.lowleveltype, "index": ootype.Signed}) self.ll_listiter = ll_listiter self.ll_listnext = ll_listnext self.ll_getnextindex = ll_getnextindex
def __init__(self, r_tuple): self.r_tuple = r_tuple self.lowleveltype = ootype.Record({ "iterable": r_tuple.lowleveltype, "index": ootype.Signed }) self.ll_tupleiter = ll_tupleiter self.ll_tuplenext = ll_tuplenext
class UnicodeIteratorRepr(AbstractStringIteratorRepr): external_item_repr = unichar_repr lowleveltype = ootype.Record({ 'string': unicode_repr.lowleveltype, 'index': ootype.Signed }) def __init__(self): self.ll_striter = ll_unicodeiter self.ll_strnext = ll_strnext self.ll_getnextindex = ll_getnextindex
def test_box_unbox_oorecord(self): A = ootype.Record({'xx': ootype.Signed}) def fn(flag): a = ootype.new(A) a.xx = 42 b_obj = box(a) a2 = unbox(b_obj, A) return a2.xx res = self.interpret(fn, [True]) assert res == 42
def _make_empty_type(self): if self.known_maxlength: return ootype.Record({"items": ootype.Array(), "length": ootype.Signed}) else: return ootype.List()
def _get_type(self): KEYTYPE = self.r_dict.key_repr.lowleveltype VALUETYPE = self.r_dict.value_repr.lowleveltype ITER = ootype.DictItemsIterator(KEYTYPE, VALUETYPE) return ootype.Record({"iterator": ITER})