# HG changeset patch # User Paul Boddie # Date 1484240672 -3600 # Node ID d0eae4e1bdc34a86b4181705dff32f5f2733d6f6 # Parent 3b41a8721f9c901491310a2780e8462c68b4b6d5 Added SystemExit support. diff -r 3b41a8721f9c -r d0eae4e1bdc3 generator.py --- a/generator.py Thu Jan 12 18:03:49 2017 +0100 +++ b/generator.py Thu Jan 12 18:04:32 2017 +0100 @@ -1115,6 +1115,11 @@ } __Catch(__tmp_exc) { + if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {0, &__builtins___exception_system_SystemExit}))) + return __load_via_object( + __load_via_object(__tmp_exc.arg.value, %s).value, + %s).intvalue; + fprintf(stderr, "Program terminated due to exception: %%s.\\n", __load_via_object( %s((__attr[]) {{0, 0}, __tmp_exc.arg}).value, @@ -1123,6 +1128,8 @@ } } """ % ( + encode_symbol("pos", "value"), + encode_symbol("pos", "__data__"), encode_function_pointer("__builtins__.str.str"), encode_symbol("pos", "__data__") ) diff -r 3b41a8721f9c -r d0eae4e1bdc3 lib/__builtins__/exception/system.py --- a/lib/__builtins__/exception/system.py Thu Jan 12 18:03:49 2017 +0100 +++ b/lib/__builtins__/exception/system.py Thu Jan 12 18:04:32 2017 +0100 @@ -40,6 +40,12 @@ class RuntimeError(Exception): pass class RuntimeWarning(Warning): pass class SystemError(Exception): pass -class SystemExit(Exception): pass + +class SystemExit(Exception): + + "An exception exiting the program." + + def __init__(self, value): + self.value = value # vim: tabstop=4 expandtab shiftwidth=4