memberGet method
dynamic
memberGet(
- String varName, {
- bool isPrivate = false,
- String? from,
- bool isRecursive = true,
- bool throws = true,
override
Fetch a value from this namespace,
Return declaration rather than actual values.
If not found and isRecursive
is true, will continue search in super namespaces.
If isRecursive
is true, means this is not a 'memberget operator' search.
Implementation
@override
dynamic memberGet(String varName,
{bool isPrivate = false,
String? from,
bool isRecursive = true,
bool throws = true}) {
final getter = '${InternalIdentifier.getter}$varName';
final externalStatic = '$id.$varName';
if (symbols.containsKey(varName)) {
final decl = symbols[varName]!;
if (decl.isPrivate && from != null && !from.startsWith(fullName)) {
throw HTError.privateMember(varName);
}
decl.resolve();
return decl.value;
} else if (symbols.containsKey(getter)) {
final decl = symbols[getter]!;
if (decl.isPrivate && from != null && !from.startsWith(fullName)) {
throw HTError.privateMember(varName);
}
decl.resolve();
return decl.value;
} else if (symbols.containsKey(externalStatic)) {
final decl = symbols[externalStatic]!;
if (decl.isPrivate && from != null && !from.startsWith(fullName)) {
throw HTError.privateMember(varName);
}
decl.resolve();
return decl.value;
}
if (isRecursive && (closure != null)) {
return closure!.memberGet(varName, from: from, isRecursive: isRecursive);
}
if (throws) {
throw HTError.undefined(varName);
}
}