import syntax_base
+redef class ToolContext
+ redef fun handle_property_conflict(lc, impls)
+ do
+ var location: nullable Location = null
+ if lc isa MMSrcLocalClass then
+ var node = lc.node
+ if node != null then node.location
+ end
+ #if location == null then location = lc.mmmodule.location
+ var clas = new Array[MMLocalClass]
+ for i in impls do
+ clas.add(i.local_class)
+ end
+ self.fatal_error(location, "Property inheritance conflict in class {lc} for `{impls.first.name}': conflicting properties are defined in {clas.join(", ")}")
+ end
+end
+
# Class specialization hierarchy sorter
private class CSHSorter
super AbstractSorter[MMLocalClass]
for a in unassigned_attributes do
var sig = a.signature
if sig == null then return # Broken attribute definition
- params.add( new MMParam( sig.return_type.as(not null), once "recv".to_symbol))
+ var name = a.name
+ if name.to_s.first == '_' or name.to_s.first == '@' then
+ name = a.to_s.substring_from(1).to_symbol
+ end
+ params.add(new MMParam(sig.return_type.as(not null), name))
end
signature = new MMSignature(params, null, local_class.get_type)
end
fun import_super_modules(tc: ToolContext, mod: MMSrcModule)
do
# Import super-modules
- var module_names_to_import = new Array[Symbol]
- var module_visibility = new HashMap[Symbol, Int]
+ var supers = new Array[MMModule]
var no_import: nullable AImport = null
for i in n_imports do
var n = i.module_name
if n != null then
- module_names_to_import.add(n)
- module_visibility[n] = i.visibility_level
+ var m = tc.get_module(n, mod)
+ supers.add(m)
+ mod.add_super_module(m, i.visibility_level)
else
no_import = i
end
end
if no_import != null then
- if not module_names_to_import.is_empty then
+ if not supers.is_empty then
tc.error(no_import.location, "Error: Top modules cannot import other modules.")
end
- else if module_names_to_import.is_empty then
+ else if supers.is_empty then
var stdname = once "standard".to_symbol
- module_names_to_import.add(stdname)
- module_visibility[stdname] = 1
+ var m = tc.get_module(stdname, mod)
+ supers.add(m)
+ mod.add_super_module(m, 1)
end
- mod.import_supers_modules(module_names_to_import)
-
- for mname in module_names_to_import do
- var level = module_visibility[mname]
- var m = tc.get_module(mname, mod)
- mod.add_super_module(m, level)
- end
+ tc.add_module(mod, supers)
end
end
redef class AModuledecl
redef fun accept_class_builder(v)
do
- if n_id.to_symbol != v.mmmodule.name then
- v.error(n_id, "Error: Module name mismatch between {v.mmmodule.name} and {n_id.to_symbol}")
+ if n_name.n_id.to_symbol != v.mmmodule.name then
+ v.error(n_name.n_id, "Error: Module name mismatch between {v.mmmodule.name} and {n_name.n_id.to_symbol}")
end
end
end
redef class AStdImport
redef fun module_name
do
- return n_id.to_symbol
+ return n_name.n_id.to_symbol
end
redef fun visibility_level
do