| Index: pkg/compiler/lib/compiler.dart
|
| diff --git a/pkg/compiler/lib/compiler.dart b/pkg/compiler/lib/compiler.dart
|
| index 82b8c3b85b42f5ffd88908b3c65bb0528f7c4ca7..3db762d3e780c341f3d7b62cb0647a14350116f4 100644
|
| --- a/pkg/compiler/lib/compiler.dart
|
| +++ b/pkg/compiler/lib/compiler.dart
|
| @@ -65,6 +65,21 @@ typedef EventSink<String> CompilerOutputProvider(String name,
|
| typedef void DiagnosticHandler(Uri uri, int begin, int end,
|
| String message, Diagnostic kind);
|
|
|
| +/// Information resulting from the compilation.
|
| +class CompilationResult {
|
| + /// `true` if the compilation succeeded, that is, compilation didn't fail due
|
| + /// to compile-time errors and/or internal errors.
|
| + final bool isSuccess;
|
| +
|
| + /// The compiler object used for the compilation.
|
| + ///
|
| + /// Note: The type of [compiler] is implementation dependent and may vary.
|
| + /// Use only for debugging and testing.
|
| + final compiler;
|
| +
|
| + CompilationResult(this.compiler, {this.isSuccess: true});
|
| +}
|
| +
|
| /**
|
| * Returns a future that completes to a non-null String when [script]
|
| * has been successfully compiled.
|
| @@ -80,14 +95,15 @@ typedef void DiagnosticHandler(Uri uri, int begin, int end,
|
| * as the compiler may create multiple files to support lazy loading
|
| * of libraries.
|
| */
|
| -Future<String> compile(Uri script,
|
| - Uri libraryRoot,
|
| - Uri packageRoot,
|
| - CompilerInputProvider inputProvider,
|
| - DiagnosticHandler handler,
|
| - [List<String> options = const [],
|
| - CompilerOutputProvider outputProvider,
|
| - Map<String, dynamic> environment = const {}]) {
|
| +Future<CompilationResult> compile(
|
| + Uri script,
|
| + Uri libraryRoot,
|
| + Uri packageRoot,
|
| + CompilerInputProvider inputProvider,
|
| + DiagnosticHandler handler,
|
| + [List<String> options = const [],
|
| + CompilerOutputProvider outputProvider,
|
| + Map<String, dynamic> environment = const {}]) {
|
| if (!libraryRoot.path.endsWith("/")) {
|
| throw new ArgumentError("libraryRoot must end with a /");
|
| }
|
| @@ -103,13 +119,8 @@ Future<String> compile(Uri script,
|
| packageRoot,
|
| options,
|
| environment);
|
| - // TODO(ahe): Use the value of the future (which signals success or failure).
|
| - return compiler.run(script).then((_) {
|
| - String code = compiler.assembledCode;
|
| - if (code != null && outputProvider != null) {
|
| - code = ''; // Non-null signals success.
|
| - }
|
| - return code;
|
| + return compiler.run(script).then((bool success) {
|
| + return new CompilationResult(compiler, isSuccess: success);
|
| });
|
| }
|
|
|
|
|