From: Jean Privat Date: Mon, 21 Jul 2014 19:58:45 +0000 (-0400) Subject: modelize_property: add annotation `lazy` X-Git-Tag: v0.6.7~30^2~8 X-Git-Url: http://nitlanguage.org modelize_property: add annotation `lazy` Signed-off-by: Jean Privat --- diff --git a/src/modelize_property.nit b/src/modelize_property.nit index 96ec598..9c269d5 100644 --- a/src/modelize_property.nit +++ b/src/modelize_property.nit @@ -645,10 +645,14 @@ redef class AAttrPropdef # Is the node tagged `noinit`? var noinit = false + # Is the node taggeg lazy? + var is_lazy = false + # The associated getter (read accessor) if any var mreadpropdef: nullable MMethodDef writable # The associated setter (write accessor) if any var mwritepropdef: nullable MMethodDef writable + redef fun build_property(modelbuilder, mclassdef) do var mclass = mclassdef.mclass @@ -718,6 +722,14 @@ redef class AAttrPropdef modelbuilder.mpropdef2npropdef[mreadpropdef] = self mreadpropdef.mdoc = mpropdef.mdoc + var atlazy = self.get_single_annotation("lazy", modelbuilder) + if atlazy != null then + if n_expr == null then + modelbuilder.error(atlazy, "Error: a lazy attribute needs a value") + end + is_lazy = true + end + var atreadonly = self.get_single_annotation("readonly", modelbuilder) if atreadonly != null then if n_expr == null then