ModuleLoader class

Implemented types

Constructors

ModuleLoader(Environment globalEnvironment, Map<String, String> sources, List<Map<String, LibraryEnum>> bridgedEnumDefinitions, List<Map<String, LibraryClass>> bridgedClases, {D4rt? d4rt, List<Map<String, LibraryFunction>> libraryFunctions = const [], List<Map<String, LibraryVariable>> libraryVariables = const [], List<Map<String, LibraryGetter>> libraryGetters = const [], List<Map<String, LibrarySetter>> librarySetters = const [], List<Map<String, LibraryExtension>> bridgedExtensions = const [], bool collectRegistrationErrors = false, SCompilationUnit parseSourceCallback(String sourceCode, Uri uri)?, String? basePath, bool allowFileSystemImports = false})

Properties

accumulatedRegistrationErrors → List<String>
Accumulated registration errors when collectRegistrationErrors is true.
final
allowFileSystemImports → bool
DGUB3 (mirrors tom_d4rt DFUB1) — when true, _fetchModuleSource may read a module's source from the filesystem (via _resolveFileSystemUri) if the URI is not already in sources and the resolved file exists. Defaults to false (sandboxed: only preloaded sources and bridged/stdlib modules are visible). Every such read is gated by _checkFileSystemSourceReadPermission.
final
basePath → String?
DGUB3 (mirrors tom_d4rt DFUB1) — base directory for resolving relative filesystem imports.
final
bridgedClases → List<Map<String, LibraryClass>>
final
bridgedEnumDefinitions → List<Map<String, LibraryEnum>>
final
bridgedExtensions → List<Map<String, LibraryExtension>>
final
callStack → D4rtCallStack
The interpreted call stack of the run this loader serves (woneprpd153).
latefinal
collectRegistrationErrors ↔ bool
When true, registration errors are collected instead of thrown.
getter/setter pair
currentLibrary ↔ Uri?
The current library URI being executed.
getter/setter pairoverride
d4rt → D4rt?
final
executionContext ↔ D4rtExecutionContext?
The run this loader loads for when the execution has hooks (GitHub #19): its onImport sees every library once. (Its permission set is consulted by D4rt.checkPermission, from the run's Zone.)
getter/setter pair
globalEnvironment → Environment
The global environment shared across all modules.
final
hashCode → int
The hash code for this object.
no setterinherited
initialFileSystemLibraryUri → Uri?
DGUB3 (mirrors tom_d4rt DFUB1) — the URI the interpreter should treat as the initial library when the root source was supplied inline (no explicit library:) and filesystem imports are enabled.
no setter
isLoadingModules → bool
Whether a module load is in progress, i.e. names a module declares may not be visible yet to a module of the same import cycle.
no setteroverride
libraryFunctions → List<Map<String, LibraryFunction>>
final
libraryGetters → List<Map<String, LibraryGetter>>
final
librarySetters → List<Map<String, LibrarySetter>>
final
libraryVariables → List<Map<String, LibraryVariable>>
final
loadedModuleCount → int
Step #3 (retention) — number of source modules currently parsed and cached in _moduleCache (each entry holds a parsed unit). Read-only introspection so D4rt can assert that prior runs' ASTs are not accumulated. Bridged-module envs (which carry no user AST) are not counted.
no setter
loadedSourceModuleCount → int
How many SOURCE modules (file: URIs, the entry script included) this loader holds — what a script runner reports as sourcesLoaded. Stdlib and bridged modules are cached here too and are not counted.
no setter
parseSourceCallback → SCompilationUnit Function(String sourceCode, Uri uri)?
Callback for parsing source code into an SAstNode tree. When provided, this is used to convert raw source strings into SCompilationUnit nodes. When null, the module loader can only work with pre-parsed AST input.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scriptEnvironment → Environment
The scope the entry script's own declarations live in, enclosing globalEnvironment: the script sees everything registered there (the stdlib, bridges, what its imports bring in), while a loaded module, whose environment encloses globalEnvironment too, does not see the script (ghissues14: a library that named something it neither declares nor imports found a same-named script declaration).
latefinal
sources → Map<String, String>
final

Methods

checkPermission(dynamic operation) → bool
Checks if a permission is granted for the given operation.
override
deferUntilModulesLoaded(void resolve()) → bool
Runs resolve once the outermost load returns, because it needs a name that is not declared yet (a supertype or type-parameter bound in a library still loading - an import cycle, or a barrel that has not reached the export declaring it). Returns false when no module load is in progress: then the name is genuinely undefined and the caller reports it.
override
libraryUnit(Uri uri, SCompilationUnit unit) → SCompilationUnit
The module unit at uri as a LIBRARY: its parts merged in, the Dart rules for parts checked (tom_d4rt's ModuleLoader.parseLibrary, tom_d4rt_ast's AstModuleLoader.libraryUnit).
loadModule(Uri uri, {Set<String>? showNames, Set<String>? hideNames}) → LoadedModule
Loads a module from the given URI.
override
loadModuleInternal(Uri uri, {Set<String>? showNames, Set<String>? hideNames}) → LoadedModule
Internal implementation that returns the full LoadedModule with environment.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordEntrySource(SCompilationUnit unit, String source) → void
Makes the entry script unit, parsed from source, locatable.
releaseLoadedModules() → void
Step #3 (retention) — drops the per-loader parsed-module cache so a finished run's parsed units become collectable. Only the per-loader _moduleCache is cleared; the process-global shared bridge caches hold no per-run state and are untouched. A subsequent execute re-parses and re-populates _moduleCache as usual.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited