module nitg
import modelbuilder
-import exprbuilder
+import frontend
+import transform
import rapid_type_analysis
import global_compiler
import separate_erasure_compiler
import separate_compiler
-
-# Create a tool context to handle options and paths
-var toolcontext = new ToolContext
-# 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 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])
-if mmodules.is_empty then return
-modelbuilder.full_propdef_semantic_analysis
-
-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
-var analysis = modelbuilder.do_rapid_type_analysis(mainmodule)
-
-if toolcontext.opt_erasure.value then
- modelbuilder.run_separate_erasure_compiler(mainmodule, analysis)
-else if toolcontext.opt_separate.value then
- modelbuilder.run_separate_compiler(mainmodule, analysis)
-else
- modelbuilder.run_global_compiler(mainmodule, analysis)
+import android_platform
+import compiler_ffi
+import pnacl_platform
+import emscripten_platform
+
+redef class ToolContext
+ redef fun process_options(args)
+ do
+ super
+
+ var sum = opt_global.value.to_i + opt_separate.value.to_i + opt_erasure.value.to_i
+ if sum > 1 then
+ print "Options --global, --separate and --erasure are exclusive"
+ exit(1)
+ else if sum == 0 then
+ # --separate by default
+ opt_separate.value = true
+ end
+ end
end