nitdbg: Added capacity to interpret with debugger in nit.nit
authorLucas Bajolet <r4pass@localhost.localdomain>
Thu, 14 Mar 2013 18:55:57 +0000 (14:55 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Mon, 18 Mar 2013 19:04:22 +0000 (15:04 -0400)
Signed-off-by: Lucas BAJOLET <r4pass@hotmail.com>

src/debugger.nit
src/nit.nit

index ca4acb0..b610c61 100644 (file)
@@ -19,6 +19,17 @@ module debugger
 
 intrude import naive_interpreter
 
+redef class ToolContext
+       # -d
+       var opt_debugger_mode: OptionBool = new OptionBool("Launches the target program with the debugger attached to it", "-d")
+
+       redef init
+       do
+               super
+               self.option_context.add_option(self.opt_debugger_mode)
+       end
+end
+
 redef class ModelBuilder
        # Execute the program from the entry point (Sys::main) of the `mainmodule'
        # `arguments' are the command-line arguments in order
index 5c9f7e6..eca3d4f 100644 (file)
@@ -20,6 +20,7 @@ module nit
 import modelbuilder
 import exprbuilder
 import naive_interpreter
+import debugger
 #import interpretor_type_test
 
 # Create a tool context to handle options and paths
@@ -51,4 +52,9 @@ if toolcontext.opt_only_metamodel.value then exit(0)
 # Here we launch the interpreter on the main module
 assert mmodules.length == 1
 var mainmodule = mmodules.first
-modelbuilder.run_naive_interpreter(mainmodule, arguments)
+
+if toolcontext.opt_debugger_mode.value then
+       modelbuilder.run_debugger(mainmodule, arguments)
+else
+       modelbuilder.run_naive_interpreter(mainmodule, arguments)
+end