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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 throw new ArgumentError("packageRoot must end with a /"); | 85 throw new ArgumentError("packageRoot must end with a /"); |
86 } | 86 } |
87 // TODO(ahe): Consider completing the future with an exception if | 87 // TODO(ahe): Consider completing the future with an exception if |
88 // code is null. | 88 // code is null. |
89 Compiler compiler = new Compiler(inputProvider, | 89 Compiler compiler = new Compiler(inputProvider, |
90 outputProvider, | 90 outputProvider, |
91 handler, | 91 handler, |
92 libraryRoot, | 92 libraryRoot, |
93 packageRoot, | 93 packageRoot, |
94 options); | 94 options); |
95 compiler.run(script); | 95 // TODO(ahe): Use the value of the future (which signals success or failure). |
96 String code = compiler.assembledCode; | 96 return compiler.run(script).then((_) { |
97 if (code != null && outputProvider != null) { | 97 String code = compiler.assembledCode; |
98 String outputType = 'js'; | 98 if (code != null && outputProvider != null) { |
99 if (options.contains('--output-type=dart')) { | 99 String outputType = 'js'; |
100 outputType = 'dart'; | 100 if (options.contains('--output-type=dart')) { |
| 101 outputType = 'dart'; |
| 102 } |
| 103 outputProvider('', outputType) |
| 104 ..add(code) |
| 105 ..close(); |
| 106 code = ''; // Non-null signals success. |
101 } | 107 } |
102 outputProvider('', outputType) | 108 return code; |
103 ..add(code) | 109 }); |
104 ..close(); | |
105 code = ''; // Non-null signals success. | |
106 } | |
107 return new Future.value(code); | |
108 } | 110 } |
109 | 111 |
110 /** | 112 /** |
111 * Kind of diagnostics that the compiler can report. | 113 * Kind of diagnostics that the compiler can report. |
112 */ | 114 */ |
113 class Diagnostic { | 115 class Diagnostic { |
114 /** | 116 /** |
115 * An error as identified by the "Dart Programming Language | 117 * An error as identified by the "Dart Programming Language |
116 * Specification" [http://www.dartlang.org/docs/spec/]. | 118 * Specification" [http://www.dartlang.org/docs/spec/]. |
117 * | 119 * |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 final String name; | 169 final String name; |
168 | 170 |
169 /** | 171 /** |
170 * This constructor is not private to support user-defined | 172 * This constructor is not private to support user-defined |
171 * diagnostic kinds. | 173 * diagnostic kinds. |
172 */ | 174 */ |
173 const Diagnostic(this.ordinal, this.name); | 175 const Diagnostic(this.ordinal, this.name); |
174 | 176 |
175 String toString() => name; | 177 String toString() => name; |
176 } | 178 } |
OLD | NEW |