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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 if (_superinterfaces == null) { | 579 if (_superinterfaces == null) { |
580 _superinterfaces = isOriginalDeclaration | 580 _superinterfaces = isOriginalDeclaration |
581 ? _nativeInterfaces(_reflectedType) | 581 ? _nativeInterfaces(_reflectedType) |
582 : _nativeInterfacesInstantiated(_reflectedType); | 582 : _nativeInterfacesInstantiated(_reflectedType); |
583 _superinterfaces = | 583 _superinterfaces = |
584 new UnmodifiableListView(_superinterfaces.map(reflectType)); | 584 new UnmodifiableListView(_superinterfaces.map(reflectType)); |
585 } | 585 } |
586 return _superinterfaces; | 586 return _superinterfaces; |
587 } | 587 } |
588 | 588 |
| 589 _unmangleQualified(Symbol s) { |
| 590 return _n(s).split('.').map((n) => MirrorSystem.getName(_s(n))).join('.'); |
| 591 } |
| 592 |
589 get _mixinApplicationName { | 593 get _mixinApplicationName { |
590 var mixins = new List<ClassMirror>(); | 594 var mixins = new List<ClassMirror>(); |
591 var klass = this; | 595 var klass = this; |
592 while (_nativeMixin(klass._reflectedType) != null) { | 596 while (_nativeMixin(klass._reflectedType) != null) { |
593 mixins.add(klass.mixin); | 597 mixins.add(klass.mixin); |
594 klass = klass.superclass; | 598 klass = klass.superclass; |
595 } | 599 } |
| 600 // Strip out the private manglings early, but the VM's unmangling routine |
| 601 // can't cope with them. |
596 return _s( | 602 return _s( |
597 _n(klass.qualifiedName) | 603 _unmangleQualified(klass.qualifiedName) |
598 + ' with ' | 604 + ' with ' |
599 + mixins.reversed.map((m)=>_n(m.qualifiedName)).join(', ')); | 605 + mixins.reversed.map((m)=>_unmangleQualified(m.qualifiedName)).join(', ')
); |
600 } | 606 } |
601 | 607 |
602 var _mixin; | 608 var _mixin; |
603 ClassMirror get mixin { | 609 ClassMirror get mixin { |
604 if (_mixin == null) { | 610 if (_mixin == null) { |
605 if (_isMixinTypedef) { | 611 if (_isMixinTypedef) { |
606 Type mixinType = _nativeMixinInstantiated(_trueSuperclass._reflectedType
, | 612 Type mixinType = _nativeMixinInstantiated(_trueSuperclass._reflectedType
, |
607 _instantiator); | 613 _instantiator); |
608 _mixin = reflectType(mixinType); | 614 _mixin = reflectType(mixinType); |
609 } else { | 615 } else { |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 if (_constructorName == null) { | 1335 if (_constructorName == null) { |
1330 if (!isConstructor) { | 1336 if (!isConstructor) { |
1331 _constructorName = _s(''); | 1337 _constructorName = _s(''); |
1332 } else { | 1338 } else { |
1333 var parts = MirrorSystem.getName(simpleName).split('.'); | 1339 var parts = MirrorSystem.getName(simpleName).split('.'); |
1334 if (parts.length > 2) { | 1340 if (parts.length > 2) { |
1335 throw new MirrorException( | 1341 throw new MirrorException( |
1336 'Internal error in MethodMirror.constructorName: ' | 1342 'Internal error in MethodMirror.constructorName: ' |
1337 'malformed name <$simpleName>'); | 1343 'malformed name <$simpleName>'); |
1338 } else if (parts.length == 2) { | 1344 } else if (parts.length == 2) { |
1339 _constructorName = _s(parts[1]); | 1345 LibraryMirror definingLibrary = owner.owner; |
| 1346 _constructorName = MirrorSystem.getSymbol(parts[1], definingLibrary); |
1340 } else { | 1347 } else { |
1341 _constructorName = _s(''); | 1348 _constructorName = _s(''); |
1342 } | 1349 } |
1343 } | 1350 } |
1344 } | 1351 } |
1345 return _constructorName; | 1352 return _constructorName; |
1346 } | 1353 } |
1347 | 1354 |
1348 String _source = null; | 1355 String _source = null; |
1349 String get source { | 1356 String get source { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 if (typeMirror == null) { | 1582 if (typeMirror == null) { |
1576 typeMirror = makeLocalTypeMirror(key); | 1583 typeMirror = makeLocalTypeMirror(key); |
1577 _instanitationCache[key] = typeMirror; | 1584 _instanitationCache[key] = typeMirror; |
1578 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1585 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1579 _declarationCache[key] = typeMirror; | 1586 _declarationCache[key] = typeMirror; |
1580 } | 1587 } |
1581 } | 1588 } |
1582 return typeMirror; | 1589 return typeMirror; |
1583 } | 1590 } |
1584 } | 1591 } |
OLD | NEW |