Commit 13d4ca82 authored by Travis Hance's avatar Travis Hance

fixed exception bases and added a few exception classes

parent d93ebf0f
...@@ -414,9 +414,10 @@ BoxedModule* builtins_module; ...@@ -414,9 +414,10 @@ BoxedModule* builtins_module;
// TODO looks like CPython and pypy put this into an "exceptions" module: // TODO looks like CPython and pypy put this into an "exceptions" module:
extern "C" { extern "C" {
BoxedClass* Exception, *AssertionError, *AttributeError, *GeneratorExit, *TypeError, *NameError, *KeyError, *IndexError, BoxedClass* BaseException, *Exception, *StandardError, *AssertionError, *AttributeError, *GeneratorExit, *TypeError,
*IOError, *OSError, *ZeroDivisionError, *ValueError, *UnboundLocalError, *RuntimeError, *ImportError, *NameError, *KeyError, *IndexError, *IOError, *OSError, *ZeroDivisionError, *ValueError, *UnboundLocalError,
*StopIteration, *Warning, *SyntaxError, *OverflowError, *DeprecationWarning, *MemoryError; *RuntimeError, *ImportError, *StopIteration, *Warning, *SyntaxError, *OverflowError, *DeprecationWarning,
*MemoryError, *LookupError, *EnvironmentError, *ArithmeticError;
} }
Box* exceptionNew1(BoxedClass* cls) { Box* exceptionNew1(BoxedClass* cls) {
...@@ -569,30 +570,35 @@ void setupBuiltins() { ...@@ -569,30 +570,35 @@ void setupBuiltins() {
builtins_module->giveAttr("all", new BoxedFunction(boxRTFunction((void*)all, BOXED_BOOL, 1))); builtins_module->giveAttr("all", new BoxedFunction(boxRTFunction((void*)all, BOXED_BOOL, 1)));
builtins_module->giveAttr("any", new BoxedFunction(boxRTFunction((void*)any, BOXED_BOOL, 1))); builtins_module->giveAttr("any", new BoxedFunction(boxRTFunction((void*)any, BOXED_BOOL, 1)));
Exception = makeBuiltinException(object_cls, "Exception"); BaseException = makeBuiltinException(object_cls, "BaseException");
AssertionError = makeBuiltinException(Exception, "AssertionError"); Exception = makeBuiltinException(BaseException, "Exception");
AttributeError = makeBuiltinException(Exception, "AttributeError"); StandardError = makeBuiltinException(Exception, "StandardError");
GeneratorExit = makeBuiltinException(Exception, "GeneratorExit"); AssertionError = makeBuiltinException(StandardError, "AssertionError");
TypeError = makeBuiltinException(Exception, "TypeError"); AttributeError = makeBuiltinException(StandardError, "AttributeError");
NameError = makeBuiltinException(Exception, "NameError"); GeneratorExit = makeBuiltinException(BaseException, "GeneratorExit");
KeyError = makeBuiltinException(Exception, "KeyError"); TypeError = makeBuiltinException(StandardError, "TypeError");
IndexError = makeBuiltinException(Exception, "IndexError"); NameError = makeBuiltinException(StandardError, "NameError");
IOError = makeBuiltinException(Exception, "IOError"); LookupError = makeBuiltinException(StandardError, "LookupError");
OSError = makeBuiltinException(Exception, "OSError"); KeyError = makeBuiltinException(LookupError, "KeyError");
ZeroDivisionError = makeBuiltinException(Exception, "ZeroDivisionError"); IndexError = makeBuiltinException(LookupError, "IndexError");
ValueError = makeBuiltinException(Exception, "ValueError"); EnvironmentError = makeBuiltinException(StandardError, "EnvironmentError");
UnboundLocalError = makeBuiltinException(Exception, "UnboundLocalError"); IOError = makeBuiltinException(EnvironmentError, "IOError");
RuntimeError = makeBuiltinException(Exception, "RuntimeError"); OSError = makeBuiltinException(EnvironmentError, "OSError");
ImportError = makeBuiltinException(Exception, "ImportError"); ArithmeticError = makeBuiltinException(StandardError, "ArithmeticError");
ZeroDivisionError = makeBuiltinException(ArithmeticError, "ZeroDivisionError");
ValueError = makeBuiltinException(StandardError, "ValueError");
UnboundLocalError = makeBuiltinException(NameError, "UnboundLocalError");
RuntimeError = makeBuiltinException(StandardError, "RuntimeError");
ImportError = makeBuiltinException(StandardError, "ImportError");
StopIteration = makeBuiltinException(Exception, "StopIteration"); StopIteration = makeBuiltinException(Exception, "StopIteration");
Warning = makeBuiltinException(Exception, "Warning"); Warning = makeBuiltinException(Exception, "Warning");
SyntaxError = makeBuiltinException(Exception, "SyntaxError"); SyntaxError = makeBuiltinException(StandardError, "SyntaxError");
OverflowError = makeBuiltinException(Exception, "OverflowError"); OverflowError = makeBuiltinException(ArithmeticError, "OverflowError");
/*ImportWarning =*/makeBuiltinException(Warning, "ImportWarning"); /*ImportWarning =*/makeBuiltinException(Warning, "ImportWarning");
/*PendingDeprecationWarning =*/makeBuiltinException(Warning, "PendingDeprecationWarning"); /*PendingDeprecationWarning =*/makeBuiltinException(Warning, "PendingDeprecationWarning");
DeprecationWarning = makeBuiltinException(Warning, "DeprecationWarning"); DeprecationWarning = makeBuiltinException(Warning, "DeprecationWarning");
/*BytesWarning =*/makeBuiltinException(Warning, "BytesWarning"); /*BytesWarning =*/makeBuiltinException(Warning, "BytesWarning");
MemoryError = makeBuiltinException(Exception, "MemoryError"); MemoryError = makeBuiltinException(StandardError, "MemoryError");
repr_obj = new BoxedFunction(boxRTFunction((void*)repr, UNKNOWN, 1)); repr_obj = new BoxedFunction(boxRTFunction((void*)repr, UNKNOWN, 1));
builtins_module->giveAttr("repr", repr_obj); builtins_module->giveAttr("repr", repr_obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment