Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Unified Diff: pkg/compiler/lib/compiler.dart

Issue 832363002: Remove Compiler.assembledCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | pkg/compiler/lib/src/compiler.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/compiler.dart
diff --git a/pkg/compiler/lib/compiler.dart b/pkg/compiler/lib/compiler.dart
index 82b8c3b85b42f5ffd88908b3c65bb0528f7c4ca7..100153dd85b9f990bb384222179d1681b6819da7 100644
--- a/pkg/compiler/lib/compiler.dart
+++ b/pkg/compiler/lib/compiler.dart
@@ -65,6 +65,30 @@ 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.
floitsch 2015/01/05 10:39:33 Specify that "succeeded" means "valid program" and
Johnni Winther 2015/01/05 13:54:10 Done.
+ 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;
+
+ /// The compilation resulted in this exception.
+ final exception;
+
+ /// The compilation resulted in an exception with this stack trace.
+ final trace;
+
+ CompilationResult(this.compiler, {this.isSuccess: true})
+ : exception = null, trace = null;
+
+ CompilationResult.error(this.exception, this.trace)
+ : compiler = null, isSuccess = false;
+}
+
/**
* Returns a future that completes to a non-null String when [script]
* has been successfully compiled.
@@ -80,14 +104,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 +128,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);
});
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | pkg/compiler/lib/src/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698