From 8f4950f81c4347cde1e1eff1c5fa30b752c3d259 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 23 Mar 2015 15:33:19 +0700 Subject: [PATCH] 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 --- src/compiler/separate_compiler.nit | 2 +- src/model/model.nit | 3 +++ src/modelize/modelize_property.nit | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) 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 -- 1.7.9.5