resolveExternal method

void resolveExternal()

resolve free external function & external struct method.

Implementation

void resolveExternal() {
  String funcName;
  if (classId != null) {
    if (category == FunctionCategory.constructor) {
      if (id == null) {
        funcName = '$classId';
      } else {
        funcName = '$classId.$id';
      }
    } else {
      if (id == null) {
        throw HTError.undefined(internalName);
      }
      if (isStatic) {
        funcName = '$classId.$id';
      } else {
        funcName = '$classId::$id';
      }
    }
  } else if (explicityNamespaceId != null) {
    if (id == null) {
      throw HTError.undefined(internalName);
    }
    funcName = '$explicityNamespaceId::$id';
  } else {
    if (id == null) {
      throw HTError.undefined(internalName);
    }
    funcName = id!;
  }
  if (classId != null && funcName.contains('::')) {
    // a external method within a normal class
    externalFunc = interpreter.fetchExternalMethod(funcName);
  } else {
    // other external function
    externalFunc = interpreter.fetchExternalFunction(funcName);
  }
}