1. Ronan Lamy
  2. pypy

Commits

Ronan Lamy  committed a3da3f9

xxx

  • Participants
  • Parent commits 7e9efc5
  • Branches ssa-flow

Comments (0)

Files changed (3)

File rpython/flowspace/flowcontext.py

View file
             return
         self.recorder.guessexception(self, *exceptions)
 
+    def call_inline(self, func, args):
+        recorder = self.recorder
+        if getattr(recorder, 'final_state', None) is not None:
+            self.mergeblock(recorder.crnt_block, recorder.final_state)
+            raise StopFlowing
+        try:
+            graph = getattr(func, 'graph')
+        except AttributeError:
+            from rpython.flowspace.objspace import build_flow
+            graph = build_flow(func)
+            func.graph = graph
+        graph = eval_graph(graph, args)
+        self.recorder.crnt_block.recloseblock(Link([], graph.startblock))
+        xxx
+
+
     def build_flow(self):
         graph = self.graph
         self.pendingblocks = collections.deque([graph.startblock])

File rpython/flowspace/objspace.py

View file
         Returns an FSException object whose w_value is an instance of w_type.
         """
         frame = self.frame
-        if frame.guessbool(self.call_function(const(isinstance), w_arg1,
-                self.w_type)):
-            # this is for all cases of the form (Class, something)
-            if frame.guessbool(self.is_(w_arg2, self.w_None)):
-                # raise Type: we assume we have to instantiate Type
-                w_value = self.call_function(w_arg1)
-            else:
-                w_valuetype = self.type(w_arg2)
-                if frame.guessbool(self.issubtype(w_valuetype, w_arg1)):
-                    # raise Type, Instance: let etype be the exact type of value
-                    w_value = w_arg2
-                else:
-                    # raise Type, X: assume X is the constructor argument
-                    w_value = self.call_function(w_arg1, w_arg2)
-        else:
-            # the only case left here is (inst, None), from a 'raise inst'.
-            if not frame.guessbool(self.is_(w_arg2, self.w_None)):
-                raise self.exc_wrap(TypeError(
-                    "instance exception may not have a separate value"))
-            w_value = w_arg1
+        w_value = frame.call_inline(normalize_exception, [w_arg1, w_arg2])
         w_type = self.type(w_value)
         return FSException(w_type, w_value)
 

File rpython/flowspace/specialcase.py

View file
         s = '\n'
     import os
     os.write(1, s)
+
+def normalize_exception(arg1, arg2):
+    """Create an exception from the arguments of a raise statement."""
+    if isinstance(arg1, type):
+        # this is for all cases of the form (Class, something)
+        if arg2 is None:
+            # raise Type: we assume we have to instantiate Type
+            return arg1()
+        else:
+            if isinstance(arg2, arg1):
+                # raise Type, Instance: let etype be the exact type of value
+                return arg2
+            else:
+                # raise Type, X: assume X is the constructor argument
+                return arg1(arg2)
+    else:
+        # the only case left here is (inst, None), from a 'raise inst'.
+        if arg2 is not None:
+            raise TypeError("instance exception may not have a separate value")
+        return arg1