| 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;
|
| + });
|
| +}
|
|
|