private var object_type_cache: nullable MClassType
+ # The type `Pointer`, super class to all extern classes
+ var pointer_type: MClassType = self.get_primitive_class("Pointer").mclass_type is lazy
+
# The primitive type `Bool`
fun bool_type: MClassType
do
return get_primitive_class("Sys").mclass_type
end
+ fun finalizable_type: nullable MClassType
+ do
+ var clas = self.model.get_mclasses_by_name("Finalizable")
+ if clas == null then return null
+ return get_primitive_class("Finalizable").mclass_type
+ end
+
# Force to get the primitive class named `name` or abort
fun get_primitive_class(name: String): MClass
do
return res
end
+ # Return the not nullable version of the type
+ # Is the type is already not nullable, then self is returned.
+ #
+ # Note: this just remove the `nullable` notation, but the result can still contains null.
+ # For instance if `self isa MNullType` or self is a a formal type bounded by a nullable type.
+ fun as_notnullable: MType
+ do
+ return self
+ end
+
private var as_nullable_cache: nullable MType = null
redef fun need_anchor do return mtype.need_anchor
redef fun as_nullable do return self
+ redef fun as_notnullable do return mtype
redef fun resolve_for(mtype, anchor, mmodule, cleanup_virtual)
do
var res = self.mtype.resolve_for(mtype, anchor, mmodule, cleanup_virtual)
fun lookup_definitions(mmodule: MModule, mtype: MType): Array[MPROPDEF]
do
assert not mtype.need_anchor
- if mtype isa MNullableType then mtype = mtype.mtype
+ mtype = mtype.as_notnullable
var cache = self.lookup_definitions_cache[mmodule, mtype]
if cache != null then return cache
fun lookup_super_definitions(mmodule: MModule, mtype: MType): Array[MPROPDEF]
do
assert not mtype.need_anchor
- if mtype isa MNullableType then mtype = mtype.mtype
+ mtype = mtype.as_notnullable
# First, select all candidates
var candidates = new Array[MPROPDEF]
fun lookup_all_definitions(mmodule: MModule, mtype: MType): Array[MPROPDEF]
do
assert not mtype.need_anchor
- if mtype isa MNullableType then mtype = mtype.mtype
+ mtype = mtype.as_notnullable
var cache = self.lookup_all_definitions_cache[mmodule, mtype]
if cache != null then return cache
# therefore, you should use `is_init_for` the verify if the property is a legal constructor for a given class
var is_init: Bool writable = false
+ # The constructor is a (the) root init with empty signature but a set of initializers
+ var is_root_init: Bool writable = false
+
# The the property a 'new' contructor?
var is_new: Bool writable = false
# The signature attached to the property definition
var msignature: nullable MSignature writable = null
+ # The signature attached to the `new` call on a root-init
+ # This is a concatenation of the signatures of the initializers
+ #
+ # REQUIRE `mproperty.is_root_init == (new_msignature != null)`
+ var new_msignature: nullable MSignature writable = null
+
+ # List of initialisers to call in root-inits
+ #
+ # They could be setters or attributes
+ #
+ # REQUIRE `mproperty.is_root_init == (new_msignature != null)`
+ var initializers = new Array[MProperty]
+
# Is the method definition abstract?
var is_abstract: Bool writable = false