memberGet method

  1. @override
dynamic memberGet(
  1. String id, {
  2. String? from,
  3. bool isRecursive = false,
  4. bool ignoreUndefined = false,
})
override

Fetch a member by the id, in the form of

object.id

id must be of String type.

Implementation

@override
dynamic memberGet(String id,
    {String? from, bool isRecursive = false, bool ignoreUndefined = false}) {
  if (externalClass != null) {
    dynamic member = externalClass!.instanceMemberGet(externalObject, id);
    if (member is Function) {
      HTClass? currentKlass = klass!;
      HTFunction? decl;
      while (decl == null && currentKlass != null) {
        decl = currentKlass.memberGet(id, ignoreUndefined: true);
        currentKlass = currentKlass.superClass;
      }
      assert(decl != null,
          'Could not find hetu declaration on external id: $typeString.$id');
      decl = decl!.clone();
      // Assign the value as if we are doing decl.resolve() here.
      decl.externalFunc = member;
      decl.instance = externalObject;
      return decl;
    } else {
      return member;
    }
  }
  if (!ignoreUndefined) {
    throw HTError.undefined(id);
  }
}