# limitations under the License.
# Compute importation of classes and inheritance of properties
-package inheritance
+module inheritance
intrude import static_type
return c_name.get_type
end
+ # Root of then extern class hierarchy
+ fun type_any_extern : MMType
+ do
+ var c_name = class_by_name(once ("Pointer".to_symbol))
+ return c_name.get_type
+ end
+
# Import global classes from supermodules
fun import_global_classes
do
var ancestors = group_ancestors(build_ancestors)
_ancestors = new HashMap[MMLocalClass, MMAncestor]
- for set in ancestors do
+ for set in ancestors.values do
if set.length == 1 then
add_ancestor(set.first)
else
return _local_property_by_global[glob]
else if has_global_property(glob) then
return inherit_local_property(glob)
+ else if not computed_super_classes then
+ compute_super_classes
+ computed_ancestors
+ inherit_global_properties
+ assert has_global_property(glob)
+ return inherit_local_property(glob)
else
abort
end
end
# Add default super class in direct parent and in super classes if this is not the Object class
+ # Default super class is Pointer for extern types
private fun add_default_any_class(supers: Array[MMLocalClass])
do
- if supers.is_empty and name != once ("Object".to_symbol) then
- var t_any = mmmodule.type_any
- supers.add(t_any.local_class)
- var default = new MMDefaultAncestor(self, t_any)
- add_direct_parent(default)
+ if name != once ("Object".to_symbol) then
+ var has_no_top = false
+ if supers.is_empty then
+ has_no_top = true
+ else if global.is_extern then
+ has_no_top = true
+ for s in supers do
+ if s.global.is_extern then
+ has_no_top = false
+ break
+ end
+ end
+ end
+
+ if has_no_top then
+ var top_type
+ if name != once ("Pointer".to_symbol) and global.is_extern then
+ top_type = mmmodule.type_any_extern
+ else
+ top_type = mmmodule.type_any
+ end
+ supers.add(top_type.local_class)
+ var default = new MMDefaultAncestor(self, top_type)
+ add_direct_parent(default)
+ end
end
end
do
tab.add(self)
stype.local_class.compute_ancestors
- for anc in stype.local_class.ancestors.as(not null) do
+ for anc in stype.local_class.ancestors.values do
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