initialize method

void initialize()

Initialize this variable with its declared initializer bytecode

Implementation

void initialize() {
  if (ip != null) {
    if (!_isInitializing) {
      _isInitializing = true;
      final initVal = interpreter.execute(
        propagateValue: false,
        context: HTContext(
          file: file,
          module: module,
          ip: ip!,
          namespace: closure,
          line: line,
          column: column,
        ),
      );
      _value = initVal;
      _isInitialized = true;
      _isInitializing = false;
    } else {
      throw HTError.circleInit(id!);
    }
  } else {
    _value = null;
  }

  // optimize variable access by storing the value directly in the namespace
  if (isMutable &&
      !isExternal &&
      !isConst &&
      !lateFinalize &&
      classId == null &&
      identical(_closure.symbols[id!], this)) {
    _closure.symbols[id!] = _value;
  }
}