[pypy-svn] r20378 - pypy/branch/somepbc-refactoring/pypy/translator

arigo at codespeak.net arigo at codespeak.net
Tue Nov 29 11:01:23 CET 2005


Author: arigo
Date: Tue Nov 29 11:01:22 2005
New Revision: 20378

Modified:
   pypy/branch/somepbc-refactoring/pypy/translator/annrpython.py
   pypy/branch/somepbc-refactoring/pypy/translator/gencl.py
Log:
fix GenCL (its tests, at least, not translator.cl()).


Modified: pypy/branch/somepbc-refactoring/pypy/translator/annrpython.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/translator/annrpython.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/translator/annrpython.py	Tue Nov 29 11:01:22 2005
@@ -81,13 +81,7 @@
         assert isinstance(function, FunctionType), "fix that!"
 
         # make input arguments and set their type
-        inputcells = []
-        input_arg_types = list(input_arg_types)
-
-        for t in input_arg_types:
-            if not isinstance(t, annmodel.SomeObject):
-                t = self.bookkeeper.valueoftype(t)
-            inputcells.append(t)
+        inputcells = [self.typeannotation(t) for t in input_arg_types]
 
         desc = self.bookkeeper.getdesc(function)
         desc.getcallfamily()
@@ -201,6 +195,12 @@
         else:
             raise TypeError, 'Variable or Constant expected, got %r' % (arg,)
 
+    def typeannotation(self, t):
+        if isinstance(t, annmodel.SomeObject):
+            return t
+        else:
+            return self.bookkeeper.valueoftype(t)
+
     def ondegenerated(self, what, s_value, where=None, called_from_graph=None):
         if self.policy.allow_someobjects:
             return

Modified: pypy/branch/somepbc-refactoring/pypy/translator/gencl.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/translator/gencl.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/translator/gencl.py	Tue Nov 29 11:01:22 2005
@@ -162,6 +162,7 @@
 
 class GenCL:
     def __init__(self, fun, input_arg_types=[]):
+        # NB. 'fun' is a graph!
         simplify_graph(fun)
         self.fun = fun
         self.blockref = {}
@@ -170,7 +171,8 @@
                         +[transform_slice])
     def annotate(self, input_arg_types):
         ann = RPythonAnnotator()
-        ann.build_types(self.fun, input_arg_types)
+        inputcells = [ann.typeannotation(t) for t in input_arg_types]
+        ann.build_graph_types(self.fun, inputcells)
         self.setannotator(ann)
     def setannotator(self, annotator):
         self.ann = annotator



More information about the Pypy-commit mailing list