registerGlobalVariables static method

void registerGlobalVariables(
  1. D4rt interpreter,
  2. String importPath
)

Registers all global variables with the interpreter.

importPath is the package import path for library-scoped registration. Collects all registration errors and throws a single exception with all error details if any registrations fail.

Implementation

static void registerGlobalVariables(D4rt interpreter, String importPath) {
  final errors = <String>[];

  try {
    interpreter.registerGlobalVariable('cliLibrary', $tom_d4rt_dcli_2.cliLibrary, importPath, sourceUri: 'package:tom_d4rt_dcli/src/api/cli_bridge.dart');
  } catch (e) {
    errors.add('Failed to register variable "cliLibrary": $e');
  }
  try {
    interpreter.registerGlobalVariable('cliGlobalHolder', $tom_d4rt_dcli_2.cliGlobalHolder, importPath, sourceUri: 'package:tom_d4rt_dcli/src/api/cli_bridge.dart');
  } catch (e) {
    errors.add('Failed to register variable "cliGlobalHolder": $e');
  }
  interpreter.registerGlobalGetter('verificationFailures', () => $tom_d4rt_dcli_8.verificationFailures, importPath, sourceUri: 'package:tom_d4rt_dcli/src/api/cli_test_utils.dart');

  if (errors.isNotEmpty) {
    throw StateError('Bridge registration errors (cli_api):\n${errors.join("\n")}');
  }
}