X-Git-Url: http://nitlanguage.org diff --git a/src/interpreter/debugger.nit b/src/interpreter/debugger.nit index 8723ed7..cf4e815 100644 --- a/src/interpreter/debugger.nit +++ b/src/interpreter/debugger.nit @@ -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 @@ -65,7 +64,7 @@ end redef class ScopeVisitor - redef init(toolcontext) + redef init do super if toolcontext.dbg != null then @@ -103,7 +102,7 @@ redef class ToolContext redef fun check_errors do if dbg == null then - super + return super else if messages.length > 0 then message_sorter.sort(messages) @@ -116,6 +115,7 @@ redef class ToolContext messages.clear end + return not had_error end # -d @@ -224,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 ## ####################################################################### @@ -279,20 +281,13 @@ class Debugger assert args.length == mpropdef.msignature.arity + 1 else debug("Invalid arity for {mpropdef}. {args.length} arguments given.") # Look for the AST node that implements the property - var mproperty = mpropdef.mproperty - if self.modelbuilder.mpropdef2npropdef.has_key(mpropdef) then - var npropdef = self.modelbuilder.mpropdef2npropdef[mpropdef] - self.parameter_check(npropdef, mpropdef, args) - if npropdef isa AMethPropdef then - return npropdef.rt_call(self, mpropdef, args) - else - print "Error, invalid propdef to call at runtime !" - return null - end - else if mproperty.is_root_init then - var nclassdef = self.modelbuilder.mclassdef2nclassdef[mpropdef.mclassdef] - self.parameter_check(nclassdef, mpropdef, args) - return nclassdef.call(self, mpropdef, args) + var node = modelbuilder.mpropdef2node(mpropdef) + if node isa AMethPropdef then + self.parameter_check(node, mpropdef, args) + return node.rt_call(self, mpropdef, args) + else if node isa AClassdef then + self.parameter_check(node, mpropdef, args) + return node.call(self, mpropdef, args) else fatal("Fatal Error: method {mpropdef} not found in the AST") abort @@ -474,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 @@ -873,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 @@ -1059,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(".") @@ -1079,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 @@ -1415,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] @@ -1442,16 +1433,11 @@ end private class TraceObject # Map of the local names bound to a frame - var trace_map: HashMap[Frame, String] + var trace_map = new HashMap[Frame, String] + # Decides if breaking or printing statement when the variable is encountered var break_on_encounter: Bool - init(break_on_encounter: Bool) - do - trace_map = new HashMap[Frame, String] - self.break_on_encounter = break_on_encounter - end - # Adds the local alias for a variable and the frame bound to it fun add_frame_variable(frame: Frame, variable_name: String) do