Author: Ronan Lamy <[email protected]>
Branch: online-transforms
Changeset: r74412:c6b3999a0d78
Date: 2014-11-08 01:57 +0000
http://bitbucket.org/pypy/pypy/changeset/c6b3999a0d78/

Log:    generate V_Type objects directly during flowing

diff --git a/rpython/annotator/expression.py b/rpython/annotator/expression.py
--- a/rpython/annotator/expression.py
+++ b/rpython/annotator/expression.py
@@ -12,3 +12,6 @@
 
     def as_operation(self):
         return op.type(self.arg)
+
+    def __eq__(self, other):
+        return isinstance(other, V_Type) and other.arg == self.arg
diff --git a/rpython/flowspace/model.py b/rpython/flowspace/model.py
--- a/rpython/flowspace/model.py
+++ b/rpython/flowspace/model.py
@@ -649,14 +649,10 @@
                     assert link.last_exc_value is None
                 for v in link.args:
                     assert isinstance(v, (Constant, Variable))
-                    if isinstance(v, Variable):
+                    if type(v) is Variable:
                         usevar(v, in_link=link)
                         if exc_link:
                             assert v != block.operations[-1].result
-                    #else:
-                    #    if not exc_link:
-                    #        assert v.value is not last_exception
-                    #        #assert v.value != last_exc_value
                 allexitcases[link.exitcase] = True
             assert len(allexitcases) == len(block.exits)
             vars_previous_blocks.update(vars)
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -411,7 +411,7 @@
 
 add_operator('is_', 2, dispatch=2, pure=True)
 add_operator('id', 1, dispatch=1, pyfunc=id)
-add_operator('type', 1, dispatch=1, pyfunc=new_style_type, pure=True)
+#add_operator('type', 1, dispatch=1, pyfunc=new_style_type, pure=True)
 add_operator('issubtype', 2, dispatch=1, pyfunc=issubclass, pure=True)  # not 
for old-style classes
 add_operator('repr', 1, dispatch=1, pyfunc=repr, pure=True)
 add_operator('str', 1, dispatch=1, pyfunc=str, pure=True)
@@ -504,11 +504,14 @@
     canraise = []
     pyfunc = staticmethod(new_style_type)
 
-    def transform(self, annotator):
+    def eval(self, ctx):
+        result = self.constfold()
+        if result is not None:
+            return result
         from rpython.annotator.expression import V_Type
-        value = V_Type(self.args[0])
-        self.result.equals = value
-        return [op.assign(value)]
+        v_instance, = self.args
+        result = V_Type(v_instance)
+        return ctx.do_op(op.assign(result))
 
 
 class NewDict(HLOperation):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to