model: make MClass::intro public
authorJean Privat <jean@pryen.org>
Fri, 9 Nov 2012 05:59:16 +0000 (00:59 -0500)
committerJean Privat <jean@pryen.org>
Fri, 9 Nov 2012 05:59:16 +0000 (00:59 -0500)
It is better than write `mclassdefs.first`.

Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit
src/modelbuilder.nit
src/rapid_type_analysis.nit
src/separate_compiler.nit
src/stats/model_stats.nit
src/typing.nit

index dbd16c7..635d34a 100644 (file)
@@ -295,7 +295,7 @@ class MClass
        # 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
index 1295816..ca6ed92 100644 (file)
@@ -517,7 +517,7 @@ class ModelBuilder
                                        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
index 67bd3f6..cec5e78 100644 (file)
@@ -573,7 +573,7 @@ redef class AForExpr
                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
index dd3ef1a..b7cdcf3 100644 (file)
@@ -260,7 +260,7 @@ class SeparateCompiler
        # 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]
index 37e248c..862bea6 100644 (file)
@@ -116,7 +116,7 @@ do
                                        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
index 179597c..9ff3b93 100644 (file)
@@ -928,7 +928,7 @@ redef class ARangeExpr
        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