sepcomp: do not generate class tables for dead classes
authorJean Privat <jean@pryen.org>
Mon, 23 Mar 2015 08:33:19 +0000 (15:33 +0700)
committerJean Privat <jean@pryen.org>
Sat, 28 Mar 2015 02:12:35 +0000 (09:12 +0700)
exceptions are pimitive types and classes that have a `new` factory

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

src/compiler/separate_compiler.nit
src/model/model.nit
src/modelize/modelize_property.nit

index ac9897c..555c220 100644 (file)
@@ -386,7 +386,7 @@ class SeparateCompiler
                method_tables = new HashMap[MClass, Array[nullable MPropDef]]
                attr_tables = new HashMap[MClass, Array[nullable MProperty]]
                for mclass in mclasses do
-                       #if mclass.kind == abstract_kind or mclass.kind == interface_kind then continue
+                       if not mclass.has_new_factory and (mclass.kind == abstract_kind or mclass.kind == interface_kind) then continue
                        if rta != null and not rta.live_classes.has(mclass) then continue
 
                        var mtype = mclass.intro.bound_mtype
index b483543..b9b484a 100644 (file)
@@ -468,6 +468,9 @@ class MClass
        end
 
        private var get_mtype_cache = new HashMap[Array[MType], MGenericType]
+
+       # Is there a `new` factory to allow the pseudo instantiation?
+       var has_new_factory = false is writable
 end
 
 
index a4d1141..bb0184f 100644 (file)
@@ -735,6 +735,7 @@ redef class AMethPropdef
                        end
                        mprop.is_init = is_init
                        mprop.is_new = n_kwnew != null
+                       if mprop.is_new then mclassdef.mclass.has_new_factory = true
                        if parent isa ATopClassdef then mprop.is_toplevel = true
                        self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mprop)
                else