warmUpNamespaces method

void warmUpNamespaces()

Trigger eager initialization for all HTVariables and HTNamedStructs within nsp that have lazy-initialization bytecode (ip != null) but haven't been initialized yet (_value == null).

This must be called while the interpreter is not evaluating any expression — typically during module loading when the stack is clean.

Implementation

void warmUpNamespaces() {
  for (final nsp in _currentBytecodeModule.namespaces.values) {
    for (final entry in nsp.symbols.entries) {
      final decl = entry.value;
      if (decl is HTVariable) {
        decl.initialize();
      } else if (decl is HTNamedStruct) {
        decl.initialize();
      }
    }
    for (final entry in nsp.importedSymbols.entries) {
      final decl = entry.value;
      if (decl is HTVariable) {
        decl.initialize();
      } else if (decl is HTNamedStruct) {
        decl.initialize();
      }
    }
  }
}