memberSet method
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 varName, dynamic varValue,
{String? from, bool isRecursive = true, bool throws = true}) {
final setter = '${InternalIdentifier.getter}$varName';
if (isRecursive) {
HTInstanceNamespace? curNamespace = runtimeInstanceNamespace;
while (curNamespace != null) {
if (curNamespace.symbols.containsKey(varName) ||
curNamespace.symbols.containsKey(setter)) {
instance.memberSet(varName, varValue,
from: from, cast: curNamespace.classId);
return true;
} else {
curNamespace = curNamespace.next;
}
}
} else {
if (symbols.containsKey(varName) || symbols.containsKey(setter)) {
instance.memberSet(varName, varValue, from: from, cast: classId);
return true;
}
}
if (isRecursive && closure != null) {
return closure!.memberSet(varName, varValue, from: from);
}
if (throws) {
throw HTError.undefined(varName);
} else {
return false;
}
}