1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Compile Nit code to Java code
17 # 3 runtime structures are used to represent Nit instance in Java generated code:
18 # * `RTClass` to represent a class, it's super-type table and its VFT
19 # * `RTMethod` to reprensent a compiled method definition
20 # * `RTVal` to reprensent a Nit instance, the null value or a native value
22 # More details are given in the documentation of these 3 classes.
24 # TODO Factorize with `abstract_compiler`
27 import rapid_type_analysis
30 redef class ToolContext
32 # Where to output the generated binary
33 var opt_output
= new OptionString("Output file", "-o", "--output")
35 # Where to output tmp files
36 var opt_compile_dir
= new OptionString("Directory used to generate temporary files", "--compile-dir")
40 option_context
.add_option
(opt_output
, opt_compile_dir
)
44 redef class ModelBuilder
46 # Start the Java compiler
47 fun run_java_compiler
(mainmodule
: MModule, runtime_type_analysis
: RapidTypeAnalysis) do
49 toolcontext
.info
("*** GENERATING JAVA ***", 1)
51 toolcontext
.info
("NOT YET IMPLEMENTED", 0)
54 toolcontext
.info
("*** END GENERATING JAVA: {time1-time0} ***", 2)