| 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 'implementation/apiimpl.dart'; | 8 import 'implementation/apiimpl.dart'; |
| 9 | 9 |
| 10 // Unless explicitly allowed, passing [:null:] for any argument to the | 10 // Unless explicitly allowed, passing [:null:] for any argument to the |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 * Deprecated: if no [outputProvider] is given, the future completes | 78 * Deprecated: if no [outputProvider] is given, the future completes |
| 79 * to the compiled script. This behavior will be removed in the future | 79 * to the compiled script. This behavior will be removed in the future |
| 80 * as the compiler may create multiple files to support lazy loading | 80 * as the compiler may create multiple files to support lazy loading |
| 81 * of libraries. | 81 * of libraries. |
| 82 */ | 82 */ |
| 83 Future<String> compile(Uri script, | 83 Future<String> compile(Uri script, |
| 84 Uri libraryRoot, | 84 Uri libraryRoot, |
| 85 Uri packageRoot, | 85 Uri packageRoot, |
| 86 CompilerInputProvider inputProvider, | 86 CompilerInputProvider inputProvider, |
| 87 DiagnosticHandler handler, | 87 DiagnosticHandler handler, |
| 88 [List<String> options = const [], | 88 [List<String> options = const [], |
| 89 CompilerOutputProvider outputProvider]) { | 89 CompilerOutputProvider outputProvider, |
| 90 Map<String, dynamic> environment = const {}]) { |
| 90 if (!libraryRoot.path.endsWith("/")) { | 91 if (!libraryRoot.path.endsWith("/")) { |
| 91 throw new ArgumentError("libraryRoot must end with a /"); | 92 throw new ArgumentError("libraryRoot must end with a /"); |
| 92 } | 93 } |
| 93 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | 94 if (packageRoot != null && !packageRoot.path.endsWith("/")) { |
| 94 throw new ArgumentError("packageRoot must end with a /"); | 95 throw new ArgumentError("packageRoot must end with a /"); |
| 95 } | 96 } |
| 96 // TODO(ahe): Consider completing the future with an exception if | 97 // TODO(ahe): Consider completing the future with an exception if |
| 97 // code is null. | 98 // code is null. |
| 98 Compiler compiler = new Compiler(inputProvider, | 99 Compiler compiler = new Compiler(inputProvider, |
| 99 outputProvider, | 100 outputProvider, |
| 100 handler, | 101 handler, |
| 101 libraryRoot, | 102 libraryRoot, |
| 102 packageRoot, | 103 packageRoot, |
| 103 options); | 104 options, |
| 105 environment); |
| 104 // TODO(ahe): Use the value of the future (which signals success or failure). | 106 // TODO(ahe): Use the value of the future (which signals success or failure). |
| 105 return compiler.run(script).then((_) { | 107 return compiler.run(script).then((_) { |
| 106 String code = compiler.assembledCode; | 108 String code = compiler.assembledCode; |
| 107 if (code != null && outputProvider != null) { | 109 if (code != null && outputProvider != null) { |
| 108 String outputType = 'js'; | 110 String outputType = 'js'; |
| 109 if (options.contains('--output-type=dart')) { | 111 if (options.contains('--output-type=dart')) { |
| 110 outputType = 'dart'; | 112 outputType = 'dart'; |
| 111 } | 113 } |
| 112 outputProvider('', outputType) | 114 outputProvider('', outputType) |
| 113 ..add(code) | 115 ..add(code) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 final String name; | 185 final String name; |
| 184 | 186 |
| 185 /** | 187 /** |
| 186 * This constructor is not private to support user-defined | 188 * This constructor is not private to support user-defined |
| 187 * diagnostic kinds. | 189 * diagnostic kinds. |
| 188 */ | 190 */ |
| 189 const Diagnostic(this.ordinal, this.name); | 191 const Diagnostic(this.ordinal, this.name); |
| 190 | 192 |
| 191 String toString() => name; | 193 String toString() => name; |
| 192 } | 194 } |
| OLD | NEW |