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 import "dart:_internal" as _symbol_dev; | 5 import "dart:_internal" as _symbol_dev; |
6 | 6 |
7 /** | 7 /** |
8 * Returns a [MirrorSystem] for the current isolate. | 8 * Returns a [MirrorSystem] for the current isolate. |
9 */ | 9 */ |
10 patch MirrorSystem currentMirrorSystem() { | 10 patch MirrorSystem currentMirrorSystem() { |
(...skipping 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 patch ClassMirror reflectClass(Type key) { | 30 patch ClassMirror reflectClass(Type key) { |
31 return _Mirrors.reflectClass(key); | 31 return _Mirrors.reflectClass(key); |
32 } | 32 } |
33 | 33 |
34 patch TypeMirror reflectType(Type key) { | 34 patch TypeMirror reflectType(Type key) { |
35 return _Mirrors.reflectType(key); | 35 return _Mirrors.reflectType(key); |
36 } | 36 } |
37 | 37 |
38 patch class MirrorSystem { | 38 patch class MirrorSystem { |
39 /* patch */ LibraryMirror findLibrary(Symbol libraryName) { | |
40 var candidates = | |
41 libraries.values.where((lib) => lib.simpleName == libraryName); | |
42 if (candidates.length == 1) { | |
43 return candidates.single; | |
44 } | |
45 if (candidates.length > 1) { | |
46 var uris = candidates.map((lib) => lib.uri.toString()).toList(); | |
47 throw new Exception("There are multiple libraries named " | |
48 "'${getName(libraryName)}': $uris"); | |
49 } | |
50 throw new Exception("There is no library named '${getName(libraryName)}'"); | |
51 } | |
52 | |
53 /* patch */ static String getName(Symbol symbol) { | 39 /* patch */ static String getName(Symbol symbol) { |
54 String string = _symbol_dev.Symbol.getName(symbol); | 40 String string = _symbol_dev.Symbol.getName(symbol); |
55 | 41 |
56 // get:foo -> foo | 42 // get:foo -> foo |
57 // set:foo -> foo= | 43 // set:foo -> foo= |
58 // get:_foo@xxx -> _foo | 44 // get:_foo@xxx -> _foo |
59 // set:_foo@xxx -> _foo= | 45 // set:_foo@xxx -> _foo= |
60 // Class._constructor@xxx -> Class._constructor | 46 // Class._constructor@xxx -> Class._constructor |
61 // _Class@xxx._constructor@xxx -> _Class._constructor | 47 // _Class@xxx._constructor@xxx -> _Class._constructor |
62 // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2 | 48 // lib._S@xxx with lib._M1@xxx, lib._M2@xxx -> lib._S with lib._M1, lib._M2 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // TODO(rmacnak): Eliminate this class. | 91 // TODO(rmacnak): Eliminate this class. |
106 class MirroredCompilationError { | 92 class MirroredCompilationError { |
107 final String message; | 93 final String message; |
108 | 94 |
109 MirroredCompilationError(this.message); | 95 MirroredCompilationError(this.message); |
110 | 96 |
111 String toString() { | 97 String toString() { |
112 return "Compile-time error during mirrored execution: <$message>"; | 98 return "Compile-time error during mirrored execution: <$message>"; |
113 } | 99 } |
114 } | 100 } |
OLD | NEW |