AstModuleLoader class
Lookup-only module resolver for pre-parsed AST bundles.
AstModuleLoader implements ModuleContext to resolve import directives against a pre-loaded map of modules. It performs no file I/O and no source code parsing — all modules must already exist in the bundle.
Module Resolution Order
When loadModule is called with a URI:
- Cache — return if already loaded
- dart:* — register the corresponding stdlib and return empty module
- Bridged libraries — register native bridges and return empty module
- Bundle modules — look up in modules, process AST → environment
- Error — throw if URI not found anywhere
Usage
Typically created internally by D4rtRunner.executeBundle — not constructed directly in user code.
final loader = AstModuleLoader(
modules: bundle.modules,
globalEnvironment: env,
runner: runner,
);
- Implemented types
Constructors
-
AstModuleLoader({required Map<
String, SCompilationUnit> modules, required Environment globalEnvironment, required D4rtRunner runner}) - Creates an AstModuleLoader for resolving imports from a bundle.
Properties
- currentLibrary ↔ Uri?
-
The current library URI being executed.
getter/setter pairoverride
- globalEnvironment → Environment
-
The global environment shared across all modules.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
modules
→ Map<
String, SCompilationUnit> -
Pre-parsed modules from the bundle, keyed by URI string.
final
- runner → D4rtRunner
-
The D4rtRunner that owns this loader — used for bridge lookups
and permission checks.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkPermission(
dynamic operation) → bool -
Checks if a permission is granted for the given operation.
override
-
loadModule(
Uri uri, {Set< String> ? showNames, Set<String> ? hideNames}) → LoadedModule -
Loads a module from the given URI.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited