From: Jean Privat Date: Tue, 10 Feb 2015 05:04:32 +0000 (+0700) Subject: model: add MProperty::is_autoinit to identify method used as initializer X-Git-Tag: v0.7.2~12^2~5 X-Git-Url: http://nitlanguage.org model: add MProperty::is_autoinit to identify method used as initializer Signed-off-by: Jean Privat --- diff --git a/src/model/model.nit b/src/model/model.nit index 00ca5cf..f0f4ff9 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -1757,6 +1757,9 @@ abstract class MProperty # The visibility of the property var visibility: MVisibility + # Is the property usable as an initializer? + var is_autoinit = false is writable + init do intro_mclassdef.intro_mproperties.add(self) diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index 42dee1e..302020a 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -181,6 +181,7 @@ redef class ModelBuilder mparameters.add(mparameter) end initializers.add(npropdef.mpropdef.mproperty) + npropdef.mpropdef.mproperty.is_autoinit = true end if npropdef isa AAttrPropdef then if npropdef.mpropdef == null then return # Skip broken attribute @@ -190,6 +191,7 @@ redef class ModelBuilder # For autoinit attributes, call the reader to force # the lazy initialization of the attribute. initializers.add(npropdef.mreadpropdef.mproperty) + npropdef.mreadpropdef.mproperty.is_autoinit = true continue end if npropdef.has_value then continue @@ -202,9 +204,11 @@ redef class ModelBuilder if msetter == null then # No setter, it is a old-style attribute, so just add it initializers.add(npropdef.mpropdef.mproperty) + npropdef.mpropdef.mproperty.is_autoinit = true else # Add the setter to the list initializers.add(msetter.mproperty) + msetter.mproperty.is_autoinit = true end end end