From e8bf939d50f595725980457ddf92d28b53615ffb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julien=20Pag=C3=A8s?= Date: Fri, 13 Mar 2015 16:46:46 +0100 Subject: [PATCH] niti: Introduce and use a virtual type for the frames MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Julien Pagès --- src/interpreter/debugger.nit | 8 +++++--- src/interpreter/naive_interpreter.nit | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/interpreter/debugger.nit b/src/interpreter/debugger.nit index 58a49d1..4400939 100644 --- a/src/interpreter/debugger.nit +++ b/src/interpreter/debugger.nit @@ -225,6 +225,8 @@ class Debugger # Auto continues the execution until the end or until an error is encountered var autocontinue = false + redef type FRAME: Frame + ####################################################################### ## Execution of statement function ## ####################################################################### @@ -867,7 +869,7 @@ class Debugger # If the variable *variable_name* is an argument of the function being executed in the frame *frame* # The function returns its position in the arguments # Else, it returns -1 - private fun get_position_of_variable_in_arguments(frame: Frame, variable_name: String): Int + private fun get_position_of_variable_in_arguments(frame: FRAME, variable_name: String): Int do var identifiers = get_identifiers_in_current_instruction(get_function_arguments(frame.mpropdef.location.text)) for i in [0 .. identifiers.length-1] do @@ -1053,7 +1055,7 @@ class Debugger ####################################################################### # Seeks a variable from the current frame called 'variable_path', can introspect complex objects using function get_variable_in_mutable_instance - private fun seek_variable(variable_path: String, frame: Frame): nullable Instance + private fun seek_variable(variable_path: String, frame: FRAME): nullable Instance do var full_variable = variable_path.split_with(".") @@ -1073,7 +1075,7 @@ class Debugger end # Gets a variable 'variable_name' contained in the frame 'frame' - private fun get_variable_in_frame(variable_name: String, frame: Frame): nullable Instance + 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 diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index dd61428..6333bc0 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -115,7 +115,7 @@ class NaiveInterpreter # Is a return executed? # Set this mark to skip the evaluation until the end of the specified method frame - var returnmark: nullable Frame = null + var returnmark: nullable FRAME = null # Is a break or a continue executed? # Set this mark to skip the evaluation until a labeled statement catch it with `is_escape` @@ -283,11 +283,14 @@ class NaiveInterpreter return res end + # The virtual type of the frames used in the execution engine + type FRAME: Frame + # The current frame used to store local variables of the current method executed - fun frame: Frame do return frames.first + fun frame: FRAME do return frames.first # The stack of all frames. The first one is the current one. - var frames = new List[Frame] + var frames = new List[FRAME] # Return a stack trace. One line per function fun stack_trace: String -- 1.7.9.5