From: Jean Privat Date: Mon, 23 Mar 2015 08:33:19 +0000 (+0700) Subject: sepcomp: do not generate class tables for dead classes X-Git-Tag: v0.7.3~2^2 X-Git-Url: http://nitlanguage.org sepcomp: do not generate class tables for dead classes exceptions are pimitive types and classes that have a `new` factory Signed-off-by: Jean Privat --- diff --git a/src/compiler/separate_compiler.nit b/src/compiler/separate_compiler.nit index ac9897c..555c220 100644 --- a/src/compiler/separate_compiler.nit +++ b/src/compiler/separate_compiler.nit @@ -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 diff --git a/src/model/model.nit b/src/model/model.nit index b483543..b9b484a 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -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 diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index a4d1141..bb0184f 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -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