Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 1072443005: Deal with type arguments of generic local functions in VM mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" show UnmodifiableListView, UnmodifiableMapView; 7 import "dart:collection" show UnmodifiableListView, UnmodifiableMapView;
8 8
9 final emptyList = new UnmodifiableListView([]); 9 final emptyList = new UnmodifiableListView([]);
10 final emptyMap = new UnmodifiableMapView({}); 10 final emptyMap = new UnmodifiableMapView({});
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 return _s( 686 return _s(
687 _n(klass.qualifiedName) 687 _n(klass.qualifiedName)
688 + ' with ' 688 + ' with '
689 + mixins.reversed.map((m)=>_n(m.qualifiedName)).join(', ')); 689 + mixins.reversed.map((m)=>_n(m.qualifiedName)).join(', '));
690 } 690 }
691 691
692 var _mixin; 692 var _mixin;
693 ClassMirror get mixin { 693 ClassMirror get mixin {
694 if (_mixin == null) { 694 if (_mixin == null) {
695 if (_isMixinAlias) { 695 if (_isMixinAlias) {
696 Type mixinType = _nativeMixinInstantiated(_trueSuperclass._reflectedType , 696 Type mixinType = _nativeMixinInstantiated(
697 _instantiator); 697 _trueSuperclass._reflectedType, _instantiator);
698 _mixin = reflectType(mixinType); 698 _mixin = reflectType(mixinType);
699 } else { 699 } else {
700 Type mixinType = _nativeMixinInstantiated(_reflectedType, _instantiator) ; 700 Type mixinType = _nativeMixinInstantiated(_reflectedType,
701 _instantiator);
701 if (mixinType == null) { 702 if (mixinType == null) {
702 // The reflectee is not a mixin application. 703 // The reflectee is not a mixin application.
703 _mixin = this; 704 _mixin = this;
704 } else { 705 } else {
705 _mixin = reflectType(mixinType); 706 _mixin = reflectType(mixinType);
706 } 707 }
707 } 708 }
708 } 709 }
709 return _mixin; 710 return _mixin;
710 } 711 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 decls.addAll(_constructors); 772 decls.addAll(_constructors);
772 typeVariables.forEach((tv) => decls[tv.simpleName] = tv); 773 typeVariables.forEach((tv) => decls[tv.simpleName] = tv);
773 return _declarations = 774 return _declarations =
774 new UnmodifiableMapView<Symbol, DeclarationMirror>(decls); 775 new UnmodifiableMapView<Symbol, DeclarationMirror>(decls);
775 } 776 }
776 777
777 Map<Symbol, Mirror> _cachedMembers; 778 Map<Symbol, Mirror> _cachedMembers;
778 Map<Symbol, Mirror> get _members { 779 Map<Symbol, Mirror> get _members {
779 if (_cachedMembers == null) { 780 if (_cachedMembers == null) {
780 var whoseMembers = _isMixinAlias ? _trueSuperclass : this; 781 var whoseMembers = _isMixinAlias ? _trueSuperclass : this;
781 _cachedMembers = _makeMemberMap(mixin._computeMembers(whoseMembers.mixin._ reflectee)); 782 _cachedMembers = _makeMemberMap(mixin._computeMembers(
783 _instantiator, whoseMembers.mixin._reflectee));
782 } 784 }
783 return _cachedMembers; 785 return _cachedMembers;
784 } 786 }
785 787
786 Map<Symbol, MethodMirror> _cachedMethods; 788 Map<Symbol, MethodMirror> _cachedMethods;
787 Map<Symbol, MethodMirror> get _methods { 789 Map<Symbol, MethodMirror> get _methods {
788 if (_cachedMethods == null) { 790 if (_cachedMethods == null) {
789 _cachedMethods = _filterMap( 791 _cachedMethods = _filterMap(
790 _members, 792 _members,
791 (key, value) => (value is MethodMirror && value.isRegularMethod)); 793 (key, value) => (value is MethodMirror && value.isRegularMethod));
792 } 794 }
793 return _cachedMethods; 795 return _cachedMethods;
794 } 796 }
795 797
796 Map<Symbol, MethodMirror> _cachedConstructors; 798 Map<Symbol, MethodMirror> _cachedConstructors;
797 Map<Symbol, MethodMirror> get _constructors { 799 Map<Symbol, MethodMirror> get _constructors {
798 if (_cachedConstructors == null) { 800 if (_cachedConstructors == null) {
799 var constructorsList = _computeConstructors(_reflectee); 801 var constructorsList = _computeConstructors(_instantiator, _reflectee);
800 var stringName = _n(simpleName); 802 var stringName = _n(simpleName);
801 constructorsList.forEach((c) => c._patchConstructorName(stringName)); 803 constructorsList.forEach((c) => c._patchConstructorName(stringName));
802 _cachedConstructors = 804 _cachedConstructors =
803 new Map.fromIterable(constructorsList, key: (e) => e.simpleName); 805 new Map.fromIterable(constructorsList, key: (e) => e.simpleName);
804 } 806 }
805 return _cachedConstructors; 807 return _cachedConstructors;
806 } 808 }
807 809
808 bool get _isAnonymousMixinApplication { 810 bool get _isAnonymousMixinApplication {
809 if (_isMixinAlias) return false; // Named mixin application. 811 if (_isMixinAlias) return false; // Named mixin application.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 938
937 static _nativeInterfacesInstantiated(reflectedType) 939 static _nativeInterfacesInstantiated(reflectedType)
938 native "ClassMirror_interfaces_instantiated"; 940 native "ClassMirror_interfaces_instantiated";
939 941
940 static _nativeMixin(reflectedType) 942 static _nativeMixin(reflectedType)
941 native "ClassMirror_mixin"; 943 native "ClassMirror_mixin";
942 944
943 static _nativeMixinInstantiated(reflectedType, instantiator) 945 static _nativeMixinInstantiated(reflectedType, instantiator)
944 native "ClassMirror_mixin_instantiated"; 946 native "ClassMirror_mixin_instantiated";
945 947
946 _computeMembers(reflectee) 948 _computeMembers(reflectee, instantiator)
947 native "ClassMirror_members"; 949 native "ClassMirror_members";
948 950
949 _computeConstructors(reflectee) 951 _computeConstructors(reflectee, instantiator)
950 native "ClassMirror_constructors"; 952 native "ClassMirror_constructors";
951 953
952 _invoke(reflectee, memberName, arguments, argumentNames) 954 _invoke(reflectee, memberName, arguments, argumentNames)
953 native 'ClassMirror_invoke'; 955 native 'ClassMirror_invoke';
954 956
955 _invokeGetter(reflectee, getterName) 957 _invokeGetter(reflectee, getterName)
956 native 'ClassMirror_invokeGetter'; 958 native 'ClassMirror_invokeGetter';
957 959
958 _invokeSetter(reflectee, setterName, value) 960 _invokeSetter(reflectee, setterName, value)
959 native 'ClassMirror_invokeSetter'; 961 native 'ClassMirror_invokeSetter';
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 final bool isShow; 1352 final bool isShow;
1351 1353
1352 _LocalCombinatorMirror(identifierString, this.isShow) 1354 _LocalCombinatorMirror(identifierString, this.isShow)
1353 : this.identifiers = [_s(identifierString)]; 1355 : this.identifiers = [_s(identifierString)];
1354 1356
1355 bool get isHide => !isShow; 1357 bool get isHide => !isShow;
1356 } 1358 }
1357 1359
1358 class _LocalMethodMirror extends _LocalDeclarationMirror 1360 class _LocalMethodMirror extends _LocalDeclarationMirror
1359 implements MethodMirror { 1361 implements MethodMirror {
1362 final Type _instantiator;
1360 final bool isStatic; 1363 final bool isStatic;
1361 final bool isAbstract; 1364 final bool isAbstract;
1362 final bool isGetter; 1365 final bool isGetter;
1363 final bool isSetter; 1366 final bool isSetter;
1364 final bool isConstructor; 1367 final bool isConstructor;
1365 final bool isConstConstructor; 1368 final bool isConstConstructor;
1366 final bool isGenerativeConstructor; 1369 final bool isGenerativeConstructor;
1367 final bool isRedirectingConstructor; 1370 final bool isRedirectingConstructor;
1368 final bool isFactoryConstructor; 1371 final bool isFactoryConstructor;
1369 final bool isOperator; 1372 final bool isOperator;
1370 1373
1371 static const _operators = const ["%", "&", "*", "+", "-", "/", "<", "<<", 1374 static const _operators = const ["%", "&", "*", "+", "-", "/", "<", "<<",
1372 "<=", "==", ">", ">=", ">>", "[]", "[]=", "^", "|", "~", "unary-", "~/"]; 1375 "<=", "==", ">", ">=", ">>", "[]", "[]=", "^", "|", "~", "unary-", "~/"];
1373 1376
1374 _LocalMethodMirror(reflectee, 1377 _LocalMethodMirror(reflectee,
1375 String simpleName, 1378 String simpleName,
1376 this._owner, 1379 this._owner,
1380 this._instantiator,
1377 this.isStatic, 1381 this.isStatic,
1378 this.isAbstract, 1382 this.isAbstract,
1379 this.isGetter, 1383 this.isGetter,
1380 this.isSetter, 1384 this.isSetter,
1381 this.isConstructor, 1385 this.isConstructor,
1382 this.isConstConstructor, 1386 this.isConstConstructor,
1383 this.isGenerativeConstructor, 1387 this.isGenerativeConstructor,
1384 this.isRedirectingConstructor, 1388 this.isRedirectingConstructor,
1385 this.isFactoryConstructor) 1389 this.isFactoryConstructor)
1386 : this.isOperator = _operators.contains(simpleName), 1390 : this.isOperator = _operators.contains(simpleName),
1387 super(reflectee, _s(simpleName)); 1391 super(reflectee, _s(simpleName));
1388 1392
1389 DeclarationMirror _owner; 1393 DeclarationMirror _owner;
1390 DeclarationMirror get owner { 1394 DeclarationMirror get owner {
1391 // For nested closures it is possible, that the mirror for the owner has not 1395 // For nested closures it is possible, that the mirror for the owner has not
1392 // been created yet. 1396 // been created yet.
1393 if (_owner == null) { 1397 if (_owner == null) {
1394 _owner = _MethodMirror_owner(_reflectee); 1398 _owner = _MethodMirror_owner(_reflectee, _instantiator);
1395 } 1399 }
1396 return _owner; 1400 return _owner;
1397 } 1401 }
1398 1402
1399 bool get isPrivate => _n(simpleName).startsWith('_') || 1403 bool get isPrivate => _n(simpleName).startsWith('_') ||
1400 _n(constructorName).startsWith('_'); 1404 _n(constructorName).startsWith('_');
1401 1405
1402 bool get isTopLevel => owner is LibraryMirror; 1406 bool get isTopLevel => owner is LibraryMirror;
1403 bool get isSynthetic => false; 1407 bool get isSynthetic => false;
1404 1408
1405 Type get _instantiator {
1406 var o = owner;
1407 while (o is MethodMirror) o = o.owner;
1408 return o._instantiator;
1409 }
1410
1411 TypeMirror _returnType = null; 1409 TypeMirror _returnType = null;
1412 TypeMirror get returnType { 1410 TypeMirror get returnType {
1413 if (_returnType == null) { 1411 if (_returnType == null) {
1414 if (isConstructor) { 1412 if (isConstructor) {
1415 _returnType = owner; 1413 _returnType = owner;
1416 } else { 1414 } else {
1417 _returnType = reflectType( 1415 _returnType = reflectType(
1418 _MethodMirror_return_type(_reflectee, _instantiator)); 1416 _MethodMirror_return_type(_reflectee, _instantiator));
1419 } 1417 }
1420 } 1418 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 var cn = _n(constructorName); 1464 var cn = _n(constructorName);
1467 if(cn == ''){ 1465 if(cn == ''){
1468 _simpleName = _s(ownerName); 1466 _simpleName = _s(ownerName);
1469 } else { 1467 } else {
1470 _simpleName = _s(ownerName + "." + cn); 1468 _simpleName = _s(ownerName + "." + cn);
1471 } 1469 }
1472 } 1470 }
1473 1471
1474 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'"; 1472 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'";
1475 1473
1476 static dynamic _MethodMirror_owner(reflectee) 1474 static dynamic _MethodMirror_owner(reflectee, instantiator)
1477 native "MethodMirror_owner"; 1475 native "MethodMirror_owner";
1478 1476
1479 static dynamic _MethodMirror_return_type(reflectee, instantiator) 1477 static dynamic _MethodMirror_return_type(reflectee, instantiator)
1480 native "MethodMirror_return_type"; 1478 native "MethodMirror_return_type";
1481 1479
1482 List<ParameterMirror> _MethodMirror_parameters(reflectee) 1480 List<ParameterMirror> _MethodMirror_parameters(reflectee)
1483 native "MethodMirror_parameters"; 1481 native "MethodMirror_parameters";
1484 1482
1485 static String _MethodMirror_source(reflectee) 1483 static String _MethodMirror_source(reflectee)
1486 native "MethodMirror_source"; 1484 native "MethodMirror_source";
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 SourceLocation get location { 1562 SourceLocation get location {
1565 throw new UnsupportedError("ParameterMirror.location unimplemented"); 1563 throw new UnsupportedError("ParameterMirror.location unimplemented");
1566 } 1564 }
1567 1565
1568 List<InstanceMirror> get metadata { 1566 List<InstanceMirror> get metadata {
1569 if (_unmirroredMetadata == null) return emptyList; 1567 if (_unmirroredMetadata == null) return emptyList;
1570 return new UnmodifiableListView(_unmirroredMetadata.map(reflect)); 1568 return new UnmodifiableListView(_unmirroredMetadata.map(reflect));
1571 } 1569 }
1572 1570
1573 Type get _instantiator { 1571 Type get _instantiator {
1574 var o = owner; 1572 return owner._instantiator;
1575 while (o is MethodMirror) o = o.owner;
1576 return o._instantiator;
1577 } 1573 }
1578 1574
1579 TypeMirror _type = null; 1575 TypeMirror _type = null;
1580 TypeMirror get type { 1576 TypeMirror get type {
1581 if (_type == null) { 1577 if (_type == null) {
1582 _type = reflectType( 1578 _type = reflectType(
1583 _ParameterMirror_type(_reflectee, _position, _instantiator)); 1579 _ParameterMirror_type(_reflectee, _position, _instantiator));
1584 } 1580 }
1585 return _type; 1581 return _type;
1586 } 1582 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 if (typeMirror == null) { 1684 if (typeMirror == null) {
1689 typeMirror = makeLocalTypeMirror(key); 1685 typeMirror = makeLocalTypeMirror(key);
1690 _instanitationCache[key] = typeMirror; 1686 _instanitationCache[key] = typeMirror;
1691 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1687 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1692 _declarationCache[key] = typeMirror; 1688 _declarationCache[key] = typeMirror;
1693 } 1689 }
1694 } 1690 }
1695 return typeMirror; 1691 return typeMirror;
1696 } 1692 }
1697 } 1693 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698