Skip to content

Commit

Permalink
Adding step-by-step execution option
Browse files Browse the repository at this point in the history
Add:    -'backtrace full' option to print the local variables of the method
        -'watch' option to print all selected values with 'object_id'
        -'continue' option to execute the code until the next break point 'object_id'

Signed-off-by: Florian Deljarry <[email protected]>
  • Loading branch information
Delja committed Jun 12, 2018
1 parent 44417e9 commit b8892a6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/interpreter/step_interpreter.nit
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ redef class NaiveInterpreter
print "∣You enter in the step-by-step mode"
print "∣Enter " + "'step'".yellow + " to do a step-into"
print "∣Press " + "'enter'".yellow + " to do a step-over"
print "∣Enter " + "'backtrace full'".yellow + " to print the locals variables"
print "∣Enter " + "'watch'".yellow + " to print the watch list variables"
print "∣Enter " + "'continue'".yellow + " to execute the code until the next breakpoint "
print "∣Enter something else to exit the step-by-step mode"
print "────────────────────────────────────────────────────────────────────"
end
Expand Down Expand Up @@ -92,6 +94,17 @@ redef class NaiveInterpreter
self.step_over
else if user_entry == "step" then
self.step_into
else if user_entry == "backtrace full" then
self.object_inspector.print_all_frame_value(frame.as(InterpreterFrame))
self.user_entry = stdin.read_line
self.step_execution(recv)
else if user_entry == "watch" then
self.object_inspector.print_pin_list_value
self.user_entry = stdin.read_line
self.step_execution(recv)
else if user_entry == "continue" then
self.user_entry = ""
self.debug_flag = false
else
self.debug_flag = false
end
Expand Down Expand Up @@ -167,6 +180,14 @@ class ObjectInspector
print "────────────────────────────────────────────────────────────────────"
end

# Display all local frames values
fun print_all_frame_value(frame : InterpreterFrame) do
for variable, instance in frame.map do
var tree = inspect_object(instance,new OrderedTree[ObjectInspected],new ObjectInspected(instance,variable.name),new List[Instance])
print_inspected_element(tree)
end
end

# Display the pin values
fun print_pin_list_value do
for instance , tree in object_watch_list do
Expand Down

0 comments on commit b8892a6

Please sign in to comment.