From: Lucas BAJOLET Date: Thu, 21 Feb 2013 20:46:28 +0000 (-0500) Subject: nitdbg: Added function to get a variable in the selected frame by its name X-Git-Tag: v0.6~79^2~51 X-Git-Url: http://nitlanguage.org nitdbg: Added function to get a variable in the selected frame by its name Signed-off-by: Lucas BAJOLET --- diff --git a/src/debugger.nit b/src/debugger.nit index 91074e1..1f48eae 100644 --- a/src/debugger.nit +++ b/src/debugger.nit @@ -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