It is better than write `mclassdefs.first`.
Signed-off-by: Jean Privat <jean@pryen.org>
# Warning: the introduction is the first `MClassDef' object associated
# to self. If self is just created without having any associated
# definition, this method will abort
- private fun intro: MClassDef
+ fun intro: MClassDef
do
assert has_a_first_definition: not mclassdefs.is_empty
return mclassdefs.first
bounds.add(objectclass.mclass_type.as_nullable)
else
# Inherit the bound
- bounds.add(mclass.mclassdefs.first.bound_mtype.arguments[i])
+ bounds.add(mclass.intro.bound_mtype.arguments[i])
end
end
end
var colltype = self.coltype.as(not null)
var itmeth = v.get_method(colltype, "iterator")
v.add_send(recvtype, itmeth)
- var iteratortype = itmeth.intro.msignature.return_mtype.as(MClassType).mclass.mclassdefs.first.bound_mtype
+ var iteratortype = itmeth.intro.msignature.return_mtype.as(MClassType).mclass.intro.bound_mtype
var objtype = v.get_class("Object").mclass_type
v.add_send(objtype, v.get_method(iteratortype, "is_ok"))
if self.variables.length == 1 then
# In a true separate compiler (a with dynamic loading) you cannot do this unfortnally
fun compile_class_to_c(mclass: MClass)
do
- var mtype = mclass.mclassdefs.first.bound_mtype
+ var mtype = mclass.intro.bound_mtype
var c_name = mclass.mclass_type.c_name
var vft = self.method_tables[mclass]
if p.mpropdefs.length == 1 then
npas += 1
else
- var sels = p.lookup_definitions(main, c.mclassdefs.first.bound_mtype)
+ var sels = p.lookup_definitions(main, c.intro.bound_mtype)
if sels.length > 1 then
print "conflict for {p.full_name} in class {c.full_name}: {sels.join(", ")}"
else if sels.is_empty then
do
var discrete_class = v.get_mclass(self, "Discrete")
if discrete_class == null then return # Forward error
- var discrete_type = discrete_class.mclassdefs.first.bound_mtype
+ var discrete_type = discrete_class.intro.bound_mtype
var t1 = v.visit_expr_subtype(self.n_expr, discrete_type)
var t2 = v.visit_expr_subtype(self.n_expr2, discrete_type)
if t1 == null or t2 == null then return