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

Unified Diff: tests/compiler/dart2js/compiler_alt.dart

Issue 824103005: Revert "Remove Compiler.assembledCode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | « tests/compiler/dart2js/backend_dart/test_helper.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/compiler_alt.dart
diff --git a/tests/compiler/dart2js/compiler_alt.dart b/tests/compiler/dart2js/compiler_alt.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5296de0802bfa42e8c72cb983282b3bf0731ae71
--- /dev/null
+++ b/tests/compiler/dart2js/compiler_alt.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2014, 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.
+
+/// Alternative compile method for dart2js commandline that stores the compiler
+/// for later inspection.
+///
+/// Use this in testing to inspect the compiler after compilation by setting
+/// the `compileFunc` variable in `package:compiler/src/dart2js.dart`
+/// to [compiler] before calling the `internalMain` function.
+
+library dart2js.alt;
+
+import 'dart:async';
+import 'package:compiler/compiler.dart';
+import 'package:compiler/src/apiimpl.dart';
+
+Compiler compiler;
+
+Future<String> 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 /");
+ }
+ if (packageRoot != null && !packageRoot.path.endsWith("/")) {
+ throw new ArgumentError("packageRoot must end with a /");
+ }
+ compiler = new Compiler(inputProvider,
+ outputProvider,
+ handler,
+ libraryRoot,
+ packageRoot,
+ options,
+ environment);
+ return compiler.run(script).then((_) {
+ String code = compiler.assembledCode;
+ if (code != null && outputProvider != null) {
+ code = ''; // Non-null signals success.
+ }
+ return code;
+ });
+}
« no previous file with comments | « tests/compiler/dart2js/backend_dart/test_helper.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698