memberGet method
Get a value of a static member from this HTClass.
Implementation
@override
dynamic memberGet(String varName, {String? from, bool throws = true}) {
final getter = '${InternalIdentifier.getter}$varName';
final constructor = '${InternalIdentifier.namedConstructorPrefix}$varName';
// if (isExternal && !internal) {
// final value =
// externalClass!.memberGet(varName != id ? '$id.$varName' : varName);
// return value;
// } else {
if (namespace.symbols.containsKey(varName)) {
final decl = namespace.symbols[varName]!;
if (decl.isPrivate &&
from != null &&
!from.startsWith(namespace.fullName)) {
throw HTError.privateMember(varName);
}
if (isExternal) {
decl.resolve();
return decl.value;
} else {
if (decl.isStatic ||
(decl is HTFunction &&
decl.category == FunctionCategory.constructor)) {
decl.resolve();
return decl.value;
}
}
} else if (namespace.symbols.containsKey(getter)) {
final decl = namespace.symbols[getter]!;
if (decl.isPrivate &&
from != null &&
!from.startsWith(namespace.fullName)) {
throw HTError.privateMember(varName);
}
final func = decl as HTFunction;
if (isExternal) {
decl.resolve();
return func.call();
} else {
if (decl.isStatic) {
decl.resolve();
return func.call();
}
}
} else if (namespace.symbols.containsKey(constructor)) {
final decl = namespace.symbols[constructor]!.value;
if (decl.isPrivate &&
from != null &&
!from.startsWith(namespace.fullName)) {
throw HTError.privateMember(varName);
}
decl.resolve();
final func = decl as HTFunction;
return func;
}
// }
if (throws) {
throw HTError.undefined(varName,
filename: interpreter.currentFileName,
line: interpreter.currentLine,
column: interpreter.currentColumn);
}
}