[pypy-svn] r19660 - in pypy/branch/somepbc-refactoring/pypy: annotation translator/test

pedronis at codespeak.net pedronis at codespeak.net
Tue Nov 8 23:05:26 CET 2005


Author: pedronis
Date: Tue Nov  8 23:05:23 2005
New Revision: 19660

Modified:
   pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py
   pypy/branch/somepbc-refactoring/pypy/translator/test/test_annrpython.py
Log:
first pass at fixing emulate_pbc_call



Modified: pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/annotation/bookkeeper.py	Tue Nov  8 23:05:23 2005
@@ -520,7 +520,7 @@
 
             callfamily.patterns.update({shape: True})
 
-    def pbc_call(self, pbc, args):
+    def pbc_call(self, pbc, args, emulated=None):
         """Analyse a call to a SomePBC() with the given args (list of
         annotations).
         """
@@ -531,8 +531,15 @@
         first.mergecallfamilies(*descs[1:])
         callfamily = first.getcallfamily()
 
-        def schedule(graph, inputcells):
+        if emulated is None:
             whence = self.position_key
+        else:
+            if emulated is True:
+                whence = None
+            else:
+                whence = emulated # callback case
+
+        def schedule(graph, inputcells):
             return self.annotator.recursivecall(graph, whence, inputcells)
 
         results = []
@@ -580,16 +587,16 @@
 
     def emulate_pbc_call(self, unique_key, pbc, args_s, replace=[], callback=None):
         args = self.build_args("simple_call", args_s)
-        shape = args.rawshape()
-        emulated_pbc_calls = self.emulated_pbc_calls
-        prev = [unique_key]
-        prev.extend(replace)
-        for other_key in prev:
-            if other_key in emulated_pbc_calls:
-                pbc, old_shape = emulated_pbc_calls[other_key]
-                assert shape == old_shape
-                del emulated_pbc_calls[other_key]
-        emulated_pbc_calls[unique_key] = pbc, shape
+        #shape = args.rawshape()
+        #emulated_pbc_calls = self.emulated_pbc_calls
+        #prev = [unique_key]
+        #prev.extend(replace)
+        #for other_key in prev:
+        #    if other_key in emulated_pbc_calls:
+        #        pbc, old_shape = emulated_pbc_calls[other_key]
+        #        assert shape == old_shape
+        #        del emulated_pbc_calls[other_key]
+        #emulated_pbc_calls[unique_key] = pbc, shape
 
         if callback is None:
             emulated = True

Modified: pypy/branch/somepbc-refactoring/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/translator/test/test_annrpython.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/translator/test/test_annrpython.py	Tue Nov  8 23:05:23 2005
@@ -1672,14 +1672,14 @@
         from pypy.translator import translator
         from pypy.translator import annrpython
         a = annrpython.RPythonAnnotator()
+        a.translator = translator.TranslationContext()
         from pypy.annotation import model as annmodel
 
         s_f = a.bookkeeper.immutablevalue(f) 
         a.bookkeeper.emulate_pbc_call('f', s_f, [annmodel.SomeInteger(), annmodel.SomeInteger()])
         a.complete()
 
-        assert f in a.translator.flowgraphs
-        assert a.binding(a.translator.flowgraphs[f].getreturnvar()).knowntype == int
+        assert a.binding(graphof(a, f).getreturnvar()).knowntype == int
 
     def test_emulated_pbc_call_callback(self):
         def f(a,b):
@@ -1687,6 +1687,7 @@
         from pypy.translator import translator
         from pypy.translator import annrpython
         a = annrpython.RPythonAnnotator()
+        a.translator = translator.TranslationContext()
         from pypy.annotation import model as annmodel
 
         memo = []
@@ -1699,8 +1700,7 @@
         assert s == annmodel.SomeImpossibleValue()
         a.complete()
 
-        assert f in a.translator.flowgraphs
-        assert a.binding(a.translator.flowgraphs[f].getreturnvar()).knowntype == int
+        assert a.binding(graphof(a, f).getreturnvar()).knowntype == int
         assert len(memo) >= 1
         for t in memo:
             assert t



More information about the Pypy-commit mailing list