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 return compiler.run(script).then((_) { |
ahe
2013/06/26 07:02:00
Could you add something like:
// TODO(ahe): Use t
Bob Nystrom
2013/06/27 00:38:18
Done.
| |
96 String code = compiler.assembledCode; | 96 String code = compiler.assembledCode; |
97 if (code != null && outputProvider != null) { | 97 if (code != null && outputProvider != null) { |
98 String outputType = 'js'; | 98 String outputType = 'js'; |
99 if (options.contains('--output-type=dart')) { | 99 if (options.contains('--output-type=dart')) { |
100 outputType = 'dart'; | 100 outputType = 'dart'; |
101 } | |
102 outputProvider('', outputType) | |
103 ..add(code) | |
104 ..close(); | |
105 code = ''; // Non-null signals success. | |
101 } | 106 } |
102 outputProvider('', outputType) | 107 return code; |
103 ..add(code) | 108 }); |
104 ..close(); | |
105 code = ''; // Non-null signals success. | |
106 } | |
107 return new Future.value(code); | |
108 } | 109 } |
109 | 110 |
110 /** | 111 /** |
111 * Kind of diagnostics that the compiler can report. | 112 * Kind of diagnostics that the compiler can report. |
112 */ | 113 */ |
113 class Diagnostic { | 114 class Diagnostic { |
114 /** | 115 /** |
115 * An error as identified by the "Dart Programming Language | 116 * An error as identified by the "Dart Programming Language |
116 * Specification" [http://www.dartlang.org/docs/spec/]. | 117 * Specification" [http://www.dartlang.org/docs/spec/]. |
117 * | 118 * |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 final String name; | 168 final String name; |
168 | 169 |
169 /** | 170 /** |
170 * This constructor is not private to support user-defined | 171 * This constructor is not private to support user-defined |
171 * diagnostic kinds. | 172 * diagnostic kinds. |
172 */ | 173 */ |
173 const Diagnostic(this.ordinal, this.name); | 174 const Diagnostic(this.ordinal, this.name); |
174 | 175 |
175 String toString() => name; | 176 String toString() => name; |
176 } | 177 } |
OLD | NEW |