[pypy-svn] r12067 - pypy/dist/pypy/translator
tismer at codespeak.net
tismer at codespeak.net
Sun May 8 13:17:49 CEST 2005
Author: tismer
Date: Sun May 8 13:17:49 2005
New Revision: 12067
Modified:
pypy/dist/pypy/translator/annrpython.py
Log:
interpretation of can_only_throw is now very exact.
The possible exceptions are checked against the
actual ones and get consumed. The algorithm works
like this: (pseudo language)
candidates = can_only_throw
for each exception link in order
covered = all candidates which match link
if covered not empty
add link to exceptions
remove covered from candidates
Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py (original)
+++ pypy/dist/pypy/translator/annrpython.py Sun May 8 13:17:49 2005
@@ -417,11 +417,16 @@
can_only_throw = getattr(unop, "can_only_throw", None)
else:
can_only_throw = None
+
if can_only_throw is not None:
- exits = [link
- for link in exits
- if link.exitcase is None
- or link.exitcase in can_only_throw ]
+ candidates = can_only_throw
+ exits = [block.exits[0]]
+ for link in block.exits[1:]:
+ case = link.exitcase
+ covered = [c for c in candidates if issubclass(c, case)]
+ if covered:
+ exits.append(link)
+ candidates = [c for c in candidates if c not in covered]
for link in exits:
self.links_followed[link] = True
More information about the Pypy-commit
mailing list