@@ -455,6 +455,16 @@ class NaiveInterpreter
455455 f .map [v ] = value
456456 end
457457
458+ # Retrieve the variable of the Instance in the current frame
459+ fun read_instance (i : Instance ): nullable Variable
460+ do
461+ var f = frames .first .as (InterpreterFrame )
462+ for key , value in f .map do
463+ if value == i then return key
464+ end
465+ return null
466+ end
467+
458468 # Store known methods, used to trace methods as they are reached
459469 var discover_call_trace : Set [MMethodDef ] = new HashSet [MMethodDef ]
460470
@@ -719,11 +729,42 @@ class NaiveInterpreter
719729 # This flag is used to launch setp by step interpreter
720730 var debug_flag = false
721731
732+ fun print_inspected_element (tree : OrderedTree [ObjectInspected ]) do
733+ print "──────────────────────────────────────────────────────────────────── "
734+ tree .write_to (stdout )
735+ print "──────────────────────────────────────────────────────────────────── "
736+ end
737+
738+ fun refrech_object_watch_list do
739+ var old = old_recv
740+ if old != null then
741+ for instance , tree in object_watch_list do
742+ # Check if the old receiver is in the watch list
743+ if old_recv .eq_is (instance ) then
744+ # get the associated variable if any
745+ var variable = read_instance (old )
746+ var update = new OrderedTree [ObjectInspected ]
747+ if variable != null then
748+ update = object_inspector .inspect_object (old ,new OrderedTree [ObjectInspected ],new ObjectInspected (old ,variable .name ),new List [Instance ])
749+ if update .to_s != self .object_watch_list [old ].to_s then
750+ self .object_watch_list [old ] = update
751+ print_inspected_element (update )
752+ end
753+ else
754+ update = object_inspector .inspect_object (old ,new OrderedTree [ObjectInspected ],new ObjectInspected (old ,"Return value " ), new List [Instance ])
755+ self .object_watch_list .keys .remove (instance )
756+ self .object_watch_list .values .remove (tree )
757+ print_inspected_element (update )
758+ end
759+ end
760+ end
761+ end
762+ end
763+
722764 fun add_object_watch_list (instance : Instance )do
723765 object_watch_list [instance ] = object_inspector .inspect_object (instance ,new OrderedTree [ObjectInspected ],new ObjectInspected (instance ,"" ), new List [Instance ])
724766 deep_old_frame = frames .length
725767 self .debug_flag = true
726- object_watch_list [instance ].write_to (stdout )
727768 end
728769
729770 # Print the commands to execute step-by-step execution
@@ -762,6 +803,7 @@ class NaiveInterpreter
762803 fun step_execution (recv : Instance ) do
763804 if self .debug_flag then
764805 init_debug_mode
806+ refrech_object_watch_list
765807 if debug_enter_user == "" then
766808 self .step_over
767809 else if debug_enter_user == "in " then
0 commit comments