registerBridges static method

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

Registers all bridges with an interpreter.

importPath is the package import path that D4rt scripts will use to access these classes (e.g., 'package:tom_build/tom.dart').

Implementation

static void registerBridges(D4rt interpreter, String importPath) {
  // Register bridged classes with source URIs for deduplication
  final classes = bridgeClasses();
  final classSources = classSourceUris();
  for (final bridge in classes) {
    interpreter.registerBridgedClass(bridge, importPath, sourceUri: classSources[bridge.name]);
  }

  // Register bridged enums with source URIs for deduplication
  final enums = bridgedEnums();
  final enumSources = enumSourceUris();
  for (final enumDef in enums) {
    interpreter.registerBridgedEnum(enumDef, importPath, sourceUri: enumSources[enumDef.name]);
  }

  // Register global variables
  registerGlobalVariables(interpreter, importPath);

  // Register global functions with source URIs for deduplication
  final funcs = globalFunctions();
  final funcSources = globalFunctionSourceUris();
  final funcSigs = globalFunctionSignatures();
  for (final entry in funcs.entries) {
    interpreter.registertopLevelFunction(entry.key, entry.value, importPath, sourceUri: funcSources[entry.key], signature: funcSigs[entry.key]);
  }

  // Register bridged extensions with source URIs for deduplication
  final extensions = bridgedExtensions();
  final extSources = extensionSourceUris();
  for (final extDef in extensions) {
    final extKey = extDef.name ?? '<unnamed>@${extDef.onTypeName}';
    interpreter.registerBridgedExtension(extDef, importPath, sourceUri: extSources[extKey]);
  }

  // Register function typedefs for type resolution
  final typedefs = functionTypedefs();
  for (final name in typedefs) {
    interpreter.registerFunctionTypedef(name, importPath);
  }
}