[pypy-commit] pypy online-transforms: rename all the things in annotator.follow_link()

rlamy noreply at buildbot.pypy.org
Sun Nov 9 01:27:06 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: online-transforms
Changeset: r74411:388640976ffd
Date: 2014-11-07 19:31 +0000
http://bitbucket.org/pypy/pypy/changeset/388640976ffd/

Log:	rename all the things in annotator.follow_link()

diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -494,87 +494,84 @@
 
     def follow_link(self, graph, link, knowntypedata):
         in_except_block = False
-        last_exception_var = link.last_exception  # may be None for non-exception link
-        last_exc_value_var = link.last_exc_value  # may be None for non-exception link
+        v_last_exc_type = link.last_exception  # may be None for non-exception link
+        v_last_exc_value = link.last_exc_value  # may be None for non-exception link
 
-        if isinstance(link.exitcase, (types.ClassType, type)) \
-                and issubclass(link.exitcase, py.builtin.BaseException):
-            assert last_exception_var and last_exc_value_var
-            last_exc_value_object = self.bookkeeper.valueoftype(link.exitcase)
-            last_exception_object = annmodel.SomeType()
-            if isinstance(last_exception_var, Constant):
-                last_exception_object.const = last_exception_var.value
-            last_exception_object.is_type_of = [last_exc_value_var]
+        if (isinstance(link.exitcase, (types.ClassType, type)) and
+                issubclass(link.exitcase, BaseException)):
+            assert v_last_exc_type and v_last_exc_value
+            s_last_exc_value = self.bookkeeper.valueoftype(link.exitcase)
+            s_last_exc_type = annmodel.SomeType()
+            if isinstance(v_last_exc_type, Constant):
+                s_last_exc_type.const = v_last_exc_type.value
+            s_last_exc_type.is_type_of = [v_last_exc_value]
 
-            if isinstance(last_exception_var, Variable):
-                self.setbinding(last_exception_var, last_exception_object)
-            if isinstance(last_exc_value_var, Variable):
-                self.setbinding(last_exc_value_var, last_exc_value_object)
+            if isinstance(v_last_exc_type, Variable):
+                self.setbinding(v_last_exc_type, s_last_exc_type)
+            if isinstance(v_last_exc_value, Variable):
+                self.setbinding(v_last_exc_value, s_last_exc_value)
 
-            last_exception_object = annmodel.SomeType()
-            if isinstance(last_exception_var, Constant):
-                last_exception_object.const = last_exception_var.value
-            #if link.exitcase is Exception:
-            #    last_exc_value_object = annmodel.SomeObject()
-            #else:
+            s_last_exc_type = annmodel.SomeType()
+            if isinstance(v_last_exc_type, Constant):
+                s_last_exc_type.const = v_last_exc_type.value
             last_exc_value_vars = []
             in_except_block = True
 
         ignore_link = False
-        cells = []
+        inputs_s = []
         renaming = {}
-        for a, v in zip(link.args, link.target.inputargs):
-            renaming.setdefault(a, []).append(v)
-        for a, v in zip(link.args, link.target.inputargs):
-            if a == last_exception_var:
+        for v_out, v_input in zip(link.args, link.target.inputargs):
+            renaming.setdefault(v_out, []).append(v_input)
+        for v_out, v_input in zip(link.args, link.target.inputargs):
+            if v_out == v_last_exc_type:
                 assert in_except_block
-                cells.append(last_exception_object)
-            elif a == last_exc_value_var:
+                inputs_s.append(s_last_exc_type)
+            elif v_out == v_last_exc_value:
                 assert in_except_block
-                cells.append(last_exc_value_object)
-                last_exc_value_vars.append(v)
+                inputs_s.append(s_last_exc_value)
+                last_exc_value_vars.append(v_input)
             else:
-                cell = self.binding(a)
-                if (link.exitcase, a) in knowntypedata:
-                    knownvarvalue = knowntypedata[(link.exitcase, a)]
-                    cell = pair(cell, knownvarvalue).improve()
+                s_out = self.annotation(v_out)
+                if (link.exitcase, v_out) in knowntypedata:
+                    knownvarvalue = knowntypedata[(link.exitcase, v_out)]
+                    s_out = pair(s_out, knownvarvalue).improve()
                     # ignore links that try to pass impossible values
-                    if cell == annmodel.s_ImpossibleValue:
+                    if s_out == annmodel.s_ImpossibleValue:
                         ignore_link = True
 
-                if hasattr(cell,'is_type_of'):
+                if hasattr(s_out,'is_type_of'):
                     renamed_is_type_of = []
-                    for v in cell.is_type_of:
-                        new_vs = renaming.get(v,[])
+                    for v in s_out.is_type_of:
+                        new_vs = renaming.get(v, [])
                         renamed_is_type_of += new_vs
-                    assert cell.knowntype is type
+                    assert s_out.knowntype is type
                     newcell = annmodel.SomeType()
-                    if cell.is_constant():
-                        newcell.const = cell.const
-                    cell = newcell
-                    cell.is_type_of = renamed_is_type_of
+                    if s_out.is_constant():
+                        newcell.const = s_out.const
+                    s_out = newcell
+                    s_out.is_type_of = renamed_is_type_of
 
-                if hasattr(cell, 'knowntypedata'):
+                if hasattr(s_out, 'knowntypedata'):
                     renamed_knowntypedata = {}
-                    for (value, v), s in cell.knowntypedata.items():
+                    for (value, v), s in s_out.knowntypedata.items():
                         new_vs = renaming.get(v, [])
                         for new_v in new_vs:
                             renamed_knowntypedata[value, new_v] = s
-                    assert isinstance(cell, annmodel.SomeBool)
+                    assert isinstance(s_out, annmodel.SomeBool)
                     newcell = annmodel.SomeBool()
-                    if cell.is_constant():
-                        newcell.const = cell.const
-                    cell = newcell
-                    cell.set_knowntypedata(renamed_knowntypedata)
+                    if s_out.is_constant():
+                        newcell.const = s_out.const
+                    s_out = newcell
+                    s_out.set_knowntypedata(renamed_knowntypedata)
 
-                cells.append(cell)
+                inputs_s.append(s_out)
         if ignore_link:
             return
 
         if in_except_block:
-            last_exception_object.is_type_of = last_exc_value_vars
+            s_last_exc_type.is_type_of = last_exc_value_vars
         self.links_followed[link] = True
-        self.addpendingblock(graph, link.target, cells)
+        self.addpendingblock(graph, link.target, inputs_s)
 
     #___ creating the annotations based on operations ______
 


More information about the pypy-commit mailing list