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:io'); | 7 #import('dart:io'); |
8 #import('dart:uri'); | 8 #import('dart:uri'); |
9 #import('dart:utf'); | 9 #import('dart:utf'); |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { | 48 void parseCommandLine(List<OptionHandler> handlers, List<String> argv) { |
49 // TODO(ahe): Use ../../args/args.dart for parsing options instead. | 49 // TODO(ahe): Use ../../args/args.dart for parsing options instead. |
50 var patterns = <String>[]; | 50 var patterns = <String>[]; |
51 for (OptionHandler handler in handlers) { | 51 for (OptionHandler handler in handlers) { |
52 patterns.add(handler.pattern); | 52 patterns.add(handler.pattern); |
53 } | 53 } |
54 var pattern = new RegExp('^(${Strings.join(patterns, ")\$|(")})\$'); | 54 var pattern = new RegExp('^(${Strings.join(patterns, ")\$|(")})\$'); |
55 OUTER: for (String argument in argv) { | 55 OUTER: for (String argument in argv) { |
56 Match match = pattern.firstMatch(argument); | 56 Match match = pattern.firstMatch(argument); |
57 assert(match.groupCount() == handlers.length); | 57 assert(match.groupCount == handlers.length); |
58 for (int i = 0; i < handlers.length; i++) { | 58 for (int i = 0; i < handlers.length; i++) { |
59 if (match[i + 1] != null) { | 59 if (match[i + 1] != null) { |
60 handlers[i].handle(argument); | 60 handlers[i].handle(argument); |
61 continue OUTER; | 61 continue OUTER; |
62 } | 62 } |
63 } | 63 } |
64 throw 'Internal error: "$argument" did not match'; | 64 throw 'Internal error: "$argument" did not match'; |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 } catch (ignored) { | 426 } catch (ignored) { |
427 print('Internal error: error while printing exception'); | 427 print('Internal error: error while printing exception'); |
428 } | 428 } |
429 try { | 429 try { |
430 print(trace); | 430 print(trace); |
431 } finally { | 431 } finally { |
432 exit(253); // 253 is recognized as a crash by our test scripts. | 432 exit(253); // 253 is recognized as a crash by our test scripts. |
433 } | 433 } |
434 } | 434 } |
435 } | 435 } |
OLD | NEW |