Helper to implement a property with the given name
. This is used for
normal and computed properties. Normal properties can provide the initial
value using the initialValue
function. Computed properties ignore
initialValue
, their value is derived from the expression in the
ComputedProperty annotation that appears above the getter that uses this
helper.
readValue(Symbol name, [initialValue()]) {
var property = _properties[name];
if (property == null) {
var value;
// Dart note: most computed properties are created in advance in
// createComputedProperties, but if one computed property depends on
// another, the declaration order might matter. Rather than trying to
// register them in order, we include here also the option of lazily
// creating the property accessor on the first read.
var binding = _getBindingForComputedProperty(name);
if (binding == null) {
// normal property
value = initialValue != null ? initialValue() : null;
} else {
value = binding.value;
}
property = _properties[name] = new _PropertyAccessor(name, this, value);
}
return property.value;
}