From de5dd9fd433244cb8b478d6e8f3ec6213d414f86 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 21 Jul 2014 10:57:11 -0400 Subject: [PATCH] modelize_property: understand `noinit` annotation on attributes Signed-off-by: Jean Privat --- src/modelize_property.nit | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modelize_property.nit b/src/modelize_property.nit index 938a3a0..04e022f 100644 --- a/src/modelize_property.nit +++ b/src/modelize_property.nit @@ -18,6 +18,7 @@ module modelize_property import modelize_class +import annotation redef class ToolContext var modelize_property_phase: Phase = new ModelizePropertyPhase(self, [modelize_class_phase]) @@ -118,8 +119,17 @@ redef class ModelBuilder var mparameters = new Array[MParameter] var anode: nullable ANode = null for npropdef in nclassdef.n_propdefs do - if npropdef isa AAttrPropdef and npropdef.n_expr == null then + if npropdef isa AAttrPropdef then if npropdef.mpropdef == null then return # Skip broken attribute + var at = npropdef.get_single_annotation("noinit", self) + if at != null then + npropdef.noinit = true + if npropdef.n_expr != null then + self.error(at, "Error: `noinit` attributes cannot have an initial value") + end + continue # Skip noinit attributes + end + if npropdef.n_expr != null then continue var paramname = npropdef.mpropdef.mproperty.name.substring_from(1) var ret_type = npropdef.mpropdef.static_mtype if ret_type == null then return @@ -632,6 +642,9 @@ end redef class AAttrPropdef redef type MPROPDEF: MAttributeDef + # Is the node tagged `noinit`? + var noinit = false + # The associated getter (read accessor) if any var mreadpropdef: nullable MMethodDef writable # The associated setter (write accessor) if any -- 1.7.9.5