memberGet method
dynamic
memberGet(
- String id, {
- String? from,
- bool isRecursive = false,
- bool isPrivate = false,
- bool ignoreUndefined = false,
- bool asDeclaration = false,
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.
TODO: remove isPrivate check;
Implementation
@override
dynamic memberGet(
String id, {
String? from,
bool isRecursive = false,
bool isPrivate = false,
bool ignoreUndefined = false,
bool asDeclaration = false,
}) {
if (id == InternalIdentifier.name) {
return fullName;
}
if (symbols.containsKey(id)) {
final decl = symbols[id];
if (decl == null) return null;
if (asDeclaration) return decl;
if (decl is HTDeclaration) {
if (decl.isPrivate && from != null && !from.startsWith(fullName)) {
throw HTError.privateMember(id);
}
decl.resolve();
return decl.value;
} else {
if (lexicon.isPrivate(id) &&
from != null &&
!from.startsWith(fullName)) {
throw HTError.privateMember(id);
}
return decl;
}
} else if (importedSymbols.containsKey(id)) {
final decl = importedSymbols[id];
if (decl == null) return null;
if (decl is HTDeclaration) {
if (asDeclaration) return decl;
if (decl.isPrivate && from != null && !from.startsWith(fullName)) {
throw HTError.privateMember(id);
}
decl.resolve();
return decl.value;
} else {
if (lexicon.isPrivate(id) &&
from != null &&
!from.startsWith(fullName)) {
throw HTError.privateMember(id);
}
return decl;
}
} else if (isRecursive && (closure != null)) {
return closure!.memberGet(
id,
from: from,
isRecursive: isRecursive,
ignoreUndefined: ignoreUndefined,
asDeclaration: asDeclaration,
);
}
if (id == lexicon.idKeys) {
return symbols.keys;
} else if (id == lexicon.idValues) {
return symbols.values;
}
if (!ignoreUndefined) {
throw HTError.undefined(id);
}
}