nitdbg: Added function to get a variable in the selected frame by its name
authorLucas BAJOLET <r4pass@r4pass-ubu-laptophp.(none)>
Thu, 21 Feb 2013 20:46:28 +0000 (15:46 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Mon, 18 Mar 2013 19:04:26 +0000 (15:04 -0400)
Signed-off-by: Lucas BAJOLET <r4pass@hotmail.com>

src/debugger.nit

index 91074e1..1f48eae 100644 (file)
@@ -55,6 +55,24 @@ end
 class Debugger
        super NaiveInterpreter
 
+       # Gets a variable 'variable_name' contained in the frame 'frame'
+       private fun get_variable_in_frame(variable_name: String, frame: Frame): nullable Instance
+       do
+               if variable_name == "self" then
+                       if frame.arguments.length >= 1 then return frame.arguments.first
+               end
+
+               var map_of_instances = frame.map
+
+               for key in map_of_instances.keys do
+                       if key.to_s == variable_name then
+                               return map_of_instances[key]
+                       end
+               end
+
+               return null
+       end
+
        # Gets an attribute 'attribute_name' contained in variable 'variable'
        fun get_attribute_in_mutable_instance(variable: MutableInstance, attribute_name: String): nullable MAttribute
        do