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 // VM-specific implementation of the dart:mirrors library. | 5 // VM-specific implementation of the dart:mirrors library. |
6 | 6 |
7 import "dart:collection"; | 7 import "dart:collection"; |
8 | 8 |
9 final emptyList = new UnmodifiableListView([]); | 9 final emptyList = new UnmodifiableListView([]); |
10 final emptyMap = new _UnmodifiableMapView({}); | 10 final emptyMap = new _UnmodifiableMapView({}); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 Map new_map = new Map<Symbol, dynamic>(); | 45 Map new_map = new Map<Symbol, dynamic>(); |
46 old_map.forEach((key, value) { | 46 old_map.forEach((key, value) { |
47 if (filter(key, value)) { | 47 if (filter(key, value)) { |
48 new_map[key] = value; | 48 new_map[key] = value; |
49 } | 49 } |
50 }); | 50 }); |
51 return new _UnmodifiableMapView(new_map); | 51 return new _UnmodifiableMapView(new_map); |
52 } | 52 } |
53 | 53 |
54 Map _makeMemberMap(List mirrors) { | 54 Map _makeMemberMap(List mirrors) { |
55 return new _UnmodifiableMapView( | 55 return new _UnmodifiableMapView<Symbol, DeclarationMirror>( |
56 new Map<Symbol, dynamic>.fromIterable(mirrors, key: (e) => e.simpleName)); | 56 new Map<Symbol, DeclarationMirror>.fromIterable( |
| 57 mirrors, key: (e) => e.simpleName)); |
57 } | 58 } |
58 | 59 |
59 String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); | 60 String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); |
60 | 61 |
61 Symbol _s(String name) { | 62 Symbol _s(String name) { |
62 if (name == null) return null; | 63 if (name == null) return null; |
63 return new _symbol_dev.Symbol.unvalidated(name); | 64 return new _symbol_dev.Symbol.unvalidated(name); |
64 } | 65 } |
65 | 66 |
66 Symbol _computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { | 67 Symbol _computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 647 } |
647 return _cachedMethods; | 648 return _cachedMethods; |
648 } | 649 } |
649 | 650 |
650 Map<Symbol, MethodMirror> _cachedConstructors; | 651 Map<Symbol, MethodMirror> _cachedConstructors; |
651 Map<Symbol, MethodMirror> get _constructors { | 652 Map<Symbol, MethodMirror> get _constructors { |
652 if (_cachedConstructors == null) { | 653 if (_cachedConstructors == null) { |
653 var constructorsList = _computeConstructors(_reflectee); | 654 var constructorsList = _computeConstructors(_reflectee); |
654 var stringName = _n(simpleName); | 655 var stringName = _n(simpleName); |
655 constructorsList.forEach((c) => c._patchConstructorName(stringName)); | 656 constructorsList.forEach((c) => c._patchConstructorName(stringName)); |
656 _cachedConstructors = _makeMemberMap(constructorsList); | 657 _cachedConstructors = |
| 658 new Map.fromIterable(constructorsList, key: (e) => e.simpleName); |
657 } | 659 } |
658 return _cachedConstructors; | 660 return _cachedConstructors; |
659 } | 661 } |
660 | 662 |
661 bool get _isAnonymousMixinApplication { | 663 bool get _isAnonymousMixinApplication { |
662 if (_isMixinAlias) return false; // Named mixin application. | 664 if (_isMixinAlias) return false; // Named mixin application. |
663 if (mixin == this) return false; // Not a mixin application. | 665 if (mixin == this) return false; // Not a mixin application. |
664 return true; | 666 return true; |
665 } | 667 } |
666 | 668 |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 if (typeMirror == null) { | 1492 if (typeMirror == null) { |
1491 typeMirror = makeLocalTypeMirror(key); | 1493 typeMirror = makeLocalTypeMirror(key); |
1492 _instanitationCache[key] = typeMirror; | 1494 _instanitationCache[key] = typeMirror; |
1493 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1495 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1494 _declarationCache[key] = typeMirror; | 1496 _declarationCache[key] = typeMirror; |
1495 } | 1497 } |
1496 } | 1498 } |
1497 return typeMirror; | 1499 return typeMirror; |
1498 } | 1500 } |
1499 } | 1501 } |
OLD | NEW |