redef class MMModule
fun dump_module_info
do
- var p = filename.file_path
+ var p = location.file.file_path
var fname = "{p}/{name}"
var f = new OFStream.open("{fname}.class_hierarchy.new.dot")
f.write(class_specialization_hierarchy.to_dot)
files.add("{tc.compdir}/{m.name}._sep.c")
tc.info("Generating C code for module: {m.name}",2)
m.compile_separate_module(tc, ga)
- var native_name = m.filename.strip_extension(".nit")
+ var native_name = m.location.file.strip_extension(".nit")
if (native_name + "_nit.h").file_exists then
includes.add("-I {native_name.dirname}")
end
do
var v = new GlobalCompilerVisitor(self, tc, ga)
v.add_decl("#include <nit_common.h>")
- var native_name = filename.strip_extension(".nit")
+ var native_name = location.file.strip_extension(".nit")
native_name += ("_nit.h")
if native_name.file_exists then v.add_decl("#include <{native_name.basename("")}>")
declare_class_tables_to_c(v)
# Compile module file for the current module
fun compile_local_table_to_c(v: GlobalCompilerVisitor)
do
- v.add_instr("const char *LOCATE_{name} = \"{filename}\";")
+ v.add_instr("const char *LOCATE_{name} = \"{location.file}\";")
if v.tc.global or _local_table.is_empty then
return
package abstractmetamodel
import partial_order
+import location
# The main singleton which knows everything
class MMContext
# The directory of the module
readable var _directory: MMDirectory
- # The filename of the module
- readable var _filename: String
+ # Location of this module
+ readable var _location: Location
# Module dependence hierarchy element
readable var _mhe: nullable PartialOrderElement[MMModule]
# Dictionary of global classes
var _global_class_by_name: Map[Symbol, MMGlobalClass] = new HashMap[Symbol, MMGlobalClass]
- protected init(name: Symbol, dir: MMDirectory, context: MMContext, filename: String)
+ protected init(name: Symbol, dir: MMDirectory, context: MMContext, loc: Location)
do
_name = name
_directory = dir
_context = context
_full_name = dir.full_name_for(name)
- _filename = filename
+ _location = loc
end
# Register that a module is imported with a visibility
end
var node_module = node_tree.n_base
assert node_module isa AModule
- var module = new MMSrcModule(context, node_module, dir, name, filename)
+ var module_loc = new Location.with_file(filename)
+ var module = new MMSrcModule(context, node_module, dir, name, module_loc)
return module
end
# Concrete NIT source local classs by name
readable var _src_local_classes: Map[Symbol, MMSrcLocalClass]
- init(c: MMContext, source: AModule, dir: MMDirectory, name: Symbol, filename: String)
+ init(c: MMContext, source: AModule, dir: MMDirectory, name: Symbol, loc: Location)
do
- super(name, dir, c, filename)
+ super(name, dir, c, loc)
_node = source
_src_local_classes = new HashMap[Symbol, MMSrcLocalClass]
end
fun locate(n: nullable PNode): String
do
if n != null then return n.locate
- return _module.filename
+ return _module.location.file
end
# Check conformity and display error