executeProgram method
dynamic
executeProgram(})
Runs a program from parse exactly as execute would run its source,
without parsing it again.
Like execute, this resets the global environment first; the arguments
mean what they mean there. Only a direct source string can be a program —
a root loaded by library URI goes through the module loader and stays
with execute.
Implementation
dynamic executeProgram(
D4rtProgram program, {
String name = 'main',
List<Object?>? positionalArgs,
Map<String, Object?>? namedArgs,
Map<String, String>? sources,
bool allowFileSystemImports = false,
D4rtExecutionHooks? hooks,
}) {
_moduleLoader = _initModule(
sources,
basePath: program.basePath,
allowFileSystemImports: allowFileSystemImports,
);
return _executeInEnvironment(
compilationUnit: program._unit,
executionEnvironment: _moduleLoader.scriptEnvironment,
name: name,
positionalArgs: positionalArgs,
namedArgs: namedArgs,
);
}