Merge remote-tracking branch 'lucas/netdbg_wip'
authorJean Privat <jean@pryen.org>
Tue, 13 Aug 2013 18:11:17 +0000 (14:11 -0400)
committerJean Privat <jean@pryen.org>
Tue, 13 Aug 2013 18:11:17 +0000 (14:11 -0400)
Conflicts:
src/Makefile
src/nit.nit

Updated:
src/nitdbg_commons.nit

1  2 
src/Makefile
src/nit.nit
src/nitdbg_commons.nit

diff --cc src/Makefile
@@@ -16,7 -16,7 +16,7 @@@
  
  NITCOPT=
  
- all: ../bin/nitc ../bin/nitdoc ../bin/nits ../bin/nitmetrics ../bin/nitg ../bin/nit ../bin/nitx
 -all: ../bin/nitc ../bin/nitdoc ../bin/nits ../bin/nitmetrics ../bin/nitg ../bin/nit ../bin/netdbg ../bin/dbgcli
++all: ../bin/nitc ../bin/nitdoc ../bin/nits ../bin/nitmetrics ../bin/nitg ../bin/nit ../bin/nitx ../bin/netdbg ../bin/dbgcli
  
  ../bin/nitc: ../c_src/nitc parser/parser.nit
        @echo '***************************************************************'
        @echo '* Compile nit from NIT source files                           *'
        @echo '***************************************************************'
        ./git-gen-version.sh
 -      ../bin/nitc ${NITCOPT} -o ../bin/nit -O -v nit.nit
 +      ../bin/nitg ${NITCOPT} -o ../bin/nit -v nit.nit
 +
 +../bin/nitx: ../bin/nitg
 +      @echo '***************************************************************'
 +      @echo '* Compile nitx from NIT source files                          *'
 +      @echo '***************************************************************'
 +      ./git-gen-version.sh
 +      ../bin/nitg ${NITCOPT} -o ../bin/nitx -v nitx.nit
  
+ ../bin/netdbg : ../bin/nitc
+       @echo '***************************************************************'
+       @echo '* Compile netdbg from NIT source files                          *'
+       @echo '***************************************************************'
+       ./git-gen-version.sh
+       ../bin/nitc ${NITCOPT} -o ../bin/netdbg -O -v netdbg.nit
+ ../bin/dbgcli : ../bin/nitc
+       @echo '***************************************************************'
+       @echo '* Compile dbgcli from NIT source files                          *'
+       @echo '***************************************************************'
+       ./git-gen-version.sh
+       ../bin/nitc ${NITCOPT} -o ../bin/dbgcli -O -v dbgcli.nit
  ../c_src/nitc: ../c_src/*.c ../c_src/*.h ../c_src/nitc._build.sh ../c_src/Makefile
        @echo '***************************************************************'
        @echo '* Compile nitc from C source files                            *'
diff --cc src/nit.nit
  # A naive Nit interpreter
  module nit
  
- import modelbuilder
- import frontend
  import naive_interpreter
  import debugger
- #import interpretor_type_test
+ import nitdbg_commons
+ redef class InterpretCommons
+       redef fun launch
+       do
+               super
+               var self_mm = mainmodule.as(not null)
+               var self_args = arguments.as(not null)
+               if toolcontext.opt_debugger_autorun.value then
+                       modelbuilder.run_debugger_autorun(self_mm, self_args)
+               else if toolcontext.opt_debugger_mode.value then
+                       modelbuilder.run_debugger(self_mm, self_args)
+               else
+                       modelbuilder.run_naive_interpreter(self_mm, self_args)
+               end
+       end
  
- # Create a tool context to handle options and paths
- var toolcontext = new ToolContext
- # Add an option "-o" to enable compatibilit with the tests.sh script
- var opt = new OptionString("compatibility (does noting)", "-o")
- toolcontext.option_context.add_option(opt)
- # We do not add other options, so process them now!
- toolcontext.process_options
- # We need a model to collect stufs
- var model = new Model
- # An a model builder to parse files
- var modelbuilder = new ModelBuilder(model, toolcontext)
- var arguments = toolcontext.option_context.rest
- if arguments.is_empty or toolcontext.opt_help.value then
-       toolcontext.option_context.usage
-       return
  end
- var progname = arguments.first
- # Here we load an process all modules passed on the command line
- var mmodules = modelbuilder.parse([progname])
- modelbuilder.run_phases
  
- # Here we launch the interpreter on the main module
- assert mmodules.length == 1
- var mainmodule = mmodules.first
- if toolcontext.opt_debugger_autorun.value then
-       modelbuilder.run_debugger_autorun(mainmodule, arguments)
- else if toolcontext.opt_debugger_mode.value then
-       modelbuilder.run_debugger(mainmodule, arguments)
- else
-       modelbuilder.run_naive_interpreter(mainmodule, arguments)
- end
 -(new InterpretCommons).launch
++(new InterpretCommons).launch
index 0000000,6995db5..f266805
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,67 +1,67 @@@
+ # This file is part of NIT ( http://www.nitlanguage.org ).
+ #
+ # Copyright 2013 Lucas Bajolet <lucas.bajolet@hotmail.com>
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ #     http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ module nitdbg_commons
+ import modelbuilder
 -import exprbuilder
++import frontend
+ class InterpretCommons
+       var model: nullable Model
+       var modelbuilder: nullable ModelBuilder
+       var toolcontext: nullable ToolContext
+       var mainmodule: nullable MModule
+       var arguments: nullable Array[String]
+       init
+       do
+       end
+       fun launch
+       do
+               # Create a tool context to handle options and paths
+               toolcontext = new ToolContext
+               # Add an option "-o" to enable compatibilit with the tests.sh script
+               var opt = new OptionString("compatibility (does noting)", "-o")
+               toolcontext.option_context.add_option(opt)
+               # We do not add other options, so process them now!
+               toolcontext.process_options
+               
+               # We need a model to collect stufs
+               model = new Model
+               # An a model builder to parse files
+               modelbuilder = new ModelBuilder(model.as(not null), toolcontext.as(not null))
+               
+               arguments = toolcontext.option_context.rest
+               if arguments.is_empty or toolcontext.opt_help.value then
+                       toolcontext.option_context.usage
+                       return
+               end
+               var progname = arguments.first
+               
+               # Here we load an process all modules passed on the command line
 -              var mmodules = modelbuilder.parse_and_build([progname])
 -              modelbuilder.full_propdef_semantic_analysis
++              var mmodules = modelbuilder.parse([progname])
++              modelbuilder.run_phases
+               
+               if toolcontext.opt_only_metamodel.value then exit(0)
+               
+               # Here we launch the interpreter on the main module
+               assert mmodules.length == 1
+               mainmodule = mmodules.first
+       end
+ end