InterpreterVisitor constructor
InterpreterVisitor({
- required Environment globalEnvironment,
- required ModuleContext moduleContext,
- Uri? initialLibrary,
Implementation
InterpreterVisitor({
required this.globalEnvironment,
required this.moduleContext, // Accept ModuleContext in the constructor
Uri? initialLibrary, // Optional URI for the initial source
}) : environment = globalEnvironment {
if (initialLibrary != null) {
// Sets the base URI in the ModuleContext for the initial source code.
// This is crucial for resolving relative imports in this initial source code.
moduleContext.currentLibrary = initialLibrary;
Logger.debug(
"[InterpreterVisitor] Initial source URI set in ModuleContext to: $initialLibrary",
);
}
// Initialize currentAsyncState if it's null and we are in an async context implicitly
// This might be more complex depending on how top-level async calls are handled
}