Skip to content

Commit

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

Signed-off-by: Florian Deljarry <[email protected]>
  • Loading branch information
Delja committed May 24, 2018
1 parent f92b6c6 commit 088c2b1
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 18 deletions.
27 changes: 27 additions & 0 deletions src/interpreter/naive_interpreter.nit
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ class NaiveInterpreter
print "∣You enter in the step-by-step mode"
print "∣Enter " + "'in'".yellow + " to do a step-into"
print "∣Press " + "'enter'".yellow + " to do a step-over"
print "∣Enter " + "'all'".yellow + " to print the locals variables"
print "∣Enter " + "'watch'".yellow + " to print the watch list variables"
print "∣Enter " + "'next'".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 @@ -809,13 +812,37 @@ class NaiveInterpreter
else if debug_enter_user == "in" then
deep_old_frame = frames.length
self.step_into
else if debug_enter_user == "all" then
self.print_all_frame_value
debug_enter_user = stdin.read_line
step_execution(recv)
else if debug_enter_user == "watch" then
self.print_watch_list_value
debug_enter_user = stdin.read_line
step_execution(recv)
else if debug_enter_user == "next" then
self.debug_enter_user = ""
self.debug_flag = false
else
self.debug_flag = false
end
end
self.old_recv = recv
end

fun print_all_frame_value do
for variable, instance in previous_frame.as(InterpreterFrame).map do
var tree = object_inspector.inspect_object(instance,new OrderedTree[ObjectInspected],new ObjectInspected(instance,variable.name),new List[Instance])
print_inspected_element(tree)
end
end

fun print_watch_list_value do
for instance , tree in object_watch_list do
print_inspected_element(tree)
end
end

# Return the colored line of the current node
fun get_color_line: String
do
Expand Down
26 changes: 13 additions & 13 deletions tests/sav/error_class_glob.res
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
../lib/core/kernel.nit:32,1--225,3: Error: `kernel$Object` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:227,1--300,3: Error: `kernel$Sys` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:313,1--371,3: Error: `kernel$Comparable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:373,1--410,3: Error: `kernel$Discrete` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:412,1--429,3: Error: `kernel$Cloneable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:431,1--486,3: Error: `kernel$Numeric` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:492,1--515,3: Error: `kernel$Bool` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:517,1--599,3: Error: `kernel$Float` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:601,1--705,3: Error: `kernel$Byte` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:707,1--885,3: Error: `kernel$Int` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:887,1--1056,3: Error: `kernel$Char` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:1058,1--1075,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:1077,1--1086,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:32,1--230,3: Error: `kernel$Object` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:232,1--305,3: Error: `kernel$Sys` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:318,1--376,3: Error: `kernel$Comparable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:378,1--415,3: Error: `kernel$Discrete` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:417,1--434,3: Error: `kernel$Cloneable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:436,1--491,3: Error: `kernel$Numeric` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:497,1--520,3: Error: `kernel$Bool` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:522,1--604,3: Error: `kernel$Float` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:606,1--710,3: Error: `kernel$Byte` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:712,1--890,3: Error: `kernel$Int` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:892,1--1061,3: Error: `kernel$Char` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:1063,1--1080,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
../lib/core/kernel.nit:1082,1--1091,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
2 changes: 1 addition & 1 deletion tests/sav/nitce/fixme/base_gen_reassign_alt4.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:728)
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:733)
11
21
31
Expand Down
2 changes: 1 addition & 1 deletion tests/sav/nitce/fixme/base_gen_reassign_alt5.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:728)
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:733)
11
21
31
Expand Down
2 changes: 1 addition & 1 deletion tests/sav/nitce/fixme/base_gen_reassign_alt6.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:728)
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:733)
11
21
31
Expand Down
2 changes: 1 addition & 1 deletion tests/sav/nituml_args3.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ digraph G {
fontsize = 8
]
Object [
label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ sys(): Sys\l+ init()\l}"
label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ inspect_o()\l+ sys(): Sys\l+ init()\l}"
]

Sys [
Expand Down
2 changes: 1 addition & 1 deletion tests/sav/nituml_args4.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ digraph G {
fontsize = 8
]
Object [
label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ sys(): Sys\l+ init()\l}"
label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ inspect_o()\l+ sys(): Sys\l+ init()\l}"
]

Sys [
Expand Down

0 comments on commit 088c2b1

Please sign in to comment.