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