| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 'compiled ${inputProvider.dartCharactersRead} characters Dart ' | 256 'compiled ${inputProvider.dartCharactersRead} characters Dart ' |
| 257 '-> $charactersWritten characters $outputLanguage ' | 257 '-> $charactersWritten characters $outputLanguage ' |
| 258 'in ${relativize(cwd, out, isWindows)}'); | 258 'in ${relativize(cwd, out, isWindows)}'); |
| 259 if (!explicitOut) { | 259 if (!explicitOut) { |
| 260 String input = uriPathToNative(arguments[0]); | 260 String input = uriPathToNative(arguments[0]); |
| 261 String output = relativize(cwd, out, isWindows); | 261 String output = relativize(cwd, out, isWindows); |
| 262 print('Dart file $input compiled to $outputLanguage: $output'); | 262 print('Dart file $input compiled to $outputLanguage: $output'); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 Sink<String> outputProvider(String name, String extension) { | 266 StreamSink<String> outputProvider(String name, String extension) { |
| 267 Uri uri; | 267 Uri uri; |
| 268 String sourceMapFileName; | 268 String sourceMapFileName; |
| 269 bool isPrimaryOutput = false; | 269 bool isPrimaryOutput = false; |
| 270 if (name == '') { | 270 if (name == '') { |
| 271 if (extension == 'js' || extension == 'dart') { | 271 if (extension == 'js' || extension == 'dart') { |
| 272 isPrimaryOutput = true; | 272 isPrimaryOutput = true; |
| 273 uri = out; | 273 uri = out; |
| 274 sourceMapFileName = | 274 sourceMapFileName = |
| 275 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); | 275 sourceMapOut.path.substring(sourceMapOut.path.lastIndexOf('/') + 1); |
| 276 } else if (extension == 'js.map' || extension == 'dart.map') { | 276 } else if (extension == 'js.map' || extension == 'dart.map') { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 307 return sink; | 307 return sink; |
| 308 } | 308 } |
| 309 | 309 |
| 310 api.compile(uri, libraryRoot, packageRoot, | 310 api.compile(uri, libraryRoot, packageRoot, |
| 311 inputProvider.readStringFromUri, handler, | 311 inputProvider.readStringFromUri, handler, |
| 312 options, outputProvider) | 312 options, outputProvider) |
| 313 .then(compilationDone); | 313 .then(compilationDone); |
| 314 } | 314 } |
| 315 | 315 |
| 316 // TODO(ahe): Get rid of this class if http://dartbug.com/8118 is fixed. | 316 // TODO(ahe): Get rid of this class if http://dartbug.com/8118 is fixed. |
| 317 class CountingSink implements Sink<String> { | 317 class CountingSink implements StreamSink<String> { |
| 318 final Sink<String> sink; | 318 final StreamSink<String> sink; |
| 319 int count = 0; | 319 int count = 0; |
| 320 | 320 |
| 321 CountingSink(this.sink); | 321 CountingSink(this.sink); |
| 322 | 322 |
| 323 add(String value) { | 323 add(String value) { |
| 324 sink.add(value); | 324 sink.add(value); |
| 325 count += value.length; | 325 count += value.length; |
| 326 } | 326 } |
| 327 | 327 |
| 328 signalError(AsyncError error) => sink.signalError(error); |
| 329 |
| 328 close() => sink.close(); | 330 close() => sink.close(); |
| 329 } | 331 } |
| 330 | 332 |
| 331 class AbortLeg { | 333 class AbortLeg { |
| 332 final message; | 334 final message; |
| 333 AbortLeg(this.message); | 335 AbortLeg(this.message); |
| 334 toString() => 'Aborted due to --throw-on-error: $message'; | 336 toString() => 'Aborted due to --throw-on-error: $message'; |
| 335 } | 337 } |
| 336 | 338 |
| 337 void writeString(Uri uri, String text) { | 339 void writeString(Uri uri, String text) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 } catch (ignored) { | 489 } catch (ignored) { |
| 488 print('Internal error: error while printing exception'); | 490 print('Internal error: error while printing exception'); |
| 489 } | 491 } |
| 490 try { | 492 try { |
| 491 print(trace); | 493 print(trace); |
| 492 } finally { | 494 } finally { |
| 493 exit(253); // 253 is recognized as a crash by our test scripts. | 495 exit(253); // 253 is recognized as a crash by our test scripts. |
| 494 } | 496 } |
| 495 } | 497 } |
| 496 } | 498 } |
| OLD | NEW |