initialize method

void initialize()

Implementation

void initialize() {
  if (_isInitialized) return;

  if (!_isInitializing) {
    _isInitializing = true;

    HTStruct static = interpreter.execute(
      propagateValue: false,
      context: HTContext(
        file: file,
        module: module,
        ip: staticDefinitionIp!,
        namespace: closure != null ? closure as HTNamespace : null,
      ),
    );
    if (closure != null) {
      if (prototypeId != null) {
        static.prototype = closure!.memberGet(prototypeId!,
            from: closure!.fullName, isRecursive: true);
      } else if (id != interpreter.lexicon.idGlobalPrototype) {
        static.prototype = interpreter.globalNamespace
            .memberGet(interpreter.lexicon.idGlobalPrototype);
      }
    }
    _self = interpreter.execute(
      propagateValue: false,
      context: HTContext(
        file: file,
        module: module,
        ip: ip!,
        namespace: closure != null ? closure as HTNamespace : null,
      ),
    );
    _self!.prototype = static;
    _self!.declaration = this;

    if (closure != null) {
      if (mixinIds.isNotEmpty) {
        for (final mixinId in mixinIds) {
          final mixinObj = closure!
              .memberGet(mixinId, from: closure!.fullName, isRecursive: true);
          static.assign(mixinObj);
        }
      }
    }
    _isInitialized = true;
    _isInitializing = false;
  } else {
    throw HTError.circleInit(id!);
  }
}