[pypy-svn] r32679 - pypy/dist/pypy/objspace/flow

arigo at codespeak.net arigo at codespeak.net
Wed Sep 27 20:59:15 CEST 2006


Author: arigo
Date: Wed Sep 27 20:59:13 2006
New Revision: 32679

Modified:
   pypy/dist/pypy/objspace/flow/model.py
Log:
A more precise checkgraph() for the exit links after an exitswitch.
This one also doesn't complain about a switch with only a 'default'
path, as the JIT creates (as an intermediate to more complete switches).


Modified: pypy/dist/pypy/objspace/flow/model.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/model.py	(original)
+++ pypy/dist/pypy/objspace/flow/model.py	Wed Sep 27 20:59:13 2006
@@ -644,7 +644,17 @@
             else:
                 assert isinstance(block.exitswitch, Variable)
                 assert block.exitswitch in vars
-                assert len(block.exits) > 1
+                if (len(block.exits) == 2 and block.exits[0].exitcase is False
+                                          and block.exits[1].exitcase is True):
+                    # a boolean switch
+                    pass
+                else:
+                    # a multiple-cases switch (or else the False and True
+                    # branches are in the wrong order)
+                    assert len(block.exits) >= 1
+                    assert block.exits[-1].exitcase == "default"
+                    cases = [Constant(link.exitcase) for link in block.exits]
+                    assert len(dict.fromkeys(cases)) == len(cases)
 
             allexitcases = {}
             for link in block.exits:



More information about the Pypy-commit mailing list