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 dart2js; | 5 library dart2js; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show Queue, LinkedHashMap; | 8 import 'dart:collection' show Queue, LinkedHashMap; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } else { | 283 } else { |
284 fail('Error: Unknown extension: $extension'); | 284 fail('Error: Unknown extension: $extension'); |
285 } | 285 } |
286 } else { | 286 } else { |
287 uri = out.resolve('$name.$extension'); | 287 uri = out.resolve('$name.$extension'); |
288 } | 288 } |
289 | 289 |
290 if (uri.scheme != 'file') { | 290 if (uri.scheme != 'file') { |
291 fail('Error: Unhandled scheme ${uri.scheme} in $uri.'); | 291 fail('Error: Unhandled scheme ${uri.scheme} in $uri.'); |
292 } | 292 } |
293 var outputStream = new File(uriPathToNative(uri.path)).openOutputStream(); | 293 IOSink output = |
| 294 new File(uriPathToNative(uri.path)).openWrite(); |
294 | 295 |
295 CountingSink sink; | 296 CountingSink sink; |
296 | 297 |
297 onDone() { | 298 onDone() { |
298 if (sourceMapFileName != null) { | 299 if (sourceMapFileName != null) { |
299 String sourceMapTag = '//@ sourceMappingURL=$sourceMapFileName\n'; | 300 String sourceMapTag = '//@ sourceMappingURL=$sourceMapFileName\n'; |
300 sink.count += sourceMapTag.length; | 301 sink.count += sourceMapTag.length; |
301 outputStream.writeString(sourceMapTag); | 302 output.addString(sourceMapTag); |
302 } | 303 } |
303 outputStream.close(); | 304 output.close(); |
304 if (isPrimaryOutput) { | 305 if (isPrimaryOutput) { |
305 charactersWritten += sink.count; | 306 charactersWritten += sink.count; |
306 } | 307 } |
307 } | 308 } |
308 | 309 |
309 var controller = new StreamController<String>(); | 310 var controller = new StreamController<String>(); |
310 controller.stream.listen(outputStream.writeString, onDone: onDone); | 311 controller.stream.listen(output.addString, onDone: onDone); |
311 sink = new CountingSink(controller); | 312 sink = new CountingSink(controller); |
312 return sink; | 313 return sink; |
313 } | 314 } |
314 | 315 |
315 api.compile(uri, libraryRoot, packageRoot, | 316 api.compile(uri, libraryRoot, packageRoot, |
316 inputProvider.readStringFromUri, handler, | 317 inputProvider.readStringFromUri, handler, |
317 options, outputProvider) | 318 options, outputProvider) |
318 .then(compilationDone); | 319 .then(compilationDone); |
319 } | 320 } |
320 | 321 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } catch (ignored) { | 501 } catch (ignored) { |
501 print('Internal error: error while printing exception'); | 502 print('Internal error: error while printing exception'); |
502 } | 503 } |
503 try { | 504 try { |
504 print(trace); | 505 print(trace); |
505 } finally { | 506 } finally { |
506 exit(253); // 253 is recognized as a crash by our test scripts. | 507 exit(253); // 253 is recognized as a crash by our test scripts. |
507 } | 508 } |
508 } | 509 } |
509 } | 510 } |
OLD | NEW |