setContext method

void setContext(
  1. HTContext? context
)

Change the current context of the bytecode interpreter to a new one.

Implementation

void setContext(HTContext? context) {
  if (context == null) return;

  var libChanged = false;
  if (context.file != null) {
    _currentFile = context.file!;
  }
  if (context.module != null &&
      (_currentBytecodeModule.id != context.module)) {
    assert(cachedModules.containsKey(context.module));
    _currentBytecodeModule = cachedModules[context.module]!;
    libChanged = true;
  }
  if (context.namespace != null) {
    currentNamespace = context.namespace!;
  } else if (libChanged) {
    currentNamespace = _currentBytecodeModule.namespaces.values.last;
  }
  if (context.ip != null) {
    _currentBytecodeModule.ip = context.ip!;
  } else if (libChanged) {
    _currentBytecodeModule.ip = 0;
  }
  if (context.line != null) {
    _currentLine = context.line!;
  } else if (libChanged) {
    _currentLine = 0;
  }
  if (context.column != null) {
    _currentColumn = context.column!;
  } else if (libChanged) {
    _currentColumn = 0;
  }
  // if (context.stackFrames != null) {
  //   _stackFrames = context.stackFrames!;
  // }
}