frontend: handle multi-iterators
[nit.git] / src / rapid_type_analysis.nit
index 365f6a4..a87a48f 100644 (file)
@@ -82,6 +82,10 @@ class RapidTypeAnalysis
        # Live methods.
        var live_methods = new HashSet[MMethod]
 
+       # Live mmodules.
+       # Those with a live method definitions (see `live_methoddefs`)
+       var live_mmodules = new HashSet[MModule]
+
        # Live callsites.
        var live_callsites = new HashSet[CallSite]
 
@@ -209,11 +213,16 @@ class RapidTypeAnalysis
 
                # Force primitive types
                force_alive("Bool")
-               force_alive("Int")
                force_alive("Float")
                force_alive("Char")
                force_alive("Pointer")
                force_alive("Byte")
+               force_alive("Int")
+               force_alive("Int8")
+               force_alive("Int16")
+               force_alive("UInt16")
+               force_alive("Int32")
+               force_alive("UInt32")
 
                while not todo.is_empty do
                        var mmethoddef = todo.shift
@@ -389,6 +398,7 @@ class RapidTypeAnalysis
        do
                if live_methoddefs.has(mpropdef) then return
                live_methoddefs.add(mpropdef)
+               live_mmodules.add(mpropdef.mclassdef.mmodule)
                todo.add(mpropdef)
 
                var mproperty = mpropdef.mproperty
@@ -530,14 +540,7 @@ redef class AExpr
        end
 end
 
-redef class AIntExpr
-       redef fun accept_rapid_type_visitor(v)
-       do
-               allocate_mtype(v)
-       end
-end
-
-redef class AByteExpr
+redef class AIntegerExpr
        redef fun accept_rapid_type_visitor(v)
        do
                allocate_mtype(v)
@@ -578,7 +581,7 @@ redef class AStringFormExpr
        do
                var native = v.analysis.mainmodule.native_string_type
                v.add_type(native)
-               var prop = v.get_method(native, "to_s_with_length")
+               var prop = v.get_method(native, "to_s_full")
                v.add_monomorphic_send(native, prop)
        end
 end
@@ -696,7 +699,7 @@ redef class ASuperExpr
        end
 end
 
-redef class AForExpr
+redef class AForGroup
        redef fun accept_rapid_type_visitor(v)
        do
                v.add_callsite(self.method_iterator)