| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library compiler; | 5 library compiler; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:package_config/packages.dart'; | 8 import 'package:package_config/packages.dart'; |
| 9 import 'src/apiimpl.dart'; | 9 import 'compiler_new.dart' as new_api; |
| 10 import 'src/old_to_new_api.dart'; |
| 10 | 11 |
| 11 // Unless explicitly allowed, passing [:null:] for any argument to the | 12 // Unless explicitly allowed, passing [:null:] for any argument to the |
| 12 // methods of library will result in an Error being thrown. | 13 // methods of library will result in an Error being thrown. |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * Returns a future that completes to the source corresponding to [uri]. | 16 * Returns a future that completes to the source corresponding to [uri]. |
| 16 * If an exception occurs, the future completes with this exception. | 17 * If an exception occurs, the future completes with this exception. |
| 17 * | 18 * |
| 18 * The source can be represented either as a [:List<int>:] of UTF-8 bytes or as | 19 * The source can be represented either as a [:List<int>:] of UTF-8 bytes or as |
| 19 * a [String]. | 20 * a [String]. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 Uri script, | 107 Uri script, |
| 107 Uri libraryRoot, | 108 Uri libraryRoot, |
| 108 Uri packageRoot, | 109 Uri packageRoot, |
| 109 CompilerInputProvider inputProvider, | 110 CompilerInputProvider inputProvider, |
| 110 DiagnosticHandler handler, | 111 DiagnosticHandler handler, |
| 111 [List<String> options = const [], | 112 [List<String> options = const [], |
| 112 CompilerOutputProvider outputProvider, | 113 CompilerOutputProvider outputProvider, |
| 113 Map<String, dynamic> environment = const {}, | 114 Map<String, dynamic> environment = const {}, |
| 114 Uri packageConfig, | 115 Uri packageConfig, |
| 115 PackagesDiscoveryProvider packagesDiscoveryProvider]) { | 116 PackagesDiscoveryProvider packagesDiscoveryProvider]) { |
| 116 if (!libraryRoot.path.endsWith("/")) { | 117 |
| 117 throw new ArgumentError("libraryRoot must end with a /"); | 118 new_api.CompilerOptions compilerOptions = new new_api.CompilerOptions( |
| 118 } | 119 entryPoint: script, |
| 119 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | 120 libraryRoot: libraryRoot, |
| 120 throw new ArgumentError("packageRoot must end with a /"); | 121 packageRoot: packageRoot, |
| 121 } | 122 packageConfig: packageConfig, |
| 122 // TODO(ahe): Consider completing the future with an exception if | 123 packagesDiscoveryProvider: packagesDiscoveryProvider, |
| 123 // code is null. | 124 options: options, |
| 124 Compiler compiler = new Compiler(inputProvider, | 125 environment: environment); |
| 125 outputProvider, | 126 |
| 126 handler, | 127 new_api.CompilerInput compilerInput = new LegacyCompilerInput(inputProvider); |
| 127 libraryRoot, | 128 new_api.CompilerDiagnostics compilerDiagnostics = |
| 128 packageRoot, | 129 new LegacyCompilerDiagnostics(handler); |
| 129 options, | 130 new_api.CompilerOutput compilerOutput = |
| 130 environment, | 131 new LegacyCompilerOutput(outputProvider); |
| 131 packageConfig, | 132 |
| 132 packagesDiscoveryProvider); | 133 return new_api.compile(compilerOptions, compilerInput, |
| 133 return compiler.run(script).then((bool success) { | 134 compilerDiagnostics, compilerOutput) |
| 134 return new CompilationResult(compiler, isSuccess: success); | 135 .then((new_api.CompilationResult result) { |
| 136 return new CompilationResult(result.compiler, isSuccess: result.isSuccess); |
| 135 }); | 137 }); |
| 136 } | 138 } |
| 137 | 139 |
| 138 /** | 140 /** |
| 139 * Kind of diagnostics that the compiler can report. | 141 * Kind of diagnostics that the compiler can report. |
| 140 */ | 142 */ |
| 141 class Diagnostic { | 143 class Diagnostic { |
| 142 /** | 144 /** |
| 143 * An error as identified by the "Dart Programming Language | 145 * An error as identified by the "Dart Programming Language |
| 144 * Specification" [http://www.dartlang.org/docs/spec/]. | 146 * Specification" [http://www.dartlang.org/docs/spec/]. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 final String name; | 202 final String name; |
| 201 | 203 |
| 202 /** | 204 /** |
| 203 * This constructor is not private to support user-defined | 205 * This constructor is not private to support user-defined |
| 204 * diagnostic kinds. | 206 * diagnostic kinds. |
| 205 */ | 207 */ |
| 206 const Diagnostic(this.ordinal, this.name); | 208 const Diagnostic(this.ordinal, this.name); |
| 207 | 209 |
| 208 String toString() => name; | 210 String toString() => name; |
| 209 } | 211 } |
| OLD | NEW |