Merge: interpreter use the catch from the compiler
[nit.git] / src / interpreter / debugger.nit
index 58a49d1..25ca6c2 100644 (file)
@@ -18,7 +18,6 @@
 module debugger
 
 intrude import naive_interpreter
-import nitx
 intrude import semantize::local_var_init
 intrude import semantize::scope
 intrude import toolcontext
@@ -225,6 +224,8 @@ class Debugger
        # Auto continues the execution until the end or until an error is encountered
        var autocontinue = false
 
+       redef type FRAME: InterpreterFrame
+
        #######################################################################
        ##                  Execution of statement function                  ##
        #######################################################################
@@ -468,10 +469,6 @@ class Debugger
                else if command == "help" then
                        help
                        return true
-               # Opens a new NitIndex prompt on current model
-               else if command == "nitx" then
-                       new NitIndex.with_infos(modelbuilder, self.mainmodule).prompt
-                       return true
                else if command == "bt" or command == "backtrack" then
                        print stack_trace
                        return true
@@ -867,7 +864,7 @@ class Debugger
        # If the variable *variable_name* is an argument of the function being executed in the frame *frame*
        # The function returns its position in the arguments
        # Else, it returns -1
-       private fun get_position_of_variable_in_arguments(frame: Frame, variable_name: String): Int
+       private fun get_position_of_variable_in_arguments(frame: FRAME, variable_name: String): Int
        do
                var identifiers = get_identifiers_in_current_instruction(get_function_arguments(frame.mpropdef.location.text))
                for i in [0 .. identifiers.length-1] do
@@ -1053,7 +1050,7 @@ class Debugger
        #######################################################################
 
        # Seeks a variable from the current frame called 'variable_path', can introspect complex objects using function get_variable_in_mutable_instance
-       private fun seek_variable(variable_path: String, frame: Frame): nullable Instance
+       private fun seek_variable(variable_path: String, frame: FRAME): nullable Instance
        do
                var full_variable = variable_path.split_with(".")
 
@@ -1073,7 +1070,7 @@ class Debugger
        end
 
        # Gets a variable 'variable_name' contained in the frame 'frame'
-       private fun get_variable_in_frame(variable_name: String, frame: Frame): nullable Instance
+       private fun get_variable_in_frame(variable_name: String, frame: FRAME): nullable Instance
        do
                if variable_name == "self" then
                        if frame.arguments.length >= 1 then return frame.arguments.first
@@ -1409,7 +1406,7 @@ redef class AMethPropdef
        # Not supposed to be used by anyone else than the Debugger.
        private fun rt_call(v: Debugger, mpropdef: MMethodDef, args: Array[Instance]): nullable Instance
        do
-               var f = new Frame(self, self.mpropdef.as(not null), args)
+               var f = new InterpreterFrame(self, self.mpropdef.as(not null), args)
                var curr_instances = v.frame.map
                for i in curr_instances.keys do
                        f.map[i] = curr_instances[i]
@@ -1421,10 +1418,8 @@ redef class AMethPropdef
                                curr_instances[i] = currFra.map[i]
                        end
                end
-               if v.returnmark == f then
-                       v.returnmark = null
+               if v.is_escape(self.return_mark) then
                        var res = v.escapevalue
-                       v.escapevalue = null
                        return res
                end
                return null