executeAsync method

Future<Object?> executeAsync({
  1. required SCompilationUnit ast,
  2. String name = 'main',
  3. List<Object?>? positionalArgs,
  4. Map<String, Object?>? namedArgs,
  5. D4rtExecutionHooks? hooks,
})

Runs execute and settles its result: an entry point that returns a Future (an async main) is awaited, so the host always receives the final native value. A synchronous entry point's value comes back unchanged. The script's error — thrown synchronously or by the Future — fails the returned Future, as execute would have thrown it.

The arguments mean what they mean on execute.

Implementation

Future<Object?> executeAsync({
  required SCompilationUnit ast,
  String name = 'main',
  List<Object?>? positionalArgs,
  Map<String, Object?>? namedArgs,
  D4rtExecutionHooks? hooks,
}) async {
  final Object? result = execute(
    ast: ast,
    name: name,
    positionalArgs: positionalArgs,
    namedArgs: namedArgs,
    hooks: hooks,
  );
  return result is Future ? await result : result;
}