Commits

Jeremy Thurgood committed c0e310c

Make enumerate() work with rstr.

Comments (0)

Files changed (3)

rpython/rtyper/lltypesystem/rlist.py

 
     def __init__(self, r_list):
         self.r_list = r_list
+        self.external_item_repr = r_list.external_item_repr
         self.lowleveltype = Ptr(GcStruct('listiter',
                                          ('list', r_list.lowleveltype),
                                          ('index', Signed)))

rpython/rtyper/lltypesystem/rstr.py

     def __init__(self):
         self.ll_striter = ll_striter
         self.ll_strnext = ll_strnext
+        self.ll_getnextindex = ll_getnextindex
 
 class StringIteratorRepr(BaseStringIteratorRepr):
 
+    external_item_repr = char_repr
     lowleveltype = Ptr(GcStruct('stringiter',
                                 ('string', string_repr.lowleveltype),
                                 ('index', Signed)))
 
 class UnicodeIteratorRepr(BaseStringIteratorRepr):
 
+    external_item_repr = unichar_repr
     lowleveltype = Ptr(GcStruct('unicodeiter',
                                 ('string', unicode_repr.lowleveltype),
                                 ('index', Signed)))
     iter.index = index + 1
     return chars[index]
 
+def ll_getnextindex(iter):
+    return iter.index
+
 string_repr.iterator_repr = StringIteratorRepr()
 unicode_repr.iterator_repr = UnicodeIteratorRepr()
 

rpython/rtyper/rrange.py

         v_index = hop.gendirectcall(self.ll_getnextindex, v_enumerate)
         hop2 = hop.copy()
         hop2.args_r = [self.r_baseiter]
-        r_item_src = self.r_baseiter.r_list.external_item_repr
+        r_item_src = self.r_baseiter.external_item_repr
         r_item_dst = hop.r_result.items_r[1]
         v_item = self.r_baseiter.rtype_next(hop2)
         v_item = hop.llops.convertvar(v_item, r_item_src, r_item_dst)