From: Jean Privat Date: Thu, 14 Apr 2016 01:03:06 +0000 (-0400) Subject: Merge: Introducing the do ... catch ... end structure X-Git-Url: http://nitlanguage.org Merge: Introducing the do ... catch ... end structure This PR is a first step in trying to handle exceptions in Nit, replacing the behaviour of `abort` if it happens within a do ... catch ... end. In the compiler, setjmp() et longjmp() are used to jump directly from the `abort` to the nearest `catch` bloc. Pull-Request: #2011 Reviewed-by: Jean Privat Reviewed-by: Alexis Laferrière --- 18633a190ffb0929bb4bd56729909d80ebef5280 diff --cc src/interpreter/naive_interpreter.nit index 7fc2355,c70dc83..0028df4 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@@ -117,9 -121,16 +117,16 @@@ class NaiveInterprete # Set this mark to skip the evaluation until a labeled statement catch it with `is_escape` var escapemark: nullable EscapeMark = null + # Is an abort being executed ? + # Set this mark to return to the last `catch` bloc or effectively aborting if there isn't any + var catch_mark = new EscapeMark + + # The count of `catch` blocs that have been encountered and can catch an abort + var catch_count = 0 + # Is a return or a break or a continue executed? # Use this function to know if you must skip the evaluation of statements - fun is_escaping: Bool do return returnmark != null or escapemark != null + fun is_escaping: Bool do return escapemark != null # The value associated with the current return/break/continue, if any. # Set the value when you set a escapemark.