OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' show |
| 6 DualKind, |
| 7 MessageKind; |
| 8 |
| 9 import 'message_kind_helper.dart'; |
| 10 |
| 11 import 'dart:mirrors'; |
| 12 |
| 13 main() { |
| 14 ClassMirror cls = reflectClass(MessageKind); |
| 15 Map<String, MessageKind> kinds = <String, MessageKind>{}; |
| 16 cls.variables.forEach((Symbol name, VariableMirror variable) { |
| 17 if (variable.isStatic) { |
| 18 var value = cls.getField(name).reflectee; |
| 19 if (value is MessageKind) { |
| 20 kinds[MirrorSystem.getName(name)] = value; |
| 21 } else if (value is DualKind) { |
| 22 kinds['${MirrorSystem.getName(name)}.error'] = value.error; |
| 23 kinds['${MirrorSystem.getName(name)}.warning'] = value.warning; |
| 24 } else { |
| 25 Expect.fail("Weird static field: '${MirrorSystem.getName(name)}'."); |
| 26 } |
| 27 } |
| 28 }); |
| 29 List<String> names = kinds.keys.toList()..sort(); |
| 30 List<String> examples = <String>[]; |
| 31 for (String name in names) { |
| 32 MessageKind kind = kinds[name]; |
| 33 if (name == 'GENERIC' // Shouldn't be used. |
| 34 // We can't provoke a crash. |
| 35 || name == 'COMPILER_CRASHED' |
| 36 || name == 'PLEASE_REPORT_THE_CRASH' |
| 37 // We cannot provide examples for patch errors. |
| 38 || name.startsWith('PATCH_')) continue; |
| 39 if (kind.examples != null) { |
| 40 examples.add(name); |
| 41 } else { |
| 42 print("No example in '$name'"); |
| 43 } |
| 44 }; |
| 45 var cachedCompiler; |
| 46 for (String name in examples) { |
| 47 Stopwatch sw = new Stopwatch()..start(); |
| 48 cachedCompiler = check(kinds[name], cachedCompiler); |
| 49 sw.stop(); |
| 50 print("Checked '$name' in ${sw.elapsedMilliseconds}ms."); |
| 51 } |
| 52 } |
OLD | NEW |