1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2013 Lucas Bajolet <lucas.bajolet@gmail.com>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Debugging of a nit program using the NaiveInterpreter
20 intrude import naive_interpreter
22 redef class ToolContext
24 var opt_debugger_mode
: OptionBool = new OptionBool("Launches the target program with the debugger attached to it", "-d")
29 self.option_context
.add_option
(self.opt_debugger_mode
)
33 redef class ModelBuilder
34 # Execute the program from the entry point (Sys::main) of the `mainmodule'
35 # `arguments' are the command-line arguments in order
37 # 1. the AST is fully loaded.
38 # 2. the model is fully built.
39 # 3. the instructions are fully analysed.
40 fun run_debugger
(mainmodule
: MModule, arguments
: Array[String])
43 self.toolcontext
.info
("*** START INTERPRETING ***", 1)
45 var interpreter
= new Debugger(self, mainmodule
, arguments
)
47 init_naive_interpreter
(interpreter
, mainmodule
)
50 self.toolcontext
.info
("*** END INTERPRETING: {time1-time0} ***", 2)
54 # The class extending NaiveInterpreter by adding debugging methods
56 super NaiveInterpreter