[pypy-svn] r13393 - in pypy/dist/pypy: rpython translator/c
arigo at codespeak.net
arigo at codespeak.net
Tue Jun 14 18:26:11 CEST 2005
Author: arigo
Date: Tue Jun 14 18:26:09 2005
New Revision: 13393
Modified:
pypy/dist/pypy/rpython/exceptiondata.py
pypy/dist/pypy/translator/c/database.py
Log:
Force some standard exceptions to exist and be translated.
Modified: pypy/dist/pypy/rpython/exceptiondata.py
==============================================================================
--- pypy/dist/pypy/rpython/exceptiondata.py (original)
+++ pypy/dist/pypy/rpython/exceptiondata.py Tue Jun 14 18:26:09 2005
@@ -7,7 +7,12 @@
class ExceptionData:
"""Public information for the code generators to help with exceptions."""
+ # the exceptions that can be implicitely raised by some operations
+ standardexceptions = [TypeError, OverflowError, ValueError,
+ ZeroDivisionError, MemoryError]
+
def __init__(self, rtyper):
+ self.make_standard_exceptions(rtyper)
# (NB. rclass identifies 'Exception' and 'object')
r_type = rclass.getclassrepr(rtyper, None)
r_instance = rclass.getinstancerepr(rtyper, None)
@@ -22,6 +27,13 @@
self.ll_pyexcclass2exc = self.make_pyexcclass2exc(rtyper)
+ def make_standard_exceptions(self, rtyper):
+ bk = rtyper.annotator.bookkeeper
+ for cls in self.standardexceptions:
+ classdef = bk.getclassdef(cls)
+ rclass.getclassrepr(rtyper, classdef).setup()
+
+
def make_exception_matcher(self, rtyper):
# ll_exception_matcher(real_exception_vtable, match_exception_vtable)
s_typeptr = annmodel.SomePtr(self.lltype_of_exception_type)
Modified: pypy/dist/pypy/translator/c/database.py
==============================================================================
--- pypy/dist/pypy/translator/c/database.py (original)
+++ pypy/dist/pypy/translator/c/database.py Tue Jun 14 18:26:09 2005
@@ -178,8 +178,7 @@
fnname = self.get(fnptr)
yield '#define RPYTHON_PYEXCCLASS2EXC %s' % (fnname,)
- for pyexccls in [TypeError, OverflowError, ValueError,
- ZeroDivisionError, MemoryError]:
+ for pyexccls in exceptiondata.standardexceptions:
exc_llvalue = exceptiondata.ll_pyexcclass2exc(
pyobjectptr(pyexccls))
# strange naming here because the macro name must be
More information about the Pypy-commit
mailing list