[pypy-svn] r13208 - pypy/dist/pypy/rpython
arigo at codespeak.net
arigo at codespeak.net
Thu Jun 9 00:41:05 CEST 2005
Author: arigo
Date: Thu Jun 9 00:41:03 2005
New Revision: 13208
Modified:
pypy/dist/pypy/rpython/rlist.py
pypy/dist/pypy/rpython/rtyper.py
Log:
Implement the 'alloc_and_set' operation (which comes out of transform.py as a
shorthand for [something] * count ).
Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py (original)
+++ pypy/dist/pypy/rpython/rlist.py Thu Jun 9 00:41:03 2005
@@ -140,6 +140,21 @@
hop.gendirectcall(ll_setitem_nonneg, v_result, ci, v_item)
return v_result
+def ll_alloc_and_set(LISTPTR, count, item):
+ l = malloc(LISTPTR.TO)
+ l.items = malloc(LISTPTR.TO.items.TO, count)
+ i = 0
+ while i < count:
+ l.items[i].item = item
+ i += 1
+ return l
+
+def rtype_alloc_and_set(hop):
+ r_list = hop.r_result
+ v_count, v_item = hop.inputargs(Signed, r_list.item_repr)
+ c1 = hop.inputconst(Void, r_list.lowleveltype)
+ return hop.gendirectcall(ll_alloc_and_set, c1, v_count, v_item)
+
# ____________________________________________________________
#
# Iteration.
Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py (original)
+++ pypy/dist/pypy/rpython/rtyper.py Thu Jun 9 00:41:03 2005
@@ -245,6 +245,9 @@
def translate_op_newlist(self, hop):
return rlist.rtype_newlist(hop)
+ def translate_op_alloc_and_set(self, hop):
+ return rlist.rtype_alloc_and_set(hop)
+
def translate_op_newtuple(self, hop):
return rtuple.rtype_newtuple(hop)
More information about the Pypy-commit
mailing list