X-Git-Url: http://nitlanguage.org diff --git a/src/nitc.nit b/src/nitc.nit index 6f2bd3e..1df5d90 100644 --- a/src/nitc.nit +++ b/src/nitc.nit @@ -25,10 +25,14 @@ private import syntax # The main class of the nitcompiler program class NitCompiler -special AbstractCompiler + super AbstractCompiler readable var _opt_output: OptionString = new OptionString("Output file", "-o", "--output") readable var _opt_boost: OptionBool = new OptionBool("Optimize compilation", "-O", "--boost") - readable var _opt_no_cc: OptionBool = new OptionBool("Do not invoke C compiler", "--no_cc") + readable var _opt_no_cc: OptionBool = new OptionBool("Do not invoke C compiler", "--no-cc") + readable var _opt_cc_no_link: OptionBool = new OptionBool("Do not invoke C linker", "--cc-no-link") + readable var _opt_cc_lib_paths: OptionArray = new OptionArray("Path to libraries for C compiler", "--cc-lib-path") + readable var _opt_cc_libs: OptionArray = new OptionArray("Name of library to use for C compiler", "--cc-lib-name") + readable var _opt_cc_include_paths: OptionArray = new OptionArray("Path to .h files for C compiler", "--cc-header-path") readable var _opt_global: OptionBool = new OptionBool("Use global compilation", "--global") readable var _opt_global_no_STF_opt: OptionBool = new OptionBool("Do not use SFT optimization", "--no-global-SFT-optimization") readable var _opt_global_no_DMR_opt: OptionBool = new OptionBool("Do not use dead method removal optimization", "--no-global-DMR-optimization") @@ -40,13 +44,12 @@ special AbstractCompiler readable var _opt_bindir: OptionString = new OptionString("NIT tools directory", "--bindir") readable var _opt_compdir: OptionString = new OptionString("Intermediate compilation directory", "--compdir") readable var _opt_extension_prefix: OptionString = new OptionString("Append prefix to file extension", "-p", "--extension-prefix") - readable var _opt_dump: OptionBool = new OptionBool("Dump intermediate code", "--dump") - readable var _opt_output_format: OptionEnum = new OptionEnum(["none", "C"], "The type of code we want to be generated", 1, "--output-format") + readable var _opt_output_format: OptionEnum = new OptionEnum(["none", "C", "icode"], "The type of code we want to be generated", 1, "--output-format") init do super("nitc") - option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_global, opt_clibdir, opt_bindir, opt_compdir, opt_extension_prefix, opt_dump, opt_global_no_STF_opt, opt_global_no_DMR_opt, opt_global_callgraph, opt_global_no_inline_get_set, opt_global_no_RFIMA, opt_global_no_out_of_init_get_test_opt, opt_output_format) + option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_cc_no_link, opt_cc_libs, opt_cc_lib_paths, opt_cc_include_paths, opt_global, opt_clibdir, opt_bindir, opt_compdir, opt_extension_prefix, opt_global_no_STF_opt, opt_global_no_DMR_opt, opt_global_callgraph, opt_global_no_inline_get_set, opt_global_no_RFIMA, opt_global_no_out_of_init_get_test_opt, opt_output_format) end redef fun process_options @@ -55,6 +58,10 @@ special AbstractCompiler output_file = opt_output.value boost = opt_boost.value no_cc = opt_no_cc.value + cc_link = not opt_cc_no_link.value + cc_lib_paths = opt_cc_lib_paths.value + cc_libs = opt_cc_libs.value + cc_include_paths = opt_cc_include_paths.value var ext = opt_extension_prefix.value if ext != null then ext_prefix = ext else ext_prefix = "" global = opt_global.value @@ -107,36 +114,8 @@ special AbstractCompiler end end - fun dump_intermediate_code(mods: Collection[MMModule]) - do - for mod in mods do - for c in mod.local_classes do - if not c isa MMConcreteClass then continue - for p in c.local_local_properties do - var routine: nullable IRoutine = null - if p isa MMAttribute then - routine = p.iroutine - else if p isa MMMethod then - routine = p.iroutine - end - if routine == null then continue - print "**** Property {p.full_name} ****" - var icd = new ICodeDumper(true, true) - routine.dump(icd) - print "**** OPTIMIZE {p.full_name} ****" - routine.optimize(mod) - icd = new ICodeDumper(true, true) - routine.dump(icd) - end - end - end - end - redef fun perform_work(mods) do - if opt_dump.value then - dump_intermediate_code(mods) - end for mod in mods do var p = new Program(mod, self) p.output_format = opt_output_format.value_name