execute method
dynamic
execute({
- required SCompilationUnit ast,
- String name = 'main',
- List<
Object?> ? positionalArgs, - Map<
String, Object?> ? namedArgs, - D4rtExecutionHooks? hooks,
Execute an AST.
ast The parsed SCompilationUnit to execute.
name The function to call (default: 'main').
positionalArgs Positional arguments to pass to the function.
namedArgs Named arguments to pass to the function.
Returns the result of the function call.
Implementation
dynamic execute({
required SCompilationUnit ast,
String name = 'main',
List<Object?>? positionalArgs,
Map<String, Object?>? namedArgs,
D4rtExecutionHooks? hooks,
}) {
// Initialize fresh environment
final executionEnvironment = _initEnvironment();
final run = _createRun(hooks, 'execute:$name');
// Create module context with permission checking
final moduleContext = NoOpModuleContext(
globalEnvironment: executionEnvironment,
permissionChecker: run?.checkPermission ?? checkPermission,
);
// Execute
return _executeInEnvironment(
run: run,
compilationUnit: ast,
executionEnvironment: executionEnvironment,
moduleContext: moduleContext,
name: name,
positionalArgs: positionalArgs,
namedArgs: namedArgs,
);
}