Chromium Code Reviews| 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('parser'); | 5 #library('parser'); |
| 6 | 6 |
| 7 #import('dart:io'); | 7 #import('dart:io'); |
| 8 | 8 |
| 9 #import('../../../utf/utf.dart'); | 9 #import('../../../utf/utf.dart'); |
| 10 | 10 |
| 11 #import('../elements/elements.dart'); | 11 #import('../elements/elements.dart'); |
| 12 #import('../scanner/scanner_implementation.dart'); | 12 #import('../scanner/scanner_implementation.dart'); |
| 13 #import('../scanner/scannerlib.dart'); | 13 #import('../scanner/scannerlib.dart'); |
| 14 #import('../tree/tree.dart'); | 14 #import('../tree/tree.dart'); |
| 15 #import('../util/characters.dart'); | 15 #import('../util/characters.dart'); |
| 16 #import('../source_file.dart'); | 16 #import('../source_file.dart'); |
| 17 | 17 |
| 18 #source('../diagnostic_listener.dart'); | 18 #source('../diagnostic_listener.dart'); |
| 19 #source('../scanner/byte_array_scanner.dart'); | 19 #source('../scanner/byte_array_scanner.dart'); |
| 20 #source('../scanner/byte_strings.dart'); | 20 #source('../scanner/byte_strings.dart'); |
| 21 | 21 |
| 22 int charCount = 0; | 22 int charCount = 0; |
| 23 Stopwatch stopwatch; | 23 Stopwatch stopwatch; |
| 24 | 24 |
| 25 void main() { | 25 void main() { toolMain(new Options().arguments); } |
|
kasperl
2012/08/14 08:30:03
I'd prefer to put this on multiple lines. Break af
| |
| 26 | |
| 27 void toolMain(List<String> arguments) { | |
| 26 filesWithCrashes = []; | 28 filesWithCrashes = []; |
| 27 stopwatch = new Stopwatch(); | 29 stopwatch = new Stopwatch(); |
| 28 MyOptions options = new MyOptions(); | 30 MyOptions options = new MyOptions(); |
| 29 | 31 |
| 30 void printStats() { | 32 void printStats() { |
| 31 int kb = (charCount / 1024).round().toInt(); | 33 int kb = (charCount / 1024).round().toInt(); |
| 32 String stats = | 34 String stats = |
| 33 '$classCount classes (${kb}Kb) in ${stopwatch.elapsedInMs()}ms'; | 35 '$classCount classes (${kb}Kb) in ${stopwatch.elapsedInMs()}ms'; |
| 34 if (errorCount != 0) { | 36 if (errorCount != 0) { |
| 35 stats = '$stats with $errorCount errors'; | 37 stats = '$stats with $errorCount errors'; |
| 36 } | 38 } |
| 37 if (options.diet) { | 39 if (options.diet) { |
| 38 print('Diet parsed $stats.'); | 40 print('Diet parsed $stats.'); |
| 39 } else { | 41 } else { |
| 40 print('Parsed $stats.'); | 42 print('Parsed $stats.'); |
| 41 } | 43 } |
| 42 if (filesWithCrashes.length !== 0) { | 44 if (filesWithCrashes.length !== 0) { |
| 43 print('The following ${filesWithCrashes.length} files caused a crash:'); | 45 print('The following ${filesWithCrashes.length} files caused a crash:'); |
| 44 for (String file in filesWithCrashes) { | 46 for (String file in filesWithCrashes) { |
| 45 print(file); | 47 print(file); |
| 46 } | 48 } |
| 47 } | 49 } |
| 48 } | 50 } |
| 49 | 51 |
| 50 for (String argument in new Options().arguments) { | 52 for (String argument in arguments) { |
| 51 if (argument == "--diet") { | 53 if (argument == "--diet") { |
| 52 options.diet = true; | 54 options.diet = true; |
| 53 continue; | 55 continue; |
| 54 } | 56 } |
| 55 if (argument == "--throw") { | 57 if (argument == "--throw") { |
| 56 options.throwOnError = true; | 58 options.throwOnError = true; |
| 57 continue; | 59 continue; |
| 58 } | 60 } |
| 59 if (argument == "--scan-only") { | 61 if (argument == "--scan-only") { |
| 60 options.scanOnly = true; | 62 options.scanOnly = true; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 set text(String newText) { | 318 set text(String newText) { |
| 317 throw "not supported"; | 319 throw "not supported"; |
| 318 } | 320 } |
| 319 } | 321 } |
| 320 | 322 |
| 321 class Mock { | 323 class Mock { |
| 322 const Mock(); | 324 const Mock(); |
| 323 bool get useColors() => true; | 325 bool get useColors() => true; |
| 324 internalError(message) { throw message.toString(); } | 326 internalError(message) { throw message.toString(); } |
| 325 } | 327 } |
| OLD | NEW |