[pypy-svn] r22656 - pypy/dist/pypy/rpython

ac at codespeak.net ac at codespeak.net
Wed Jan 25 16:55:16 CET 2006


Author: ac
Date: Wed Jan 25 16:55:16 2006
New Revision: 22656

Modified:
   pypy/dist/pypy/rpython/rgenop.py
   pypy/dist/pypy/rpython/rlist.py
Log:
Oops, forgot these files in the last chekin.

Modified: pypy/dist/pypy/rpython/rgenop.py
==============================================================================
--- pypy/dist/pypy/rpython/rgenop.py	(original)
+++ pypy/dist/pypy/rpython/rgenop.py	Wed Jan 25 16:55:16 2006
@@ -6,6 +6,7 @@
 
 from pypy.rpython.lltypesystem import lltype
 from pypy.objspace.flow import model as flowmodel
+from pypy.translator.simplify import eliminate_empty_blocks, join_blocks
 
 
 def newblock():
@@ -27,6 +28,11 @@
     block.operations.append(op)
     return v
 
+def gengraphconst(block, name, target, FUNCTYPE):
+    fptr = lltype.functionptr(FUNCTYPE, name,
+                              graph=buildgraph(target))
+    return genconst(block, fptr)
+
 def genconst(block, llvalue):
     v = flowmodel.Constant(llvalue)
     v.concretetype = lltype.typeOf(llvalue)
@@ -91,10 +97,17 @@
         from pypy.rpython.typesystem import LowLevelTypeSystem
         self.type_system = LowLevelTypeSystem.instance
 
-def runblock(block, args):
-    from pypy.rpython.llinterp import LLInterpreter
+def buildgraph(block):
     graph = flowmodel.FunctionGraph('?', block)
     _patchgraph(graph)
     flowmodel.checkgraph(graph)
+    eliminate_empty_blocks(graph)
+    join_blocks(graph)
+    graph.rgenop = True
+    return graph
+
+def runblock(block, args):
+    from pypy.rpython.llinterp import LLInterpreter
+    graph = buildgraph(block)
     llinterp = LLInterpreter(PseudoRTyper())
     return llinterp.eval_graph(graph, args)

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Wed Jan 25 16:55:16 2006
@@ -168,12 +168,12 @@
 
         argtypes = [Signed]
         fnptr = list_repr.rtyper.annotate_helper_fn(LIST.ll_newlist, argtypes)
-        self.c_newlist = inputconst(typeOf(fnptr), fnptr)
+        self.newlist_ptr = fnptr
 
         bk = list_repr.rtyper.annotator.bookkeeper
         argtypes = [bk.immutablevalue(dum_nocheck), LISTPTR, Signed, ITEM]
         fnptr = list_repr.rtyper.annotate_helper_fn(ll_setitem_nonneg, argtypes)
-        self.c_setitem_nonneg = inputconst(typeOf(fnptr), fnptr)
+        self.setitem_nonneg_ptr = fnptr
         self.c_dum_nocheck = inputconst(Void, dum_nocheck)
         self.c_LIST = inputconst(Void, self.LIST)
 
@@ -181,12 +181,12 @@
         """Make the operations that would build a list containing the
         provided items."""
         c_list = builder.addconst(self.c_LIST)
-        c_newlist = builder.addconst(self.c_newlist)
+        c_newlist = builder.genconst(self.newlist_ptr)
         c_len  = builder.genconst(len(items_v))
         v_result = builder.genop('direct_call',
                                  [c_newlist, c_list, c_len],
                                  self.LISTPTR)
-        c_setitem_nonneg = builder.addconst(self.c_setitem_nonneg)
+        c_setitem_nonneg = builder.genconst(self.setitem_nonneg_ptr)
         c_dum_nocheck = builder.addconst(self.c_dum_nocheck)
         for i, v in enumerate(items_v):
             c_i = builder.genconst(i)



More information about the Pypy-commit mailing list