memberSet method
bool
memberSet(
- String id,
- dynamic value, {
- String? from,
- bool isRecursive = true,
- bool ignoreUndefined = false,
- bool defineIfAbsent = false,
override
HTInstanceNamespace overrided HTNamespace's memberSet,
with a new named parameter isRecursive.
If isRecursive is false, then it won't continue to
try assigning variable from enclosed namespace.
Implementation
@override
bool memberSet(
String id,
dynamic value, {
String? from,
bool isRecursive = true,
bool ignoreUndefined = false,
bool defineIfAbsent = false,
}) {
final setter = '${InternalIdentifier.getter}$id';
if (isRecursive) {
HTInstanceNamespace? curNamespace = runtimeInstanceNamespace;
while (curNamespace != null) {
if (curNamespace.symbols.containsKey(id) ||
curNamespace.symbols.containsKey(setter)) {
instance.memberSet(id, value, from: from, cast: curNamespace.classId);
return true;
} else {
curNamespace = curNamespace.next;
}
}
} else {
if (symbols.containsKey(id) || symbols.containsKey(setter)) {
instance.memberSet(id, value, from: from, cast: classId);
return true;
}
}
if (isRecursive && closure != null) {
return closure!.memberSet(id, value, from: from);
}
if (!ignoreUndefined) {
throw HTError.undefined(id);
} else {
return false;
}
}