nitc :: actors_generation_phase
Generate a support module for each module that contain a class annotated withis actor
nitc :: actors_injection_phase
Injects model for the classes annotated with "is actor" sonitc :: astbuilder
Instantiation and transformation of semantic nodes in the AST of expressions and statementscflags
and ldflags
to specify
extra_java_files
to compile extra java files
nitc :: i18n_phase
Basic support of internationalization through the generation of id-to-string tablesSerializable::inspect
to show more useful information
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.threaded
annotation
nitc :: serialization_code_gen_phase
Phase generating methods (code) to serialize Nit objectsserialization :: serialization_core
Abstract services to serialize Nit objects to different formatsnitc :: serialization_model_phase
Phase generating methods (model-only) to serialize Nit objectsserialize_to_json
and JsonSerializer
nitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagescore :: union_find
union–find algorithm using an efficient disjoint-set data structureclone
method of the astbuilder tool
# A naive Nit interpreter
module nit
import interpreter
import frontend::code_gen
import parser_util
import vm
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
toolcontext.option_context.options_before_rest = true
toolcontext.tooldescription = "Usage: nit [OPTION]... <file.nit>...\nInterprets and debugs Nit programs."
# Add an option "-o" to enable compatibility with the tests.sh script
var opt = new OptionString("Does nothing. Used for compatibility.", "-o")
opt.hidden = true
toolcontext.option_context.add_option(opt)
var opt_eval = new OptionBool("Specifies the program from command-line", "-e")
var opt_loop = new OptionBool("Repeatedly run the program for each line in file-name arguments", "-n")
var opt_vm = new OptionBool("Run the virtual machine instead of the naive interpreter (experimental)", "--vm")
toolcontext.option_context.add_option(opt_eval, opt_loop, opt_vm)
# We do not add other options, so process them now!
toolcontext.process_options(args)
# 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
var progname = arguments.first
# Here we load an process all modules passed on the command line
var mmodules: Array[MModule]
if opt_eval.value then
var amodule = toolcontext.parse_module(progname)
toolcontext.check_errors
var parent = null
if opt_loop.value then
parent = modelbuilder.get_mmodule_by_name(null, null, "niti_runtime")
if parent == null then
toolcontext.check_errors
abort
end
end
modelbuilder.load_rt_module(parent, amodule, "-")
mmodules = [amodule.mmodule.as(not null)]
else if progname == "-" then
var content = stdin.read_all
var amodule = toolcontext.parse_module(content)
toolcontext.check_errors
modelbuilder.load_rt_module(null, amodule, "-")
mmodules = [amodule.mmodule.as(not null)]
else
mmodules = modelbuilder.parse([progname])
end
modelbuilder.run_phases
if toolcontext.opt_only_metamodel.value then toolcontext.quit
var mainmodule = toolcontext.make_main_module(mmodules)
var self_mm = mainmodule
var self_args = arguments
if opt_vm.value then
modelbuilder.run_virtual_machine(self_mm, self_args)
else
modelbuilder.run_naive_interpreter(self_mm, self_args)
end
src/nit.nit:17,1--90,3