Skip to content

Commit 0c82c50

Browse files
committed
Adding step-by-step execution option
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]>
1 parent 17ed073 commit 0c82c50

File tree

7 files changed

+45
-18
lines changed

7 files changed

+45
-18
lines changed

src/interpreter/naive_interpreter.nit

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,9 @@ class NaiveInterpreter
773773
print "∣You enter in the step-by-step mode"
774774
print "∣Enter " + "'in'".yellow + " to do a step-into"
775775
print "∣Press " + "'enter'".yellow + " to do a step-over"
776+
print "∣Enter " + "'all'".yellow + " to print the locals variables"
777+
print "∣Enter " + "'watch'".yellow + " to print the watch list variables"
778+
print "∣Enter " + "'next'".yellow + " to execute the code until the next breakpoint "
776779
print "∣Enter something else to exit the step-by-step mode"
777780
print "────────────────────────────────────────────────────────────────────"
778781
end
@@ -809,13 +812,37 @@ class NaiveInterpreter
809812
else if debug_enter_user == "in" then
810813
deep_old_frame = frames.length
811814
self.step_into
815+
else if debug_enter_user == "all" then
816+
self.print_all_frame_value
817+
debug_enter_user = stdin.read_line
818+
step_execution(recv)
819+
else if debug_enter_user == "watch" then
820+
self.print_watch_list_value
821+
debug_enter_user = stdin.read_line
822+
step_execution(recv)
823+
else if debug_enter_user == "next" then
824+
self.debug_enter_user = ""
825+
self.debug_flag = false
812826
else
813827
self.debug_flag = false
814828
end
815829
end
816830
self.old_recv = recv
817831
end
818832

833+
fun print_all_frame_value do
834+
for variable, instance in previous_frame.as(InterpreterFrame).map do
835+
var tree = object_inspector.inspect_object(instance,new OrderedTree[ObjectInspected],new ObjectInspected(instance,variable.name),new List[Instance])
836+
print_inspected_element(tree)
837+
end
838+
end
839+
840+
fun print_watch_list_value do
841+
for instance , tree in object_watch_list do
842+
print_inspected_element(tree)
843+
end
844+
end
845+
819846
# Return the colored line of the current node
820847
fun get_color_line: String
821848
do

tests/sav/error_class_glob.res

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
../lib/core/kernel.nit:32,1--225,3: Error: `kernel$Object` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
2-
../lib/core/kernel.nit:227,1--300,3: Error: `kernel$Sys` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
3-
../lib/core/kernel.nit:313,1--371,3: Error: `kernel$Comparable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
4-
../lib/core/kernel.nit:373,1--410,3: Error: `kernel$Discrete` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
5-
../lib/core/kernel.nit:412,1--429,3: Error: `kernel$Cloneable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
6-
../lib/core/kernel.nit:431,1--486,3: Error: `kernel$Numeric` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
7-
../lib/core/kernel.nit:492,1--515,3: Error: `kernel$Bool` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
8-
../lib/core/kernel.nit:517,1--599,3: Error: `kernel$Float` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
9-
../lib/core/kernel.nit:601,1--705,3: Error: `kernel$Byte` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
10-
../lib/core/kernel.nit:707,1--885,3: Error: `kernel$Int` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
11-
../lib/core/kernel.nit:887,1--1056,3: Error: `kernel$Char` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
12-
../lib/core/kernel.nit:1058,1--1075,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
13-
../lib/core/kernel.nit:1077,1--1086,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
1+
../lib/core/kernel.nit:32,1--230,3: Error: `kernel$Object` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
2+
../lib/core/kernel.nit:232,1--305,3: Error: `kernel$Sys` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
3+
../lib/core/kernel.nit:318,1--376,3: Error: `kernel$Comparable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
4+
../lib/core/kernel.nit:378,1--415,3: Error: `kernel$Discrete` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
5+
../lib/core/kernel.nit:417,1--434,3: Error: `kernel$Cloneable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
6+
../lib/core/kernel.nit:436,1--491,3: Error: `kernel$Numeric` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
7+
../lib/core/kernel.nit:497,1--520,3: Error: `kernel$Bool` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
8+
../lib/core/kernel.nit:522,1--604,3: Error: `kernel$Float` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
9+
../lib/core/kernel.nit:606,1--710,3: Error: `kernel$Byte` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
10+
../lib/core/kernel.nit:712,1--890,3: Error: `kernel$Int` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
11+
../lib/core/kernel.nit:892,1--1061,3: Error: `kernel$Char` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
12+
../lib/core/kernel.nit:1063,1--1080,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?
13+
../lib/core/kernel.nit:1082,1--1091,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`?

tests/sav/nitce/fixme/base_gen_reassign_alt4.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:728)
1+
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:733)
22
11
33
21
44
31

tests/sav/nitce/fixme/base_gen_reassign_alt5.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:728)
1+
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:733)
22
11
33
21
44
31

tests/sav/nitce/fixme/base_gen_reassign_alt6.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:728)
1+
Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/core/kernel.nit:733)
22
11
33
21
44
31

tests/sav/nituml_args3.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ digraph G {
1212
fontsize = 8
1313
]
1414
Object [
15-
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}"
15+
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}"
1616
]
1717

1818
Sys [

tests/sav/nituml_args4.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ digraph G {
1212
fontsize = 8
1313
]
1414
Object [
15-
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}"
15+
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}"
1616
]
1717

1818
Sys [

0 commit comments

Comments
 (0)