fetch method

dynamic fetch(
  1. String varName, {
  2. String? moduleName,
})

Get a top level variable defined in a certain namespace.

Implementation

dynamic fetch(
  String varName, {
  String? moduleName,
}) {
  try {
    final savedModuleName = _currentBytecodeModule.id;
    HTNamespace nsp = getNamespace(moduleName: moduleName);
    final result = nsp.memberGet(varName, isRecursive: false);
    if (_currentBytecodeModule.id != savedModuleName) {
      _currentBytecodeModule = cachedModules[savedModuleName]!;
    }
    return result;
  } catch (error, stackTrace) {
    if (config.processError) {
      processError(error, stackTrace);
    } else {
      rethrow;
    }
  }
}