+ else
+ print "Cannot find variable {parts_of_command[1]}"
+ end
+ end
+ end
+
+ # Processes the input string to know where to put a breakpoint
+ fun process_place_break_fun(parts_of_command: Array[String])
+ do
+ var bp = get_breakpoint_from_command(parts_of_command)
+ if bp != null then
+ place_breakpoint(bp)
+ end
+ end
+
+ # Returns a breakpoint containing the informations stored in the command
+ fun get_breakpoint_from_command(parts_of_command: Array[String]): nullable Breakpoint
+ do
+ if parts_of_command[1].is_numeric then
+ return new Breakpoint(parts_of_command[1].to_i, curr_file)
+ else if parts_of_command.length >= 3 and parts_of_command[2].is_numeric then
+ return new Breakpoint(parts_of_command[2].to_i, parts_of_command[1])
+ else
+ return null
+ end
+ end
+
+ # Processes the command of removing a breakpoint on specified line and file
+ fun process_remove_break_fun(parts_of_command: Array[String])
+ do
+ if parts_of_command[1].is_numeric then
+ remove_breakpoint(self.curr_file, parts_of_command[1].to_i)
+ else if parts_of_command.length >= 3 and parts_of_command[2].is_numeric then
+ remove_breakpoint(parts_of_command[1], parts_of_command[2].to_i)
+ end
+ end
+
+ # Processes an array print command
+ fun process_array_command(parts_of_command: Array[String])
+ do
+ var index_of_first_brace = parts_of_command[1].chars.index_of('[')
+ var variable_name = get_real_variable_name(parts_of_command[1].substring(0,index_of_first_brace))
+ var braces = parts_of_command[1].substring_from(index_of_first_brace)
+
+ var indexes = remove_braces(braces)
+
+ var index_array = new Array[Array[Int]]
+
+ if indexes != null then
+ for index in indexes do
+ var temp_indexes_array = process_index(index)
+ if temp_indexes_array != null then
+ index_array.push(temp_indexes_array)
+ #print index_array.last
+ end
+ end
+ end
+
+ var instance = seek_variable(variable_name, frame)
+
+ if instance != null then
+ print_nested_collection(instance, index_array, 0, variable_name, "")
+ else
+ print "Cannot find variable {variable_name}"
+ end
+ end
+
+ # Processes the modification function to modify a variable dynamically
+ #
+ # Command of type variable = value
+ fun process_mod_function(parts_of_command: Array[String])
+ do
+ parts_of_command[0] = get_real_variable_name(parts_of_command[0])
+ var parts_of_variable = parts_of_command[0].split_with(".")
+
+ if parts_of_variable.length > 1 then
+ var last_part = parts_of_variable.pop
+ var first_part = parts_of_command[0].substring(0,parts_of_command[0].length - last_part.length - 1)
+ var papa = seek_variable(first_part, frame)
+
+ if papa != null and papa isa MutableInstance then
+ var attribute = get_attribute_in_mutable_instance(papa, last_part)
+
+ if attribute != null then
+ modify_argument_of_complex_type(papa, attribute, parts_of_command[2])
+ end
+ end
+ else
+ var target = seek_variable(parts_of_variable[0], frame)
+ if target != null then
+ modify_in_frame(target, parts_of_command[2])
+ end
+ end
+ end
+
+ # Processes the untrace variable command
+ #
+ # Command pattern : "untrace variable"
+ fun process_untrace_command(parts_of_command: Array[String])
+ do
+ var variable_name = get_real_variable_name(parts_of_command[1])
+ if untrace_variable(variable_name) then
+ print "Untraced variable {parts_of_command[1]}"
+ else
+ print "{parts_of_command[1]} is not traced"
+ end
+ end
+
+ # Processes the trace variable command
+ #
+ # Command pattern : "trace variable [break/print]"
+ fun process_trace_command(parts_of_command: Array[String])
+ do
+ var variable_name = get_real_variable_name(parts_of_command[1])
+ var breaker:Bool
+
+ if seek_variable(variable_name, frame) == null then
+ print "Cannot find a variable called {parts_of_command[1]}"
+ return
+ end
+
+ if parts_of_command.length == 3 then
+ if parts_of_command[2] == "break" then
+ breaker = true
+ else
+ breaker = false
+ end
+ else
+ breaker = false
+ end
+
+ trace_variable(variable_name, breaker)
+
+ print "Successfully tracing {parts_of_command[1]}"
+ end
+
+ #######################################################################
+ ## Trace Management functions ##
+ #######################################################################
+
+ # Effectively untraces the variable called *variable_name*
+ #
+ # Returns true if the variable exists, false otherwise
+ private fun untrace_variable(variable_name: String): Bool
+ do
+ var to_remove: nullable TraceObject = null
+ for i in self.traces do
+ if i.is_variable_traced_in_frame(variable_name, frame) then
+ to_remove = i
+ end
+ end
+
+ if to_remove != null then
+ self.traces.remove(to_remove)
+ return true
+ else
+ return false
+ end
+ end
+
+ # Effectively traces the variable *variable_name* either in print or break mode depending on the value of breaker (break if true, print if false)
+ #
+ private fun trace_variable(variable_name: String, breaker: Bool)
+ do
+ for i in self.traces do
+ if i.is_variable_traced_in_frame(variable_name, frame) then
+ print "This variable is already traced"
+ return