registerBridges static method
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) {
// Step #17 — register deferred factory thunks (not pre-built
// BridgedClass objects): a script touching N of the M classes
// materializes ≈N (each thunk builds its class on first resolve).
final classThunks = bridgeClassThunks();
final classTypes = bridgeClassTypes();
final classSources = classSourceUris();
for (final entry in classThunks.entries) {
interpreter.registerBridgedClassLazy(
entry.key,
classTypes[entry.key]!,
entry.value,
importPath,
sourceUri: classSources[entry.key],
);
}
// Register the flattened native supertype table so
// interpreted subclasses pass subtype checks against bridged
// ancestors. Idempotent — safe to call per barrel.
BridgedClass.registerSupertypes(classSupertypes());
// 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]);
}
// GEN-107: Register library re-exports
for (final r in bridgeReExports()) {
interpreter.registerLibraryReExport(r.source, r.target, show: r.show, hide: r.hide);
}
}