'module' will become a keyword.
Therefore the identifiers 'module' must be renamed.
The strategy is the following:
* use 'mod' in local variables and parameters
* Program::module -> Program::main_module
* use mmmodule for other properties (no better ideas)
Signed-off-by: Jean Privat <jean@pryen.org>
else if ic isa INew then
# FIXME: take only the last property on the redef. hierarchie
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var m = cls[ic.property.global].as(MMMethod)
var r = cls.new_instance_iroutine[m]
builder.add_search(ic.property, r, false, false)
builder.add_search(ic.property, ic.property.iroutine, false, false)
else if ic isa ICheckInstance then
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var ir = cls.checknew_iroutine
builder.add_search(null, ir, true, false)
else if ic isa IInitAttributes then
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var ir = cls.init_var_iroutine
builder.add_search(null, ir, true, false)
end
# This method will create a file and output informations about this optimization
fun dump_dead_method_optimization(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.dmr_opt.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.dmr_opt.log")
f.write("Nb. dead iroutines removed: {nb_removed_iroutines}\n")
f.write("Nb. live iroutines: {nb_not_removed_iroutines}\n")
# This method will create a file and output the name of all types that are instantiated in it
fun dump_instantiated_types(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.instantiated_types.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.instantiated_types.log")
with_each_live_local_classes !action(c) do
f.write("{c}\n")
end
# This method will create a file and output the names of all types that are not instantiated in it
fun dump_not_instantiated_types(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.not_instantiated_types.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.not_instantiated_types.log")
# Must overwrite 'with_each_local_classes' since we are looking at non-instantiated classes
- for c in module.local_classes do
+ for c in main_module.local_classes do
if not ita.is_class_instantiated(c) then
f.write("{c}\n")
end
redef fun with_each_live_local_classes
!action(m: MMLocalClass)
do
- for c in module.local_classes do
+ for c in main_module.local_classes do
if ita == null or ita.as(not null).is_class_instantiated(c) then action(c)
end
end
# This method will create a file and output all inits reachable as init in it
fun dump_reachable_as_init_methods(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.reachable_methods_as_init.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.reachable_methods_as_init.log")
with_each_live_local_classes !action(c) do
for g in c.global_properties do
var p = c[g]
if ic isa INew then
# FIXME: take only the last property on the redef. hierarchie
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var m = cls[ic.property.global].as(MMMethod)
assert m.global.is_init
if not builder.context._methods.has_key(cls) then builder.context._methods[cls] = new List[MMMethod]
# This method will create a file and output the name of all methods reachable
# from an init in it
fun dump_reachable_methods_from_init(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.reachable_methods_from_init.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.reachable_methods_from_init.log")
with_each_methods !action(m) do
if rfima.is_method_reachable_from_init(m) then
f.write("{m.full_name}\n")
# This method will create a file and output the name of all reachable methods that
# can not be reached from an init in it
fun dump_unreachable_methods_from_init(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.unreachable_methods_from_init.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.unreachable_methods_from_init.log")
with_each_methods !action(m) do
if not rfima.is_method_reachable_from_init(m) and rma.is_method_reachable(m) then
f.write("{m.full_name}\n")
else if ic isa INew then
# FIXME: take only the last property on the redef. hierarchie
var t = ic.stype
- var cls = t.for_module(program.module).local_class
+ var cls = t.for_module(program.main_module).local_class
var m = cls[ic.property.global].as(MMMethod)
var r = cls.new_instance_iroutine[m]
process_call(r)
end
else if ic isa ICheckInstance then
var t = ic.stype
- var cls = t.for_module(program.module).local_class
+ var cls = t.for_module(program.main_module).local_class
var ir = cls.checknew_iroutine
if ir != null then process_call(ir)
else if ic isa IInitAttributes then
var t = ic.stype
- var cls = t.for_module(program.module).local_class
+ var cls = t.for_module(program.main_module).local_class
var ir = cls.init_var_iroutine
if ir != null then process_call(ir)
end
# This method will create a file and output all reachable method names in it
fun dump_reachable_methods(directory_name: String, algo: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.reachable_methods.{algo}.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.reachable_methods.{algo}.log")
with_each_methods !action(m) do
if rma.is_method_reachable(m) then
f.write("{m.full_name}\n")
# This method will create a file and output all unreachable method names in it
fun dump_unreachable_methods(directory_name: String, algo: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.unreachable_methods.{algo}.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.unreachable_methods.{algo}.log")
with_each_methods !action(m) do
if not rma.is_method_reachable(m) then
f.write("{m.full_name}\n")
# This method will create a file and output informations about this optimization
fun dump_out_of_init_information(directory_name: String) do
- var f = new OFStream.open("{directory_name}/{module.name}.out_of_init_opt.log")
+ var f = new OFStream.open("{directory_name}/{main_module.name}.out_of_init_opt.log")
var nb_not_optimized = 0
with_each_iroutines !action(i,m) do
# Also check every subclasses if they use the same 'version' of the
# method
fun check_method(m: MMMethod): Bool do
- var m_cls = m.local_class.for_module(program.module)
+ var m_cls = m.local_class.for_module(program.main_module)
if context.is_class_instantiated(m_cls) then return true
var forced_types = ["Object", "Bool", "Float", "Int", "String", "NativeString", "Range", "Array", "ArrayIterator", "Inline__"]
for some_type in forced_types do
- if not program.module.has_global_class_named(some_type.to_symbol) then continue
- var cls_type = program.module.class_by_name(some_type.to_symbol)
+ if not program.main_module.has_global_class_named(some_type.to_symbol) then continue
+ var cls_type = program.main_module.class_by_name(some_type.to_symbol)
add_instantiated_class(cls_type)
end
- if program.module.has_global_class_named("Inline__".to_symbol) then
- var ptr_class = program.module.class_by_name("Inline__".to_symbol)
+ if program.main_module.has_global_class_named("Inline__".to_symbol) then
+ var ptr_class = program.main_module.class_by_name("Inline__".to_symbol)
# Assume that all classes that are subclasses of Inline__
# can be inlined without notice ...
# and are always counted as instantiated
end
end
- if program.module.has_global_class_named("Pointer".to_symbol) then
- var ptr_class = program.module.class_by_name("Pointer".to_symbol)
+ if program.main_module.has_global_class_named("Pointer".to_symbol) then
+ var ptr_class = program.main_module.class_by_name("Pointer".to_symbol)
# Assume that all classes that are subclasses of Pointer
# can be returned by the native interface
# and are always counted as instantiated
end
end
- for cls in program.module.global_classes do
+ for cls in program.main_module.global_classes do
if not cls.is_universal then continue
- add_instantiated_class(program.module[cls])
+ add_instantiated_class(program.main_module[cls])
end
end
if program.main_method == null then
# Add primitive type (so that compiling works)
for t in ["Int","Char","Bool"] do
- if program.module.has_global_class_named(t.to_symbol) then
- add_instantiated_class(program.module.class_by_name(t.to_symbol))
+ if program.main_module.has_global_class_named(t.to_symbol) then
+ add_instantiated_class(program.main_module.class_by_name(t.to_symbol))
end
end
return
else if ic isa INew then
# FIXME: take only the last property on the redef. hierarchie
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var m = cls[ic.property.global].as(MMMethod)
var r = cls.new_instance_iroutine[m]
builder.add_instantiated_class(cls)
builder.add_reachable_call(ic)
else if ic isa ICheckInstance then
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var ir = cls.checknew_iroutine
builder.add_reachable_iroutine(ir)
else if ic isa IInitAttributes then
var t = ic.stype
- var cls = t.for_module(builder.program.module).local_class
+ var cls = t.for_module(builder.program.main_module).local_class
var ir = cls.init_var_iroutine
builder.add_reachable_iroutine(ir)
end
cprogram.files.add("$CLIBDIR/gc_static_objects_list.c")
tc.info("Generating C code",1)
- for m in module.mhe.greaters_and_self do m.compile_separate_module(cprogram)
+ for m in main_module.mhe.greaters_and_self do m.compile_separate_module(cprogram)
tc.info("Generating main, tables and makefile ...",1)
compile_main(cprogram)
# Compile the main file
private fun compile_main(cprogram: CProgram)
do
- var v = new CompilerVisitor(module, cprogram)
+ var v = new CompilerVisitor(main_module, cprogram)
v.add_decl("#include <nit_common.h>")
compile_tables_to_c(v)
compile_main_part(v)
- var filename = "{cprogram.compdir}/{module.name}._tables.c"
+ var filename = "{cprogram.compdir}/{main_module.name}._tables.c"
cprogram.files.add(filename)
var f = new OFStream.open(filename)
- f.write("/* This C file is generated by NIT to compile program {module.name}. */\n")
- for m in module.mhe.greaters_and_self do
+ f.write("/* This C file is generated by NIT to compile program {main_module.name}. */\n")
+ for m in main_module.mhe.greaters_and_self do
f.write("#include \"{cprogram.module_header_name(m)}\"\n")
end
v.header_writer.write_to_stream(f)
do
_program = p
_compdir = p.tc.compdir.as(not null)
- _build_file = "{compdir}/{program.module.name}._build.sh"
+ _build_file = "{compdir}/{program.main_module.name}._build.sh"
end
# The Nit program compiled to C
end
f.write("#!/bin/sh\n")
- f.write("# This shell script is generated by NIT to compile the program {program.module.name}.\n")
+ f.write("# This shell script is generated by NIT to compile the program {program.main_module.name}.\n")
f.write("CLIBDIR=\"{tc.clibdir.as(not null)}\"\n")
f.write("{tc.bindir.as(not null)}/gccx {verbose} -d {compdir} -I $CLIBDIR {include_dirs.join(" ")}")
if tc.output_file != null then
f.write(" -o {tc.output_file.as(not null)}")
else if tc.ext_prefix.is_empty then
- f.write(" -o {program.module.name}")
+ f.write(" -o {program.main_module.name}")
else
- f.write(" -o {program.module.name}_{tc.ext_prefix}")
+ f.write(" -o {program.main_module.name}_{tc.ext_prefix}")
end
if tc.boost then f.write(" -O")
if not tc.cc_link then f.write(" -x \"-c\"")
if _indent_level < 0 then _indent_level = 0
end
- # The processed module
- readable var _module: MMModule
+ # The processed mmmodule
+ readable var _mmmodule: MMModule
# Where header decl are stored (public stuff)
readable writable var _header_writer: Writer
readable var _cprogram: CProgram
# Create a new CompilerVisitor based on a module
- init(module: MMModule, cp: CProgram)
+ init(mod: MMModule, cp: CProgram)
do
- _module = module
+ _mmmodule = mod
_cprogram = cp
_program = cp.program
do
var cname = _cname_cache
if cname == null then
- cname = cmangle(module.name, local_class.name, name)
+ cname = cmangle(mmmodule.name, local_class.name, name)
_cname_cache = cname
end
return cname
# Compile module and class tables
fun compile_tables_to_c(v: CompilerVisitor)
do
- for m in module.mhe.greaters_and_self do
+ for m in main_module.mhe.greaters_and_self do
m.compile_local_table_to_c(v)
end
var s = new Buffer.from("classtable_t TAG2VFT[4] = \{NULL")
for t in ["Int","Char","Bool"] do
- if module.has_global_class_named(t.to_symbol) then
+ if main_module.has_global_class_named(t.to_symbol) then
s.append(", (const classtable_t)VFT_{t}")
else
s.append(", NULL")
fun declare_class_tables_to_c(v: CompilerVisitor)
do
for c in local_classes do
- if c.global.module == self then
+ if c.global.mmmodule == self then
c.declare_tables_to_c(v)
end
end
v.add_decl("struct \{struct stack_frame_t me;\} fra;")
end
v.add_instr("fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;")
- v.add_instr("fra.me.file = LOCATE_{v.visitor.module.name};")
+ v.add_instr("fra.me.file = LOCATE_{v.visitor.mmmodule.name};")
v.add_instr("fra.me.line = {ll};")
v.add_instr("fra.me.meth = LOCATE_{v.basecname};")
v.add_instr("fra.me.has_broke = 0;")
fun do_table_computation
do
tc.info("Building tables",1)
- for m in module.mhe.greaters_and_self do
+ for m in main_module.mhe.greaters_and_self do
tc.info("Building tables for module: {m.name}",2)
m.local_analysis
end
# We have to work on ALL the classes of the module
var classes = new Array[MMLocalClass]
- for c in module.local_classes do classes.add(c)
+ for c in main_module.local_classes do classes.add(c)
classes.sort !cmp(x,y) = x.total_order_compare(y)
for c in classes do
# Assign a unique class identifier
# (negative are for primitive classes)
var gc = c.global
- var bm = gc.module
+ var bm = gc.mmmodule
if c.primitive_info != null then
cc.id = pclassid
pclassid = pclassid - 4
special AbsTableEltClass
redef fun is_related_to(c)
do
- var bc = c.module[_local_class.global]
+ var bc = c.mmmodule[_local_class.global]
return c.cshe <= bc
end
end
fun add_null_reciever_check(e: IRegister)
do
var nul = lit_null_reg
- var c = expr(new IIs(e, nul), module.type_bool)
+ var c = expr(new IIs(e, nul), mmmodule.type_bool)
var iif = new IIf(c)
stmt(iif)
var old_seq = seq
# Add a type cast (ITypeCheck + IAbort) in the current icode sequence
fun add_type_cast(e: IRegister, stype: MMType)
do
- var c = expr(new ITypeCheck(e, stype), module.type_bool)
+ var c = expr(new ITypeCheck(e, stype), mmmodule.type_bool)
var iif = new IIf(c)
stmt(iif)
var old_seq = seq
fun add_attr_check(prop: MMAttribute, e: IRegister)
do
if not prop.signature.return_type.is_nullable then
- var cond = expr(new IAttrIsset(prop, e), module.type_bool)
+ var cond = expr(new IAttrIsset(prop, e), mmmodule.type_bool)
var iif = new IIf(cond)
stmt(iif)
var seq_old = seq
# Add a localized IAbort
fun add_abort(s: String...)
do
- stmt(new IAbort(s, module))
+ stmt(new IAbort(s, mmmodule))
end
# Add an assigment to the iroutine return value
if prop.name == ne then
var eqp = prop.signature.recv.local_class.select_method(ee)
var eqcall = add_call(eqp, args, closcns).as(not null)
- return expr(new INot(eqcall), module.type_bool)
+ return expr(new INot(eqcall), mmmodule.type_bool)
end
# TODO: Inline x==y as "x is y or (x != null and (== is not the Object one) and x.==(y))"
icall.closure_defs = closcns
if prop.name == ee then
# Prepare the result
- var reg = new_register(module.type_bool)
+ var reg = new_register(mmmodule.type_bool)
# "x is y"
- var cond = expr(new IIs(args[0], args[1]), module.type_bool)
+ var cond = expr(new IIs(args[0], args[1]), mmmodule.type_bool)
var iif = new IIf(cond)
stmt(iif)
var seq_old = seq
# Do the "x != null" part iff x is nullable
if args[0].stype.is_nullable then
var nul = lit_null_reg
- cond = expr(new IIs(args[0], nul), module.type_bool)
+ cond = expr(new IIs(args[0], nul), mmmodule.type_bool)
iif = new IIf(cond)
stmt(iif)
seq = iif.then_seq
seq = iif.else_seq
end
# "x.==(y)"
- add_assignment(reg, expr(icall, module.type_bool))
+ add_assignment(reg, expr(icall, mmmodule.type_bool))
seq = seq_old
return reg
end
# Return a literal "null" value
fun lit_null_reg: IRegister
do
- return new_register(module.type_none)
+ return new_register(mmmodule.type_none)
end
# Return a literal "true" value
fun lit_true_reg: IRegister
do
var e = new IBoolValue(true)
- return expr(e, module.type_bool)
+ return expr(e, mmmodule.type_bool)
end
# Return a literal "false" value
fun lit_false_reg: IRegister
do
var e = new IBoolValue(false)
- return expr(e, module.type_bool)
+ return expr(e, mmmodule.type_bool)
end
# Get a new register
end
# The module where classes and types are extracted
- readable var _module: MMModule
+ readable var _mmmodule: MMModule
# The current iroutine build
readable var _iroutine: IRoutine
# The current sequence of icodes
readable writable var _seq: ISeq
- init(module: MMModule, r: IRoutine)
+ init(mod: MMModule, r: IRoutine)
do
- _module = module
+ _mmmodule = mod
_current_location = r.location
_iroutine = r
_seq = r.body
readable var _modules: Array[MMModule] = new Array[MMModule]
# Register a new module with the modules it depends on
- fun add_module(module: MMModule, supers: Array[MMModule])
+ fun add_module(mod: MMModule, supers: Array[MMModule])
do
- _module_hierarchy.add(module, _module_hierarchy.select_smallests(supers))
- _modules.add(module)
- module._mhe = _module_hierarchy[module]
+ _module_hierarchy.add(mod, _module_hierarchy.select_smallests(supers))
+ _modules.add(mod)
+ mod._mhe = _module_hierarchy[mod]
end
# Register a global class
readable var _modules: Map[Symbol, MMModule] = new HashMap[Symbol, MMModule]
# Register a new module
- fun add_module(module: MMModule)
+ fun add_module(mod: MMModule)
do
- assert not _modules.has_key(module.name)
- _modules[module.name] = module
+ assert not _modules.has_key(mod.name)
+ _modules[mod.name] = mod
end
init(name: Symbol, path: String, parent: nullable MMDirectory) do
end
# The module that introduces the global class
- fun module: MMModule
+ fun mmmodule: MMModule
do
- return intro.module
+ return intro.mmmodule
end
redef fun to_s
do
var sup = new Array[MMLocalClass]
for s in class_refinement_hierarchy do
- if c.module.mhe < s.module and s isa MMConcreteClass then
+ if c.mmmodule.mhe < s.mmmodule and s isa MMConcreteClass then
sup.add(s)
end
end
readable var _arity : Int
# The module of the local class
- readable var _module: MMModule
+ readable var _mmmodule: MMModule
# The global class of the local class
fun global: MMGlobalClass do return _global.as(not null)
# Create a new class with a given name and arity
protected init(mod: MMModule, name: Symbol, arity: Int)
do
- _module = mod
+ _mmmodule = mod
_name = name
_arity = arity
mod._local_classes.add(self)
fun new_global
do
var g = new MMGlobalClass(self)
- _module._global_classes.add(g)
- _module._global_class_by_name[name] = g
+ _mmmodule._global_classes.add(g)
+ _mmmodule._global_class_by_name[name] = g
set_global(g)
end
do
_global = g
_global.register_local_class(self)
- _module.register_global_class(self)
+ _mmmodule.register_global_class(self)
end
# Is there a global propery with a given name
end
# The current MMContext
- fun context: MMContext do return module.context
+ fun context: MMContext do return mmmodule.context
redef fun to_s
do
var a = self
if a == b then
return 0
- else if a.module.mhe < b.module then
+ else if a.mmmodule.mhe < b.mmmodule then
return 1
- else if b.module.mhe < a.module then
+ else if b.mmmodule.mhe < a.mmmodule then
return -1
end
var ar = a.cshe.rank
fun prhe: PartialOrderElement[MMLocalProperty] do return _prhe.as(not null)
# The module of the local property
- fun module: MMModule do return _local_class.module
+ fun mmmodule: MMModule do return _local_class.mmmodule
# Full expanded name with all qualifications
fun full_name: String
do
if _global == null then
- return "{local_class.module}::{local_class}::(?::{name})"
+ return "{local_class.mmmodule}::{local_class}::(?::{name})"
else if global.intro == self then
- return "{local_class.module}::{local_class}::{name}"
+ return "{local_class.mmmodule}::{local_class}::{name}"
else
- return "{local_class.module}::{local_class}::({global.intro.full_name})"
+ return "{local_class.mmmodule}::{local_class}::({global.intro.full_name})"
end
end
for i in [0..arity[ do
var oft = global.intro.get_formal(i)
var ft = _formals_types[i]
- ft.bound = oft.bound.for_module(module)
+ ft.bound = oft.bound.for_module(mmmodule)
end
end
return _formals_types
redef fun for_module(mod)
do
var t: MMType = self
- if module != mod then
+ if mmmodule != mod then
var parms = new Array[MMType]
for p in _params do
parms.add(p.for_module(mod))
# The position is self in def_class
readable var _position: Int
- redef fun module do return _def_class.module
+ redef fun mmmodule do return _def_class.mmmodule
redef fun for_module(mod)
do
var t: MMType = self
- if module != mod then
+ if mmmodule != mod then
t = mod[_def_class.global].get_formal(position)
end
return t
r = r.direct_type
var old_r = r.upcast_for(def_class)
#if not old_r isa MMTypeGeneric then
- # print "adapt {self}'{def_class}'{self.module} to {r}'{r.module}"
- # print " old_r = {old_r}'{old_r.module}"
+ # print "adapt {self}'{def_class}'{self.mmmodule} to {r}'{r.mmmodule}"
+ # print " old_r = {old_r}'{old_r.mmmodule}"
#end
assert old_r isa MMTypeGeneric
var reduct = old_r.params[position]
var set = new HashSet[MMLocalClass]
set.add_all(supers)
var u = set.to_a
- module.set_supers_class(self,u)
+ mmmodule.set_supers_class(self,u)
assert _crhe != null
assert _cshe != null
_computing_super = false
set.add(glob) # Add the global property
# Do not inherit constructors trough specialization
- #print "{c.module}::{c} -> {module}::{self} for {glob.local_property.local_class.module}::{glob.local_property.local_class}::{glob.local_property} : {glob.is_init}"
+ #print "{c.mmmodule}::{c} -> {mmmodule}::{self} for {glob.local_property.local_class.mmmodule}::{glob.local_property.local_class}::{glob.local_property} : {glob.is_init}"
if glob.is_init and glob.intro.local_class.global != global then
#print "pass"
continue
if _ancestors.has_key(c) then
return _ancestors[c]
end
- var a = c.for_module(module)
+ var a = c.for_module(mmmodule)
assert cshe <= a
var ra: MMAncestor
if _ancestors.has_key(a) then
private fun add_default_any_class(supers: Array[MMLocalClass])
do
if supers.is_empty and name != once ("Object".to_symbol) then
- var t_any = module.type_any
+ var t_any = mmmodule.type_any
supers.add(t_any.local_class)
var default = new MMDefaultAncestor(self, t_any)
add_direct_parent(default)
assert _crhe != null
for ref in _crhe.direct_greaters do
for sup in ref.cshe.direct_greaters do
- var cla = sup.for_module(_module)
+ var cla = sup.for_module(_mmmodule)
supers.add(cla)
end
end
# Conflict case (FIXME)
if impls2.length != 1 then
stderr.write("Fatal error: inherit_local_property error\n")
- print("------- {module}::{self} {glob.intro.full_name}")
+ print("------- {mmmodule}::{self} {glob.intro.full_name}")
for i in impls2 do
print(" {i.full_name}")
end
tab.add(self)
stype.local_class.compute_ancestors
for anc in stype.local_class.ancestors.as(not null) do
- var aaa = anc.stype.for_module(stype.module)
- var a = aaa.adapt_to(stype).for_module(inheriter.module)
+ var aaa = anc.stype.for_module(stype.mmmodule)
+ var a = aaa.adapt_to(stype).for_module(inheriter.mmmodule)
if a.local_class != inheriter.local_class then
var it = tab.iterator
var b = true
if self == s then
return true
end
- assert _recv.module == s.recv.module
+ assert _recv.mmmodule == s.recv.mmmodule
var rt = _return_type
var srt = s.return_type
if arity != s.arity or (rt == null) != (srt == null) then return false
if _recv == r then
return self
end
- var mod = r.module
+ var mod = r.mmmodule
var p = new Array[MMType]
for i in _params do
p.add(i.for_module(mod).adapt_to(r))
fun inheriter: MMType do return _inheriter.as(not null)
fun is_reffinement: Bool do
- return stype.module != stype.module
+ return stype.mmmodule != stype.mmmodule
end
fun is_specialisation: Bool do
# Note that static type a related to a specific module
abstract class MMType
# The module where self makes sence
- fun module: MMModule is abstract
+ fun mmmodule: MMModule is abstract
# The local class that self direclty or indirectly refers to
fun local_class: MMLocalClass is abstract
redef fun as_nullable do return self
init(t: MMType) do _base_type = t
- redef fun module do return _base_type.module
+ redef fun mmmodule do return _base_type.mmmodule
redef fun local_class do return _base_type.local_class
class MMTypeClass
special MMType
redef readable var _local_class: MMLocalClass
- redef fun module do return _local_class.module end
+ redef fun mmmodule do return _local_class.mmmodule end
redef fun <(t) do return t.is_supertype(self)
redef fun to_s
redef fun for_module(mod)
do
var t: MMType = self
- if module != mod then
+ if mmmodule != mod then
t = _local_class.for_module(mod).get_type
end
return t
# The type of null
class MMTypeNone
special MMType
- redef readable var _module: MMModule
+ redef readable var _mmmodule: MMModule
redef fun is_nullable: Bool do return true
redef fun <(t) do return t isa MMTypeNone or t isa MMNullableType
redef fun to_s do return "null"
redef fun as_nullable do return self
redef fun as_notnull do abort
- private init(m: MMModule) do _module = m
+ private init(m: MMModule) do _mmmodule = m
end
redef class MMModule
_recv = recv
end
- redef fun module do return _recv.module
+ redef fun mmmodule do return _recv.mmmodule
redef fun for_module(mod)
do
- if mod == module then return self
+ if mod == mmmodule then return self
return adapt_to(recv.for_module(mod))
end
protected fun parse_file(context: ToolContext, file: IFStream, filename: String, module_name: Symbol, dir: MMDirectory): MODULE is abstract
# Process a parsed module
- protected fun process_metamodel(context: ToolContext, module: MODULE) is abstract
+ protected fun process_metamodel(context: ToolContext, mod: MODULE) is abstract
end
redef class MMModule
f.close
end
- # Currently computed module
- readable var _module: nullable MMSrcModule
+ # Currently computed mmmodule
+ readable var _mmmodule: nullable MMSrcModule
# Is the current directory module computed as a simple modude ?
readable writable var _inside_mode: Bool = false
do
_entities.add(e)
if e isa MMSrcModule then
- _module = e
+ _mmmodule = e
end
end
fun extract_other_doc
do
info("Generating other files",1)
- _module = null
+ _mmmodule = null
inside_mode = false
intrude_mode = false
clear
add("<a href=\"overview.html\"><b>Overview</b></a> <a href=\"index-1.html\"><b>Index</b></a> <a href=\"index.html\" target=\"_top\"><b>With Frames</b></a>\n")
add("</td></tr></table>")
add("Visibility: ")
- var module = module
- if (not inside_mode and not intrude_mode) or module == null then
+ var mod = mmmodule
+ if (not inside_mode and not intrude_mode) or mod == null then
add("<b>Public</b> ")
else
- add("<a href=\"{module}.html\"><b>Public</b></a> ")
+ add("<a href=\"{mod}.html\"><b>Public</b></a> ")
end
- if inside_mode or module == null then
+ if inside_mode or mod == null then
add("<b>Inside</b> ")
- else if module.directory.owner != module then
+ else if mod.directory.owner != mod then
add("<strike><b>Inside</b></strike> ")
else
- add("<a href=\"{module}_.html\"><b>Inside</b></a> ")
+ add("<a href=\"{mod}_.html\"><b>Inside</b></a> ")
end
- if intrude_mode or module == null then
+ if intrude_mode or mod == null then
add("<b>Intrude</b> ")
else
- add("<a href=\"{module}__.html\"><b>Intrude</b></a> ")
+ add("<a href=\"{mod}__.html\"><b>Intrude</b></a> ")
end
add("<br/>")
end
# if inside_mode is set, it could be a different result
fun known_owner_of(m: MMModule): MMModule
do
- var module = module
- if module == null then return m
- var res = module.known_owner_of(m)
- if not inside_mode and not intrude_mode and res.directory.owner == module then
- return module
+ var mod = mmmodule
+ if mod == null then return m
+ var res = mod.known_owner_of(m)
+ if not inside_mode and not intrude_mode and res.directory.owner == mod then
+ return mod
else
return res
end
redef class MMModule
special MMEntity
redef fun html_link(dctx) do
- if dctx.module == self then
+ if dctx.mmmodule == self then
return "{self}"
else
return "<a href=\"{self}.html\">{self}</a>"
var _known_owner_of_cache: Map[MMModule, MMModule] = new HashMap[MMModule, MMModule]
# Return the owner of `module` from the point of view of `self`
- fun known_owner_of(module: MMModule): MMModule
+ fun known_owner_of(mod: MMModule): MMModule
do
- if _known_owner_of_cache.has_key(module) then return _known_owner_of_cache[module]
- var res = module
+ if _known_owner_of_cache.has_key(mod) then return _known_owner_of_cache[mod]
+ var res = mod
# is module is publicly imported by self?
- if mhe < module and visibility_for(module) != 0 then
- res = known_owner_of_intern(module, self, false)
+ if mhe < mod and visibility_for(mod) != 0 then
+ res = known_owner_of_intern(mod, self, false)
else
# Return the canonnical owner of module from the point of view of self
- res = module.owner(self)
+ res = mod.owner(self)
end
- _known_owner_of_cache[module] = res
+ _known_owner_of_cache[mod] = res
return res
end
end
# ???
- private fun known_owner_of_intern(module: MMModule, from: MMModule, as_owner: Bool): MMModule
+ private fun known_owner_of_intern(mod: MMModule, from: MMModule, as_owner: Bool): MMModule
do
- if module == self then return self
+ if mod == self then return self
var candidates = new Array[MMModule]
for m in explicit_imported_modules do
if from.visibility_for(m) == 0 then continue
- if not m.mhe <= module then continue
- candidates.add(m.known_owner_of_intern(module, from, true))
+ if not m.mhe <= mod then continue
+ candidates.add(m.known_owner_of_intern(mod, from, true))
end
# FIXME: I do not know what this does
- if candidates.is_empty then return module.owner(from)
+ if candidates.is_empty then return mod.owner(from)
var max = candidates.first
for m in candidates do
if max.mhe < m then max = m
redef fun html_link(dctx)
do
- var m = module
- if not need_doc(dctx) then m = global.intro.module
+ var m = mmmodule
+ if not need_doc(dctx) then m = global.intro.mmmodule
m = dctx.known_owner_of(m)
- if m == dctx.module then
+ if m == dctx.mmmodule then
return "<a href=\"#{html_anchor}\">{self}</a>"
else
return "<a href=\"{m}.html#{html_anchor}\">{self}</a>"
redef fun locate(dctx)
do
- return "in {module.html_link(dctx)}::{local_class.html_link(dctx)}"
+ return "in {mmmodule.html_link(dctx)}::{local_class.html_link(dctx)}"
end
fun known_intro_class(dctx: DocContext): MMLocalClass
do
- var mod = dctx.known_owner_of(global.intro.local_class.module)
+ var mod = dctx.known_owner_of(global.intro.local_class.mmmodule)
var cla = mod[global.intro.local_class.global]
return cla
end
if is_redef then
var gp = global.intro
if intro_class.global != local_class.global then
- res.append(" {module[intro_class.global].html_link(dctx)}::")
- else if intro_class.module != module then
- res.append(" {intro_class.module.html_link(dctx)}::")
+ res.append(" {mmmodule[intro_class.global].html_link(dctx)}::")
+ else if intro_class.mmmodule != mmmodule then
+ res.append(" {intro_class.mmmodule.html_link(dctx)}::")
end
end
return res.to_s
do
if global.visibility_level >= 3 or self isa MMAttribute then
if not dctx.intrude_mode then return false
- if dctx.module.visibility_for(module) == 0 then return false
+ if dctx.mmmodule.visibility_for(mmmodule) == 0 then return false
end
if global.intro == self then
return true
redef fun html_link(dctx)
do
- var m = module
- if not need_doc(dctx) then m = global.module
+ var m = mmmodule
+ if not need_doc(dctx) then m = global.mmmodule
m = dctx.known_owner_of(m)
- if m == dctx.module then
+ if m == dctx.mmmodule then
return "<a href=\"#{html_anchor}\">{self}</a>"
else
return "<a href=\"{m}.html#{html_anchor}\">{self}</a>"
redef fun doc do return global.intro.doc
redef fun need_doc(dctx) do
- if module == dctx.module then
+ if mmmodule == dctx.mmmodule then
for m in dctx.owned_modules do
if m.global_classes.has(global) then
var c = m[global]
return false
end
- redef fun locate(dctx) do return "in {module.html_link(dctx)}"
+ redef fun locate(dctx) do return "in {mmmodule.html_link(dctx)}"
- fun known_intro(dctx: DocContext): MMLocalClass do return dctx.known_owner_of(global.intro.module)[global]
+ fun known_intro(dctx: DocContext): MMLocalClass do return dctx.known_owner_of(global.intro.mmmodule)[global]
redef fun prototype_head(dctx)
do
if is_redef then res.append("redef ")
if global.visibility_level == 3 then res.append("private ")
res.append("class ")
- if is_redef then res.append("{ki.module.html_link(dctx)}::")
+ if is_redef then res.append("{ki.mmmodule.html_link(dctx)}::")
return res.to_s
end
# Extract the doc of a class
fun extract_class_doc(dctx: DocContext)
do
- dctx.add("<a name=\"{html_anchor}\"></a><h2>{self}</h2><small>{module.html_link(dctx)}::</small><br/>{prototype_head(dctx)}<b>{self}</b>{prototype_body(dctx)}\n")
+ dctx.add("<a name=\"{html_anchor}\"></a><h2>{self}</h2><small>{mmmodule.html_link(dctx)}::</small><br/>{prototype_head(dctx)}<b>{self}</b>{prototype_body(dctx)}\n")
dctx.add("<blockquote>\n")
dctx.add("<dl>\n")
var sup2 = new Array[String]
- var intro_module = dctx.known_owner_of(global.module)
- if intro_module != module then
+ var intro_module = dctx.known_owner_of(global.mmmodule)
+ if intro_module != mmmodule then
dctx.add("<dt>Refine {self} from: <dd>{intro_module.html_link(dctx)}\n")
sup2.clear
var mods = new Array[MMModule]
for c in crhe.greaters do
if c.need_doc(dctx) then
- var km = dctx.known_owner_of(c.module)
- if km != module and km != intro_module and not mods.has(km) then
+ var km = dctx.known_owner_of(c.mmmodule)
+ if km != mmmodule and km != intro_module and not mods.has(km) then
mods.add(km)
end
end
end
for c in crhe.linear_extension do
- if mods.has(c.module) then sup2.add(c.module.html_link(dctx))
+ if mods.has(c.mmmodule) then sup2.add(c.mmmodule.html_link(dctx))
end
if not sup2.is_empty then dctx.add("<dt>Previous refinements in: <dd>{sup2.join(", ")}\n")
end
sup2.clear
for c in crhe.smallers do
c.compute_super_classes
- for c2 in c.module.local_classes do
+ for c2 in c.mmmodule.local_classes do
if not c2 isa MMConcreteClass then continue
c2.compute_super_classes
c2.compute_ancestors
end
sup2.clear
for c in crhe.order do
- if not module.mhe <= c.module and c.need_doc(dctx) then
- sup2.add(c.module.html_link(dctx))
+ if not mmmodule.mhe <= c.mmmodule and c.need_doc(dctx) then
+ sup2.add(c.mmmodule.html_link(dctx))
end
end
if not sup2.is_empty then
var new_props = new Array[MMLocalProperty]
for g in global_properties do
if not accept_prop(g.intro, pass) then continue
- if module.visibility_for(g.intro.module) < g.visibility_level then continue
+ if mmmodule.visibility_for(g.intro.mmmodule) < g.visibility_level then continue
var p = self[g]
if p.local_class != self or not p.need_doc(dctx) then
var cla = new Array[MMLocalClass]
var mmap = new HashMap[MMModule, Array[MMLocalProperty]]
for c in che.greaters do
if c isa MMSrcLocalClass then
- var km = dctx.known_owner_of(c.module)
+ var km = dctx.known_owner_of(c.mmmodule)
var kc = km[c.global]
if kc == self then continue
var props: Array[MMLocalProperty]
- if km == module then
+ if km == mmmodule then
if cmap.has_key(kc) then
props = cmap[kc]
else
dctx.open_stage
dctx.stage("<tr bgcolor=\"#EEEEFF\"><th colspan=\"2\"><small>Imported {passname}</small></th><tr>\n")
- for m in module.mhe.linear_extension do
+ for m in mmmodule.mhe.linear_extension do
if not mmap.has_key(m) then continue
var props = mmap[m]
if props.is_empty then continue
var mmap = new HashMap[MMModule, Array[MMLocalProperty]]
for c in crhe.order do
- if module.mhe <= c.module or dctx.owned_modules.has(c.module) or not c isa MMSrcLocalClass then continue
- var km = dctx.known_owner_of(c.module)
- if module.mhe <= km then continue
+ if mmmodule.mhe <= c.mmmodule or dctx.owned_modules.has(c.mmmodule) or not c isa MMSrcLocalClass then continue
+ var km = dctx.known_owner_of(c.mmmodule)
+ if mmmodule.mhe <= km then continue
var kc = km[c.global]
var props: Array[MMLocalProperty]
if mmap.has_key(km) then
dctx.open_stage
dctx.stage("<tr bgcolor=\"#EEEEFF\"><th colspan=\"2\"><small>Added {passname} in known modules</small></th><tr>\n")
for c in crhe.order do
- var m = c.module
+ var m = c.mmmodule
if not mmap.has_key(m) then continue
var props = mmap[m]
if props.is_empty then continue
dctx.open_stage
for p in new_props do
- dctx.add("<a name=\"{p.html_anchor}\"></a><h3>{p}</h3><p><small>{p.module.html_link(dctx)}::{p.local_class.html_link(dctx)}::</small><br/>{p.prototype_head(dctx)} <b>{p.name}</b>{p.prototype_body(dctx)}</p>\n")
+ dctx.add("<a name=\"{p.html_anchor}\"></a><h3>{p}</h3><p><small>{p.mmmodule.html_link(dctx)}::{p.local_class.html_link(dctx)}::</small><br/>{p.prototype_head(dctx)} <b>{p.name}</b>{p.prototype_body(dctx)}</p>\n")
dctx.add("<blockquote>")
var doc = p.doc
if doc != null then
if not properties.is_empty then
var s: String
if heir.global == global then
- s = module.html_link(dctx)
+ s = mmmodule.html_link(dctx)
else
s = self.html_link(dctx)
end
do
if global.visibility_level >= 3 then
if not dctx.intrude_mode then return false
- if dctx.module.visibility_for(module) == 0 then return false
+ if dctx.mmmodule.visibility_for(mmmodule) == 0 then return false
end
if global.intro == self then
return true
var i = ctypes.iterator
while i.is_ok do
var n = i.key
- if module.has_global_class_named(n) then
- var c = module.class_by_name(n)
+ if mmmodule.has_global_class_named(n) then
+ var c = mmmodule.class_by_name(n)
if cshe < c then
_primitive_info_cache = i.item
_primitive_info_b = true
readable var _tc: ToolContext
# This module is the 'main' module, the one where we find the 'main' method
- readable var _module: MMModule
+ readable var _main_module: MMModule
# This method is the entry point of this program
# There might be no entry point (if in fact we are compiling a library)
# start using all the classes
private fun finish_processing_classes do
var classes = new Array[MMLocalClass]
- for c in module.local_classes do
+ for c in main_module.local_classes do
c.compute_super_classes
classes.add(c)
end
fun compute_main_method do
# Check for the 'Sys' class
var sysname = once "Sys".to_symbol
- if not module.has_global_class_named(sysname) then return
- var sys = module.class_by_name(sysname)
+ if not main_module.has_global_class_named(sysname) then return
+ var sys = main_module.class_by_name(sysname)
# Check for 'Sys::main' method
var entryname = once "main".to_symbol
# Generation of allocation function of this class
fun generate_allocation_iroutines
do
- for c in module.local_classes do
+ for c in main_module.local_classes do
var pi = c.primitive_info
if pi == null then
do
var iself = new IRegister(c.get_type)
var iselfa = [iself]
var iroutine = new IRoutine(iselfa, null)
- var icb = new ICodeBuilder(module, iroutine)
+ var icb = new ICodeBuilder(main_module, iroutine)
for g in c.global_properties do
if not g.intro isa MMAttribute then continue
var iself = new IRegister(c.get_type)
var iselfa = [iself]
var iroutine = new IRoutine(iselfa, null)
- var icb = new ICodeBuilder(module, iroutine)
+ var icb = new ICodeBuilder(main_module, iroutine)
for g in c.global_properties do
if not g.intro isa MMAttribute then continue
var p = c[g]
for i in [0..p.signature.arity[ do iparams.add(new IRegister(p.signature[i]))
var iroutine = new IRoutine(iparams, iself)
iroutine.location = p.iroutine.location
- var icb = new ICodeBuilder(module, iroutine)
+ var icb = new ICodeBuilder(main_module, iroutine)
var inew = new IAllocateInstance(c.get_type)
inew.result = iself
fun with_each_iroutines
!action(i: IRoutine, m: MMModule)
do
- for m in module.mhe.greaters_and_self do
+ for m in main_module.mhe.greaters_and_self do
for c in m.local_classes do
var iroutine: nullable IRoutine = null
fun with_each_methods
!action(m: MMMethod)
do
- for m in module.mhe.greaters_and_self do
+ for m in main_module.mhe.greaters_and_self do
for c in m.local_classes do
# Process methods and attributes initialization
for p in c.local_local_properties do
fun with_each_live_local_classes
!action(m: MMLocalClass)
do
- for c in module.local_classes do
+ for c in main_module.local_classes do
action(c)
end
end
init(m: MMModule, toolcontext: ToolContext) do
- _module = m
+ _main_module = m
_tc = toolcontext
finish_processing_classes
end
init(visitor: AbsSyntaxVisitor, r: IRoutine, m: nullable MMMethod)
do
- super(visitor.module, r)
+ super(visitor.mmmodule, r)
_visitor = visitor
_return_seq = r.body
_return_value = r.result
# Compare left and null
var n = v.lit_null_reg
- var c = v.expr(new IIs(e, n), v.module.type_bool)
+ var c = v.expr(new IIs(e, n), v.mmmodule.type_bool)
var iif = new IIf(c)
v.stmt(iif)
var old_seq = v.seq
# Compute specialization relation
for c in local_classes do
- if visibility_for(c.global.intro.module) < c.global.visibility_level then
+ if visibility_for(c.global.intro.mmmodule) < c.global.visibility_level then
continue
end
c.compute_super_classes
redef class APackagedecl
redef fun accept_class_builder(v)
do
- if n_id.to_symbol != v.module.name then
- v.error(n_id, "Error: Package name missmatch between {v.module.name} and {n_id.to_symbol}")
+ if n_id.to_symbol != v.mmmodule.name then
+ v.error(n_id, "Error: Package name missmatch between {v.mmmodule.name} and {n_id.to_symbol}")
end
end
end
redef fun accept_class_builder(v)
do
var local_class: MMSrcLocalClass
- var mod = v.module
+ var mod = v.mmmodule
var local_classes = mod.src_local_classes
if (local_classes.has_key(name)) then
local_class = local_classes[name]
# Redef
- glob.check_visibility(v, self, v.module)
+ glob.check_visibility(v, self, v.mmmodule)
if n_kwredef == null then
v.error(self, "Redef error: {name} is an imported class. Add the redef keyword to refine it.")
return
var o = c.global.intro
if c == o then
if n_type == null then
- _formal.bound = v.module.type_any.as_nullable
+ _formal.bound = v.mmmodule.type_any.as_nullable
else
var stype = n_type.get_stype(v)
if stype == null then return
_formal.bound = stype
end
else
- var ob = o.get_formal(_formal.position).bound.for_module(v.module)
+ var ob = o.get_formal(_formal.position).bound.for_module(v.mmmodule)
if n_type == null then
_formal.bound = ob
else
end
var s = prop.signature
- #print "process {prop.local_class.module}::{prop.local_class}::{prop} from global {prop.global.local_property.local_class.module}::{prop.global.local_property.local_class}::{prop.global.local_property}"
+ #print "process {prop.local_class.mmmodule}::{prop.local_class}::{prop} from global {prop.global.local_property.local_class.mmmodule}::{prop.global.local_property.local_class}::{prop.global.local_property}"
for i in prop.prhe.direct_greaters do
var ip = i.local_class[prop.global]
var isig = i.signature.adaptation_to(v.local_class.get_type)
if visibility_level != 1 and glob.visibility_level != visibility_level then
v.error(self, "Redef error: {prop.local_class}::{prop} redefinition cannot change visibility.")
end
- glob.check_visibility(v, self, v.module, true)
+ glob.check_visibility(v, self, v.mmmodule, true)
end
end
ename = n_extern.text
ename = ename.substring(1, ename.length-2)
else
- ename = "{method.module.name}_{method.local_class.name}_{method.local_class.name}_{method.name}_{method.signature.arity}"
+ ename = "{method.mmmodule.name}_{method.local_class.name}_{method.local_class.name}_{method.name}_{method.signature.arity}"
end
method.extern_name = ename
end
end
# Add the finalizer to the closure signature
- var finalize_sig = new MMSignature(new Array[MMType], null, v.module.type_any) # FIXME should be no receiver
+ var finalize_sig = new MMSignature(new Array[MMType], null, v.mmmodule.type_any) # FIXME should be no receiver
var finalizer_clos = new MMClosure(once ("break".to_symbol), finalize_sig, false, true)
sig.closures.add(finalizer_clos)
var node_module = node_tree.n_base
assert node_module != null
var module_loc = new Location.with_file(filename)
- var module = new MMSrcModule(context, node_module, dir, name, module_loc)
- return module
+ var mod = new MMSrcModule(context, node_module, dir, name, module_loc)
+ return mod
end
- redef fun process_metamodel(context, module)
+ redef fun process_metamodel(context, mod)
do
- module.process_supermodules(context)
- context.info("Syntax analysis for module: {module.name}", 2)
- module.process_syntax(context)
+ mod.process_supermodules(context)
+ context.info("Syntax analysis for module: {mod.name}", 2)
+ mod.process_syntax(context)
end
init do end
redef class MMGlobalClass
# Check that a module can access a class
fun check_visibility(v: AbsSyntaxVisitor, n: ANode, cm: MMSrcModule): Bool do
- var pm = intro.module
+ var pm = intro.mmmodule
assert pm isa MMSrcModule
var vpm = cm.visibility_for(pm)
if vpm == 3 then
class MMSrcLocalClass
special MMConcreteClass
# The first related AST node (if any)
- fun node: nullable AClassdef do return module.nodes(self).as(nullable AClassdef)
+ fun node: nullable AClassdef do return mmmodule.nodes(self).as(nullable AClassdef)
# Concrete NIT source generic formal parameter by name
readable var _formal_dict: Map[Symbol, MMTypeFormalParameter] = new HashMap[Symbol, MMTypeFormalParameter]
redef class MMGlobalProperty
# Check that a module can access a property
fun check_visibility(v: AbsSyntaxVisitor, n: ANode, cm: MMSrcModule, allows_protected: Bool): Bool do
- var pm = local_class.module
+ var pm = local_class.mmmodule
assert pm isa MMSrcModule
var vpm = cm.visibility_for(pm)
if vpm == 3 then
# Concrete NIT source attribute
class MMSrcAttribute
special MMAttribute
- redef fun node: nullable AAttrPropdef do return module.nodes(self).as(nullable AAttrPropdef)
+ redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
super(name, cla)
- cla.module.nodes(self) = n
+ cla.mmmodule.nodes(self) = n
end
end
# Concrete NIT source method for an automatic accesor
class MMAttrImplementationMethod
special MMSrcMethod
- redef fun node: nullable AAttrPropdef do return module.nodes(self).as(nullable AAttrPropdef)
+ redef fun node: nullable AAttrPropdef do return mmmodule.nodes(self).as(nullable AAttrPropdef)
init(name: Symbol, cla: MMLocalClass, n: AAttrPropdef)
do
super(name, cla)
- cla.module.nodes(self) = n
+ cla.mmmodule.nodes(self) = n
end
end
redef readable var _is_intern: Bool
redef readable var _is_abstract: Bool
redef readable writable var _extern_name: nullable String # Will be computed during MMBuilder
- redef fun node: nullable AMethPropdef do return module.nodes(self).as(nullable AMethPropdef)
+ redef fun node: nullable AMethPropdef do return mmmodule.nodes(self).as(nullable AMethPropdef)
init(name: Symbol, cla: MMLocalClass, n: nullable AMethPropdef)
do
super(name, cla)
- cla.module.nodes(self) = n
+ cla.mmmodule.nodes(self) = n
_is_init = node isa AConcreteInitPropdef
_is_intern = node isa AInternMethPropdef
_is_abstract = node isa ADeferredMethPropdef
special Visitor
fun get_type_by_name(clsname: Symbol): MMType
do
- if not _module.has_global_class_named(clsname) then _tc.fatal_error(_module.location, "Missing necessary class: \"{clsname}\"")
- var cls = _module.class_by_name(clsname)
+ if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
+ var cls = _mmmodule.class_by_name(clsname)
return cls.get_type
end
fun get_instantiated_type_by_name(clsname: Symbol, vtype: Array[MMType]): MMType
do
- if not _module.has_global_class_named(clsname) then _tc.fatal_error(_module.location, "Missing necessary class: \"{clsname}\"")
- var cls = _module.class_by_name(clsname)
+ if not _mmmodule.has_global_class_named(clsname) then _tc.fatal_error(_mmmodule.location, "Missing necessary class: \"{clsname}\"")
+ var cls = _mmmodule.class_by_name(clsname)
return cls.get_instantiate_type(vtype)
end
# The primitive type of null
fun type_none: MMType
do
- return _module.type_none
+ return _mmmodule.type_none
end
fun get_method(recv: MMType, name: Symbol): MMMethod
end
# The current module
- readable var _module: MMSrcModule
+ readable var _mmmodule: MMSrcModule
# The current class
fun local_class: MMSrcLocalClass do return _local_class.as(not null)
return stype
end
- protected init(tc: ToolContext, module: MMSrcModule)
+ protected init(tc: ToolContext, mmmodule: MMSrcModule)
do
_tc = tc
- _module = module
+ _mmmodule = mmmodule
end
end
fun get_local_class(v: AbsSyntaxVisitor): nullable MMLocalClass
do
var name = n_id.to_symbol
- var mod = v.module
+ var mod = v.mmmodule
var cla = v.local_class
if cla.formal_dict.has_key(name) or cla.has_global_property_by_name(name) then
_stype_cached = true
var name = n_id.to_symbol
- var mod = v.module
+ var mod = v.mmmodule
var cla = v.local_class
var t: nullable MMType
# Number of nested once
readable writable var _once_count: Int = 0
- init(tc, module) do super
+ init(tc, mod) do super
private fun get_default_constructor_for(n: ANode, c: MMLocalClass, prop: MMSrcMethod): nullable MMMethod
do
var cur_c: nullable MMLocalClass = null
if i < l then
cur_m = explicit_super_init_calls[i]
- cur_c = cur_m.global.intro.local_class.for_module(v.module)
+ cur_c = cur_m.global.intro.local_class.for_module(v.mmmodule)
end
var j = 0
while j < v.local_class.cshe.direct_greaters.length do
i += 1
if i < l then
cur_m = explicit_super_init_calls[i]
- cur_c = cur_m.global.intro.local_class.for_module(v.module)
+ cur_c = cur_m.global.intro.local_class.for_module(v.mmmodule)
else
cur_m = null
cur_c = null
return null
end
var prop = lc.select_method(name)
- prop.global.check_visibility(v, self, v.module, false)
+ prop.global.check_visibility(v, self, v.mmmodule, false)
var psig = prop.signature_for(type_lvalue)
_assign_method = prop
if not v.check_conform_expr(n_value, psig[0].not_for_self) then return null
var stype: nullable MMType = null
for prop in precs do
assert prop isa MMMethod
- var t = prop.signature_for(v.self_var.stype.as(not null)).return_type.for_module(v.module).adapt_to(v.local_property.signature.recv)
+ var t = prop.signature_for(v.self_var.stype.as(not null)).return_type.for_module(v.mmmodule).adapt_to(v.local_property.signature.recv)
stypes.add(t)
if stype == null or stype < t then
stype = t
return
end
var prop = lc.select_attribute(name)
- if v.module.visibility_for(prop.global.local_class.module) < 3 then
- v.error(self, "Error: Attribute {name} from {prop.global.local_class.module} is invisible in {v.module}")
+ if v.mmmodule.visibility_for(prop.global.local_class.mmmodule) < 3 then
+ v.error(self, "Error: Attribute {name} from {prop.global.local_class.mmmodule} is invisible in {v.mmmodule}")
end
_prop = prop
var at = prop.signature_for(type_recv).return_type
# Get the signature for a local property and a receiver
private fun get_signature(v: TypingVisitor, type_recv: MMType, prop: MMMethod, recv_is_self: Bool): MMSignature
do
- prop.global.check_visibility(v, self, v.module, recv_is_self)
+ prop.global.check_visibility(v, self, v.mmmodule, recv_is_self)
var psig = prop.signature_for(type_recv)
if not recv_is_self then psig = psig.not_for_self
return psig
if parent != v.top_block and self != v.top_block then
v.error(self, "Error: Constructor invocation {property} must not be in nested block.")
end
- var cla = v.module[property.global.intro.local_class.global]
+ var cla = v.mmmodule[property.global.intro.local_class.global]
var prev_class: nullable MMLocalClass = null
var esic = v.explicit_super_init_calls.as(not null)
if not esic.is_empty then