[pypy-svn] r25916 - in pypy/dist/pypy/rpython: . lltypesystem

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 18 00:02:22 CEST 2006


Author: antocuni
Date: Tue Apr 18 00:02:16 2006
New Revision: 25916

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rlist.py
   pypy/dist/pypy/rpython/rlist.py
Log:
rtype_alloc_and_set and ll_alloc_and_set have been moved to
rpython/rlist.py and made typesystem indipendent, in order to use them
in ootypesystem, too.



Modified: pypy/dist/pypy/rpython/lltypesystem/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rlist.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rlist.py	Tue Apr 18 00:02:16 2006
@@ -5,7 +5,7 @@
 from pypy.rpython.rmodel import externalvsinternal
 from pypy.rpython.rlist import AbstractBaseListRepr, AbstractListRepr, \
         AbstractFixedSizeListRepr, AbstractListIteratorRepr, rtype_newlist, \
-        ll_setitem_nonneg
+        rtype_alloc_and_set, ll_setitem_nonneg
 from pypy.rpython.rlist import dum_nocheck, dum_checkidx
 from pypy.rpython.lltypesystem.rslice import SliceRepr
 from pypy.rpython.lltypesystem.rslice import startstop_slice_repr, startonly_slice_repr
@@ -362,24 +362,6 @@
         llops.gendirectcall(ll_setitem_nonneg, v_func, v_result, ci, v_item)
     return v_result
 
-def ll_alloc_and_set(LIST, count, item):
-    if count < 0:
-        count = 0
-    l = LIST.ll_newlist(count)
-    if item: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
-        i = 0
-        items = l.ll_items()
-        while i < count:
-            items[i] = item
-            i += 1
-    return l
-ll_alloc_and_set.oopspec = 'newlist(count, item)'
-
-def rtype_alloc_and_set(hop):
-    r_list = hop.r_result
-    v_count, v_item = hop.inputargs(Signed, r_list.item_repr)
-    cLIST = hop.inputconst(Void, r_list.LIST)
-    return hop.gendirectcall(ll_alloc_and_set, cLIST, v_count, v_item)
 
 # ____________________________________________________________
 #

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Tue Apr 18 00:02:16 2006
@@ -256,6 +256,12 @@
     items_v = [hop.inputarg(r_listitem, arg=i) for i in range(nb_args)]
     return hop.rtyper.type_system.rlist.newlist(hop.llops, r_list, items_v)
 
+def rtype_alloc_and_set(hop):
+    r_list = hop.r_result
+    v_count, v_item = hop.inputargs(Signed, r_list.item_repr)
+    cLIST = hop.inputconst(Void, r_list.LIST)
+    return hop.gendirectcall(ll_alloc_and_set, cLIST, v_count, v_item)
+
 
 class __extend__(pairtype(AbstractBaseListRepr, AbstractBaseListRepr)):
 
@@ -341,6 +347,18 @@
 #  be direct_call'ed from rtyped flow graphs, which means that they will
 #  get flowed and annotated, mostly with SomePtr.
 
+def ll_alloc_and_set(LIST, count, item):
+    if count < 0:
+        count = 0
+    l = LIST.ll_newlist(count)
+    if item: # as long as malloc it is known to zero the allocated memory avoid zeroing twice
+        i = 0
+        while i < count:
+            l.ll_setitem_fast(i, item)
+            i += 1
+    return l
+ll_alloc_and_set.oopspec = 'newlist(count, item)'
+
 
 # return a nullptr() if lst is a list of pointers it, else None.  Note
 # that if we are using ootypesystem there are not pointers, so we



More information about the Pypy-commit mailing list