[pypy-svn] r33070 - pypy/dist/pypy/objspace/flow
arigo at codespeak.net
arigo at codespeak.net
Mon Oct 9 20:43:38 CEST 2006
Author: arigo
Date: Mon Oct 9 20:43:37 2006
New Revision: 33070
Modified:
pypy/dist/pypy/objspace/flow/model.py
Log:
(pedronis, arigo)
Switches with non-integer cases don't really work, neither in llinterp
nor in C, so let's forbid them again.
Modified: pypy/dist/pypy/objspace/flow/model.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/model.py (original)
+++ pypy/dist/pypy/objspace/flow/model.py Mon Oct 9 20:43:37 2006
@@ -647,13 +647,20 @@
# a multiple-cases switch (or else the False and True
# branches are in the wrong order)
assert len(block.exits) >= 1
- cases = [Constant(link.exitcase) for link in block.exits]
- if Constant('default') in cases:
- assert Constant('default') == cases[-1]
- assert len(dict.fromkeys(cases)) == len(cases)
- assert cases != [Constant(None)], (
- "exitswitch Variable followed by a normal-looking link"
- " is probably not intended")
+ cases = [link.exitcase for link in block.exits]
+ has_default = cases[-1] == 'default'
+ for n in cases[:len(cases)-has_default]:
+ if isinstance(n, (int, long)):
+ continue
+ if isinstance(n, (str, unicode)) and len(n) == 1:
+ continue
+ assert n != 'default', (
+ "'default' branch of a switch is not the last exit"
+ )
+ assert n is not None, (
+ "exitswitch Variable followed by a None exitcase")
+ raise AssertionError(
+ "switch on a non-primitive value %r" % (n,))
allexitcases = {}
for link in block.exits:
More information about the Pypy-commit
mailing list