package abstractmetamodel
import partial_order
+import location
# The main singleton which knows everything
class MMContext
fun add_local_class(c: MMLocalClass, sup: Array[MMLocalClass])
do
var csup = new Array[MMLocalClass]
- var csups = new Array[String]
for s in sup do
if s isa MMConcreteClass then
csup.add(s)
# 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]
# All global classes of the module (defined and imported)
- readable var _global_classes: Array[MMGlobalClass] = new Array[MMGlobalClass]
+ readable var _global_classes: Set[MMGlobalClass] = new HashSet[MMGlobalClass]
# All local classes of the module (defined and imported)
- readable var _local_classes: Array[MMLocalClass] = new Array[MMLocalClass]
+ readable var _local_classes: Set[MMLocalClass] = new HashSet[MMLocalClass]
# Class specialization hierarchy of the module.
readable var _class_specialization_hierarchy: PartialOrder[MMLocalClass] = new PartialOrder[MMLocalClass]
# 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
# Local classes are classes defined, refined or imported in a module
class MMLocalClass
# The name of the local class
- readable var _name: Symbol
+ readable var _name: Symbol
# Arity of the local class (if generic)
# FIXME: How to move this into the generic module in a sane way?
# All known global properties
readable var _global_properties: Set[MMGlobalProperty] = new HashSet[MMGlobalProperty]
+ # All locally defined local properties
+ readable var _local_local_properties: Set[MMLocalProperty] = new HashSet[MMLocalProperty]
+
# Dictionnary of global properties
var _properties_by_name: Map[Symbol, Array[MMGlobalProperty]] = new HashMap[Symbol, Array[MMGlobalProperty]]
fun register_local_property(p: MMLocalProperty)
do
_local_property_by_global[p.global] = p
+ if p.local_class == self then
+ _local_local_properties.add(p)
+ end
end
# Register a global property and associate it with its name
do
return _name.to_s
end
+
+ # Comparaison in a total order that superset the class refinement and the class specialisation relations
+ fun total_order_compare(b: MMLocalClass): Int
+ do
+ var a = self
+ if a == b then
+ return 0
+ else if a.module.mhe < b.module then
+ return 1
+ else if b.module.mhe < a.module then
+ return -1
+ end
+ var ar = a.cshe.rank
+ var br = b.cshe.rank
+ if ar > br then
+ return 1
+ else if br > ar then
+ return -1
+ else
+ return b.name.to_s <=> a.name.to_s
+ end
+ end
end
# A global property gather local properties that correspond to a same message
# Method local properties
class MMMethod
special MMLocalProperty
+ # Is the method defined with intern
+ fun is_intern: Bool is abstract
+
+ # Is the method abstract
+ fun is_abstract: Bool is abstract
+
+ # Is the method extern, if yes what is the extern_name
+ fun extern_name: nullable String is abstract
end
# Concrete local classes