mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:07:49 +00:00
db5d9ffc16
`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>
54 lines
1.8 KiB
Dart
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);
|
|
});
|
|
}
|