dart-sdk/pkg/compiler/lib/compiler_api_unmigrated.dart
Stephen Adams db5d9ffc16 [dart2js] Migrate common.dart
`diagnostic_listener.dart` is the last unmigrated import of
`common.dart`, which is imported in ~100 files.

`compiler_api.dart` is split to move the `compile` method with
unmigrated dependencies to another file to allow `compiler_api.dart` to
become migrated. Luckily there is only one reference to `compile`.

We no longer allow null `SourceSpan`s and use `SourceSpan.unknown()`
instead.

Added `SpannableWithEntity` as a migrated interface that `HInstruction`
can implement to break the dependency on a large unmigrated ssa library.

Change-Id: I0a5ff6e6c36a34ff55d98f634c671bb8f1fb9e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242161
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-04-23 03:13:59 +00:00

54 lines
1.8 KiB
Dart

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.10
library compiler_api_migrated;
import 'dart:async';
import 'src/compiler.dart' show Compiler;
import 'src/options.dart' show CompilerOptions;
import 'compiler_api.dart';
// Unless explicitly allowed, passing [:null:] for any argument to the
// methods of library will result in an Error being thrown.
/// Returns a future that completes to a [CompilationResult] when the Dart
/// sources in [options] have been compiled.
///
/// The generated compiler output is obtained by providing a [compilerOutput].
///
/// If the compilation fails, the future's `CompilationResult.isSuccess` is
/// `false` and [CompilerDiagnostics.report] on [compilerDiagnostics]
/// is invoked at least once with `kind == Diagnostic.ERROR` or
/// `kind == Diagnostic.CRASH`.
Future<CompilationResult> compile(
CompilerOptions compilerOptions,
CompilerInput compilerInput,
CompilerDiagnostics compilerDiagnostics,
CompilerOutput compilerOutput) {
if (compilerOptions == null) {
throw new ArgumentError("compilerOptions must be non-null");
}
if (compilerInput == null) {
throw new ArgumentError("compilerInput must be non-null");
}
if (compilerDiagnostics == null) {
throw new ArgumentError("compilerDiagnostics must be non-null");
}
if (compilerOutput == null) {
throw new ArgumentError("compilerOutput must be non-null");
}
var compiler = Compiler(
compilerInput, compilerOutput, compilerDiagnostics, compilerOptions);
return compiler.run().then((bool success) {
return new CompilationResult(compiler,
isSuccess: success,
kernelInitializedCompilerState: compiler.initializedCompilerState);
});
}