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

Side by Side Diff: reflectable/lib/src/reflectable_transformer_based.dart

Issue 1473073009: Added `dynamicReflected..Type`, corrected type expressions. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Review response. Created 5 years 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
OLDNEW
1 // Copyright (c) 2015, the Dart Team. All rights reserved. Use of this 1 // Copyright (c) 2015, the Dart Team. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in 2 // source code is governed by a BSD-style license that can be found in
3 // the LICENSE file. 3 // the LICENSE file.
4 4
5 library reflectable.src.mirrors_unimpl; 5 library reflectable.src.mirrors_unimpl;
6 6
7 import 'dart:collection' show UnmodifiableMapView, UnmodifiableListView; 7 import 'dart:collection' show UnmodifiableMapView, UnmodifiableListView;
8 8
9 import '../capability.dart'; 9 import '../capability.dart';
10 import '../mirrors.dart'; 10 import '../mirrors.dart';
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 545
546 @override 546 @override
547 TypeMirror get originalDeclaration => this; 547 TypeMirror get originalDeclaration => this;
548 548
549 @override 549 @override
550 bool get hasReflectedType => true; 550 bool get hasReflectedType => true;
551 551
552 @override 552 @override
553 Type get reflectedType => _data.types[_classIndex]; 553 Type get reflectedType => _data.types[_classIndex];
554 554
555 @override
556 bool get hasDynamicReflectedType => true;
557
558 @override
559 Type get dynamicReflectedType => reflectedType;
560
555 String toString() => "NonGenericClassMirrorImpl($qualifiedName)"; 561 String toString() => "NonGenericClassMirrorImpl($qualifiedName)";
556 } 562 }
557 563
558 typedef bool InstanceChecker(Object instance); 564 typedef bool InstanceChecker(Object instance);
559 565
560 class GenericClassMirrorImpl extends ClassMirrorImpl { 566 class GenericClassMirrorImpl extends ClassMirrorImpl {
561 /// Used to enable instance checks. Let O be an instance and let C denote the 567 /// Used to enable instance checks. Let O be an instance and let C denote the
562 /// generic class modeled by this mirror. The check is then such that the 568 /// generic class modeled by this mirror. The check is then such that the
563 /// result is true iff there exists a list of type arguments X1..Xk such that 569 /// result is true iff there exists a list of type arguments X1..Xk such that
564 /// O is an instance of C<X1..Xk>. We can perform this check by checking that 570 /// O is an instance of C<X1..Xk>. We can perform this check by checking that
565 /// O is an instance of C<dynamic .. dynamic>, and O is not an instance 571 /// O is an instance of C<dynamic .. dynamic>, and O is not an instance
566 /// of any of Dj<dynamic .. dynamic> for j in {1..n}, where D1..Dn is the 572 /// of any of Dj<dynamic .. dynamic> for j in {1..n}, where D1..Dn is the
567 /// complete set of classes in the current program which are direct 573 /// complete set of classes in the current program which are direct
568 /// subinterfaces of C (i.e., classes which directly `extends` or `implements` 574 /// subinterfaces of C (i.e., classes which directly `extends` or `implements`
569 /// C). The check is implemented by this function. 575 /// C). The check is implemented by this function.
570 final InstanceChecker _isGenericRuntimeTypeOf; 576 final InstanceChecker _isGenericRuntimeTypeOf;
571 577
572 final List<int> _typeVariableIndices; 578 final List<int> _typeVariableIndices;
573 579
580 final Type _dynamicReflectedType;
581
574 GenericClassMirrorImpl( 582 GenericClassMirrorImpl(
575 String simpleName, 583 String simpleName,
576 String qualifiedName, 584 String qualifiedName,
577 int descriptor, 585 int descriptor,
578 int classIndex, 586 int classIndex,
579 ReflectableImpl reflector, 587 ReflectableImpl reflector,
580 List<int> declarationIndices, 588 List<int> declarationIndices,
581 List<int> instanceMemberIndices, 589 List<int> instanceMemberIndices,
582 List<int> staticMemberIndices, 590 List<int> staticMemberIndices,
583 int superclassIndex, 591 int superclassIndex,
584 Map<String, _StaticGetter> getters, 592 Map<String, _StaticGetter> getters,
585 Map<String, _StaticSetter> setters, 593 Map<String, _StaticSetter> setters,
586 Map<String, Function> constructors, 594 Map<String, Function> constructors,
587 int ownerIndex, 595 int ownerIndex,
588 int mixinIndex, 596 int mixinIndex,
589 List<int> superinterfaceIndices, 597 List<int> superinterfaceIndices,
590 List<Object> metadata, 598 List<Object> metadata,
591 this._isGenericRuntimeTypeOf, 599 this._isGenericRuntimeTypeOf,
592 this._typeVariableIndices) 600 this._typeVariableIndices,
601 this._dynamicReflectedType)
593 : super( 602 : super(
594 simpleName, 603 simpleName,
595 qualifiedName, 604 qualifiedName,
596 descriptor, 605 descriptor,
597 classIndex, 606 classIndex,
598 reflector, 607 reflector,
599 declarationIndices, 608 declarationIndices,
600 instanceMemberIndices, 609 instanceMemberIndices,
601 staticMemberIndices, 610 staticMemberIndices,
602 superclassIndex, 611 superclassIndex,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 648
640 @override 649 @override
641 bool get hasReflectedType => false; 650 bool get hasReflectedType => false;
642 651
643 @override 652 @override
644 Type get reflectedType { 653 Type get reflectedType {
645 throw new UnsupportedError("Attempt to obtain `reflectedType` " 654 throw new UnsupportedError("Attempt to obtain `reflectedType` "
646 "from generic class '$qualifiedName'."); 655 "from generic class '$qualifiedName'.");
647 } 656 }
648 657
658 @override
659 bool get hasDynamicReflectedType => true;
660
661 @override
662 Type get dynamicReflectedType => _dynamicReflectedType;
663
649 String toString() => "GenericClassMirrorImpl($qualifiedName)"; 664 String toString() => "GenericClassMirrorImpl($qualifiedName)";
650 } 665 }
651 666
652 class InstantiatedGenericClassMirrorImpl extends ClassMirrorImpl { 667 class InstantiatedGenericClassMirrorImpl extends ClassMirrorImpl {
653 final GenericClassMirrorImpl _originalDeclaration; 668 final GenericClassMirrorImpl _originalDeclaration;
654 final Type _reflectedType; 669 final Type _reflectedType;
655 670
656 InstantiatedGenericClassMirrorImpl( 671 InstantiatedGenericClassMirrorImpl(
657 String simpleName, 672 String simpleName,
658 String qualifiedName, 673 String qualifiedName,
(...skipping 26 matching lines...) Expand all
685 getters, 700 getters,
686 setters, 701 setters,
687 constructors, 702 constructors,
688 ownerIndex, 703 ownerIndex,
689 mixinIndex, 704 mixinIndex,
690 superinterfaceIndices, 705 superinterfaceIndices,
691 metadata); 706 metadata);
692 707
693 // TODO(sigurdm) implement: Implement typeArguments. 708 // TODO(sigurdm) implement: Implement typeArguments.
694 @override 709 @override
695 List<TypeMirror> get typeArguments => throw unimplementedError("typeArguments" ); 710 List<TypeMirror> get typeArguments =>
711 throw unimplementedError("typeArguments");
696 712
697 @override 713 @override
698 List<TypeVariableMirror> get typeVariables => 714 List<TypeVariableMirror> get typeVariables =>
699 originalDeclaration.typeVariables; 715 originalDeclaration.typeVariables;
700 716
701 @override 717 @override
702 bool get isOriginalDeclaration => false; 718 bool get isOriginalDeclaration => false;
703 719
704 @override 720 @override
705 TypeMirror get originalDeclaration => _originalDeclaration; 721 TypeMirror get originalDeclaration => _originalDeclaration;
706 722
707 @override 723 @override
708 bool get hasReflectedType => _reflectedType != null; 724 bool get hasReflectedType => _reflectedType != null;
709 725
710 @override 726 @override
711 Type get reflectedType { 727 Type get reflectedType {
712 if (_reflectedType != null) return _reflectedType; 728 if (_reflectedType != null) return _reflectedType;
713 throw new UnsupportedError("Cannot provide `reflectedType` of " 729 throw new UnsupportedError("Cannot provide `reflectedType` of "
714 "instance of generic type '$simpleName'."); 730 "instance of generic type '$simpleName'.");
715 } 731 }
716 732
733 @override
734 bool get hasDynamicReflectedType =>
735 _originalDeclaration.hasDynamicReflectedType;
736
737 @override
738 Type get dynamicReflectedType => _originalDeclaration.dynamicReflectedType;
739
717 String toString() => "InstantiatedGenericClassMirrorImpl($qualifiedName)"; 740 String toString() => "InstantiatedGenericClassMirrorImpl($qualifiedName)";
718 } 741 }
719 742
720 InstantiatedGenericClassMirrorImpl _createInstantiatedGenericClass( 743 InstantiatedGenericClassMirrorImpl _createInstantiatedGenericClass(
721 GenericClassMirrorImpl genericClassMirror, Type reflectedType) { 744 GenericClassMirrorImpl genericClassMirror, Type reflectedType) {
722 // TODO(eernst) implement: Pass a representation of type arguments to this 745 // TODO(eernst) implement: Pass a representation of type arguments to this
723 // method, and create an instantiated generic class which includes that 746 // method, and create an instantiated generic class which includes that
724 // information. 747 // information.
725 return new InstantiatedGenericClassMirrorImpl( 748 return new InstantiatedGenericClassMirrorImpl(
726 genericClassMirror.simpleName, 749 genericClassMirror.simpleName,
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 /// The index of the [ClassMirror] of the owner of this method, respectively 1006 /// The index of the [ClassMirror] of the owner of this method, respectively
984 /// the [LibraryMirror] of the owner of this top-level function, 1007 /// the [LibraryMirror] of the owner of this top-level function,
985 final int _ownerIndex; 1008 final int _ownerIndex;
986 1009
987 /// The index of the mirror for the return type of this method. 1010 /// The index of the mirror for the return type of this method.
988 final int _returnTypeIndex; 1011 final int _returnTypeIndex;
989 1012
990 /// The return type of this method. 1013 /// The return type of this method.
991 final Type _reflectedReturnType; 1014 final Type _reflectedReturnType;
992 1015
1016 /// The return type of this method, erased to have `dynamic` for all
1017 /// type arguments; a null value indicates that it is identical to
1018 /// `reflectedReturnType` if that value is available they are equal; if
1019 /// `reflectedReturnType` is unavailable then so is
1020 /// `dynamicReflectedReturnType`.
1021 final Type _dynamicReflectedReturnType;
1022
993 /// The indices of the [ParameterMirror]s describing the formal parameters 1023 /// The indices of the [ParameterMirror]s describing the formal parameters
994 /// of this method. 1024 /// of this method.
995 final List<int> _parameterIndices; 1025 final List<int> _parameterIndices;
996 1026
997 /// The [Reflectable] associated with this mirror. 1027 /// The [Reflectable] associated with this mirror.
998 final ReflectableImpl _reflector; 1028 final ReflectableImpl _reflector;
999 1029
1000 /// A cache of the metadata of the mirrored method. The empty list means 1030 /// A cache of the metadata of the mirrored method. The empty list means
1001 /// no metadata, null means that [_reflector] does not have 1031 /// no metadata, null means that [_reflector] does not have
1002 /// [metadataCapability]. 1032 /// [metadataCapability].
1003 final List<Object> _metadata; 1033 final List<Object> _metadata;
1004 1034
1005 MethodMirrorImpl( 1035 MethodMirrorImpl(
1006 this._name, 1036 this._name,
1007 this._descriptor, 1037 this._descriptor,
1008 this._ownerIndex, 1038 this._ownerIndex,
1009 this._returnTypeIndex, 1039 this._returnTypeIndex,
1010 this._reflectedReturnType, 1040 this._reflectedReturnType,
1041 this._dynamicReflectedReturnType,
1011 this._parameterIndices, 1042 this._parameterIndices,
1012 this._reflector, 1043 this._reflector,
1013 this._metadata); 1044 this._metadata);
1014 1045
1015 int get kind => constants.kindFromEncoding(_descriptor); 1046 int get kind => constants.kindFromEncoding(_descriptor);
1016 1047
1017 DeclarationMirror get owner { 1048 DeclarationMirror get owner {
1018 if (_ownerIndex == NO_CAPABILITY_INDEX) { 1049 if (_ownerIndex == NO_CAPABILITY_INDEX) {
1019 throw new NoSuchCapabilityError( 1050 throw new NoSuchCapabilityError(
1020 "Trying to get owner of method '$qualifiedName' " 1051 "Trying to get owner of method '$qualifiedName' "
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 Type get reflectedReturnType { 1162 Type get reflectedReturnType {
1132 if (_reflectedReturnType == null) { 1163 if (_reflectedReturnType == null) {
1133 throw new NoSuchCapabilityError( 1164 throw new NoSuchCapabilityError(
1134 "Requesting reflectedReturnType of method " 1165 "Requesting reflectedReturnType of method "
1135 "'$simpleName' without capability"); 1166 "'$simpleName' without capability");
1136 } 1167 }
1137 return _reflectedReturnType; 1168 return _reflectedReturnType;
1138 } 1169 }
1139 1170
1140 @override 1171 @override
1172 bool get hasDynamicReflectedReturnType =>
1173 _dynamicReflectedReturnType != null || hasReflectedReturnType;
1174
1175 @override
1176 Type get dynamicReflectedReturnType {
1177 return _dynamicReflectedReturnType != null
1178 ? _dynamicReflectedReturnType
1179 : reflectedReturnType;
1180 }
1181
1182 @override
1141 String get simpleName => isConstructor 1183 String get simpleName => isConstructor
1142 ? (_name == '' ? "${owner.simpleName}" : "${owner.simpleName}.$_name") 1184 ? (_name == '' ? "${owner.simpleName}" : "${owner.simpleName}.$_name")
1143 : _name; 1185 : _name;
1144 1186
1145 @override 1187 @override
1146 String get source => null; 1188 String get source => null;
1147 1189
1148 @override 1190 @override
1149 String toString() => "MethodMirrorImpl($qualifiedName)"; 1191 String toString() => "MethodMirrorImpl($qualifiedName)";
1150 } 1192 }
1151 1193
1152 abstract class ImplicitAccessorMirrorImpl extends _DataCaching 1194 abstract class ImplicitAccessorMirrorImpl extends _DataCaching
1153 implements MethodMirror { 1195 implements MethodMirror {
1154 final ReflectableImpl _reflector; 1196 final ReflectableImpl _reflector;
1155 final int _variableMirrorIndex; 1197 final int _variableMirrorIndex;
1156 final Type _reflectedType; 1198 final Type _reflectedType;
1199 final Type _dynamicReflectedType;
1157 1200
1158 /// Index of this [ImplicitAccessorMirrorImpl] in `_data.memberMirrors`. 1201 /// Index of this [ImplicitAccessorMirrorImpl] in `_data.memberMirrors`.
1159 final int _selfIndex; 1202 final int _selfIndex;
1160 1203
1161 VariableMirrorImpl get _variableMirror => 1204 VariableMirrorImpl get _variableMirror =>
1162 _data.memberMirrors[_variableMirrorIndex]; 1205 _data.memberMirrors[_variableMirrorIndex];
1163 1206
1164 ImplicitAccessorMirrorImpl(this._reflector, this._variableMirrorIndex, 1207 ImplicitAccessorMirrorImpl(this._reflector, this._variableMirrorIndex,
1165 this._reflectedType, this._selfIndex); 1208 this._reflectedType, this._dynamicReflectedType, this._selfIndex);
1166 1209
1167 int get kind => constants.kindFromEncoding(_variableMirror._descriptor); 1210 int get kind => constants.kindFromEncoding(_variableMirror._descriptor);
1168 1211
1169 DeclarationMirror get owner => _variableMirror.owner; 1212 DeclarationMirror get owner => _variableMirror.owner;
1170 1213
1171 @override 1214 @override
1172 String get constructorName => ""; 1215 String get constructorName => "";
1173 1216
1174 @override 1217 @override
1175 bool get isAbstract => false; 1218 bool get isAbstract => false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 @override 1260 @override
1218 TypeMirror get returnType => _variableMirror.type; 1261 TypeMirror get returnType => _variableMirror.type;
1219 1262
1220 @override 1263 @override
1221 bool get hasReflectedReturnType => _variableMirror.hasReflectedType; 1264 bool get hasReflectedReturnType => _variableMirror.hasReflectedType;
1222 1265
1223 @override 1266 @override
1224 Type get reflectedReturnType => _variableMirror.reflectedType; 1267 Type get reflectedReturnType => _variableMirror.reflectedType;
1225 1268
1226 @override 1269 @override
1270 bool get hasDynamicReflectedReturnType =>
1271 _variableMirror.hasDynamicReflectedType;
1272
1273 @override
1274 Type get dynamicReflectedReturnType => _variableMirror.dynamicReflectedType;
1275
1276 @override
1227 String get source => null; 1277 String get source => null;
1228 } 1278 }
1229 1279
1230 class ImplicitGetterMirrorImpl extends ImplicitAccessorMirrorImpl { 1280 class ImplicitGetterMirrorImpl extends ImplicitAccessorMirrorImpl {
1231 ImplicitGetterMirrorImpl(ReflectableImpl reflector, int variableMirrorIndex, 1281 ImplicitGetterMirrorImpl(ReflectableImpl reflector, int variableMirrorIndex,
1232 Type reflectedType, int selfIndex) 1282 Type reflectedType, Type dynamicReflectedType, int selfIndex)
1233 : super(reflector, variableMirrorIndex, reflectedType, selfIndex); 1283 : super(reflector, variableMirrorIndex, reflectedType,
1284 dynamicReflectedType, selfIndex);
1234 1285
1235 @override 1286 @override
1236 bool get isGetter => true; 1287 bool get isGetter => true;
1237 1288
1238 @override 1289 @override
1239 bool get isSetter => false; 1290 bool get isSetter => false;
1240 1291
1241 @override 1292 @override
1242 List<ParameterMirror> get parameters => <ParameterMirror>[]; 1293 List<ParameterMirror> get parameters => <ParameterMirror>[];
1243 1294
1244 @override 1295 @override
1245 String get qualifiedName => _variableMirror.qualifiedName; 1296 String get qualifiedName => _variableMirror.qualifiedName;
1246 1297
1247 @override 1298 @override
1248 String get simpleName => _variableMirror.simpleName; 1299 String get simpleName => _variableMirror.simpleName;
1249 1300
1250 @override 1301 @override
1251 String toString() => "ImplicitGetterMirrorImpl($qualifiedName)"; 1302 String toString() => "ImplicitGetterMirrorImpl($qualifiedName)";
1252 } 1303 }
1253 1304
1254 class ImplicitSetterMirrorImpl extends ImplicitAccessorMirrorImpl { 1305 class ImplicitSetterMirrorImpl extends ImplicitAccessorMirrorImpl {
1255 ImplicitSetterMirrorImpl(ReflectableImpl reflector, int variableMirrorIndex, 1306 ImplicitSetterMirrorImpl(ReflectableImpl reflector, int variableMirrorIndex,
1256 Type reflectedType, int selfIndex) 1307 Type reflectedType, Type dynamicReflectedType, int selfIndex)
1257 : super(reflector, variableMirrorIndex, reflectedType, selfIndex); 1308 : super(reflector, variableMirrorIndex, reflectedType,
1309 dynamicReflectedType, selfIndex);
1258 1310
1259 @override 1311 @override
1260 bool get isGetter => false; 1312 bool get isGetter => false;
1261 1313
1262 @override 1314 @override
1263 bool get isSetter => true; 1315 bool get isSetter => true;
1264 1316
1265 int get _parameterDescriptor { 1317 int get _parameterDescriptor {
1266 int descriptor = constants.parameter; 1318 int descriptor = constants.parameter;
1267 if (_variableMirror.isStatic) descriptor |= constants.staticAttribute; 1319 if (_variableMirror.isStatic) descriptor |= constants.staticAttribute;
1268 if (_variableMirror.isPrivate) descriptor |= constants.privateAttribute; 1320 if (_variableMirror.isPrivate) descriptor |= constants.privateAttribute;
1269 descriptor |= constants.syntheticAttribute; 1321 descriptor |= constants.syntheticAttribute;
1270 if (_variableMirror._isDynamic) descriptor |= constants.dynamicAttribute; 1322 if (_variableMirror._isDynamic) descriptor |= constants.dynamicAttribute;
1271 if (_variableMirror._isClassType) descriptor |= 1323 if (_variableMirror._isClassType) descriptor |=
1272 constants.classTypeAttribute; 1324 constants.classTypeAttribute;
1273 return descriptor; 1325 return descriptor;
1274 } 1326 }
1275 1327
1276 @override 1328 @override
1277 List<ParameterMirror> get parameters { 1329 List<ParameterMirror> get parameters {
1278 return <ParameterMirror>[ 1330 return <ParameterMirror>[
1279 new ParameterMirrorImpl( 1331 new ParameterMirrorImpl(
1280 _variableMirror.simpleName, 1332 _variableMirror.simpleName,
1281 _parameterDescriptor, 1333 _parameterDescriptor,
1282 _selfIndex, 1334 _selfIndex,
1283 _variableMirror._reflector, 1335 _variableMirror._reflector,
1284 _variableMirror._classMirrorIndex, 1336 _variableMirror._classMirrorIndex,
1285 _variableMirror._reflectedType, 1337 _variableMirror._reflectedType,
1338 _variableMirror._dynamicReflectedType,
1286 <Object>[], 1339 <Object>[],
1287 null) 1340 null)
1288 ]; 1341 ];
1289 } 1342 }
1290 1343
1291 @override 1344 @override
1292 String get qualifiedName => "${_variableMirror.qualifiedName}="; 1345 String get qualifiedName => "${_variableMirror.qualifiedName}=";
1293 1346
1294 @override 1347 @override
1295 String get simpleName => "${_variableMirror.simpleName}="; 1348 String get simpleName => "${_variableMirror.simpleName}=";
1296 1349
1297 @override 1350 @override
1298 String toString() => "ImplicitSetterMirrorImpl($qualifiedName)"; 1351 String toString() => "ImplicitSetterMirrorImpl($qualifiedName)";
1299 } 1352 }
1300 1353
1301 abstract class VariableMirrorBase extends _DataCaching 1354 abstract class VariableMirrorBase extends _DataCaching
1302 implements VariableMirror { 1355 implements VariableMirror {
1303 final String _name; 1356 final String _name;
1304 final int _descriptor; 1357 final int _descriptor;
1305 final int _ownerIndex; 1358 final int _ownerIndex;
1306 final ReflectableImpl _reflector; 1359 final ReflectableImpl _reflector;
1307 final int _classMirrorIndex; 1360 final int _classMirrorIndex;
1308 final Type _reflectedType; 1361 final Type _reflectedType;
1362 final Type _dynamicReflectedType;
1309 final List<Object> _metadata; 1363 final List<Object> _metadata;
1310 1364
1311 VariableMirrorBase( 1365 VariableMirrorBase(
1312 this._name, 1366 this._name,
1313 this._descriptor, 1367 this._descriptor,
1314 this._ownerIndex, 1368 this._ownerIndex,
1315 this._reflector, 1369 this._reflector,
1316 this._classMirrorIndex, 1370 this._classMirrorIndex,
1317 this._reflectedType, 1371 this._reflectedType,
1372 this._dynamicReflectedType,
1318 this._metadata); 1373 this._metadata);
1319 1374
1320 int get kind => constants.kindFromEncoding(_descriptor); 1375 int get kind => constants.kindFromEncoding(_descriptor);
1321 1376
1322 @override 1377 @override
1323 bool get isPrivate => (_descriptor & constants.privateAttribute != 0); 1378 bool get isPrivate => (_descriptor & constants.privateAttribute != 0);
1324 1379
1325 @override 1380 @override
1326 bool get isTopLevel => (_descriptor & constants.topLevelAttribute != 0); 1381 bool get isTopLevel => (_descriptor & constants.topLevelAttribute != 0);
1327 1382
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1430
1376 @override 1431 @override
1377 Type get reflectedType { 1432 Type get reflectedType {
1378 if (_reflectedType == null) { 1433 if (_reflectedType == null) {
1379 throw new NoSuchCapabilityError( 1434 throw new NoSuchCapabilityError(
1380 "Attempt to get reflectedType without capability (of '$_name')"); 1435 "Attempt to get reflectedType without capability (of '$_name')");
1381 } 1436 }
1382 return _reflectedType; 1437 return _reflectedType;
1383 } 1438 }
1384 1439
1440 @override
1441 bool get hasDynamicReflectedType =>
1442 _dynamicReflectedType != null || hasReflectedType;
1443
1444 @override
1445 Type get dynamicReflectedType =>
1446 _dynamicReflectedType != null ? _dynamicReflectedType : reflectedType;
1447
1385 // Note that [operator ==] is redefined slightly differently in the two 1448 // Note that [operator ==] is redefined slightly differently in the two
1386 // subtypes of this class, but they share this [hashCode] implementation. 1449 // subtypes of this class, but they share this [hashCode] implementation.
1387 @override 1450 @override
1388 int get hashCode => simpleName.hashCode ^ owner.hashCode; 1451 int get hashCode => simpleName.hashCode ^ owner.hashCode;
1389 } 1452 }
1390 1453
1391 class VariableMirrorImpl extends VariableMirrorBase { 1454 class VariableMirrorImpl extends VariableMirrorBase {
1392 @override 1455 @override
1393 DeclarationMirror get owner { 1456 DeclarationMirror get owner {
1394 if (_ownerIndex == NO_CAPABILITY_INDEX) { 1457 if (_ownerIndex == NO_CAPABILITY_INDEX) {
(...skipping 12 matching lines...) Expand all
1407 @override 1470 @override
1408 bool get isConst => (_descriptor & constants.constAttribute != 0); 1471 bool get isConst => (_descriptor & constants.constAttribute != 0);
1409 1472
1410 VariableMirrorImpl( 1473 VariableMirrorImpl(
1411 String name, 1474 String name,
1412 int descriptor, 1475 int descriptor,
1413 int ownerIndex, 1476 int ownerIndex,
1414 ReflectableImpl reflectable, 1477 ReflectableImpl reflectable,
1415 int classMirrorIndex, 1478 int classMirrorIndex,
1416 Type reflectedType, 1479 Type reflectedType,
1480 Type dynamicReflectedType,
1417 List<Object> metadata) 1481 List<Object> metadata)
1418 : super(name, descriptor, ownerIndex, reflectable, classMirrorIndex, 1482 : super(name, descriptor, ownerIndex, reflectable, classMirrorIndex,
1419 reflectedType, metadata); 1483 reflectedType, dynamicReflectedType, metadata);
1420 1484
1421 // Note that the corresponding implementation of [hashCode] is inherited from 1485 // Note that the corresponding implementation of [hashCode] is inherited from
1422 // [VariableMirrorBase]. 1486 // [VariableMirrorBase].
1423 @override 1487 @override
1424 bool operator ==(other) => other is VariableMirrorImpl && 1488 bool operator ==(other) => other is VariableMirrorImpl &&
1425 other.simpleName == simpleName && 1489 other.simpleName == simpleName &&
1426 other.owner == owner; 1490 other.owner == owner;
1427 } 1491 }
1428 1492
1429 class ParameterMirrorImpl extends VariableMirrorBase 1493 class ParameterMirrorImpl extends VariableMirrorBase
(...skipping 20 matching lines...) Expand all
1450 @override 1514 @override
1451 MethodMirror get owner => _data.memberMirrors[_ownerIndex]; 1515 MethodMirror get owner => _data.memberMirrors[_ownerIndex];
1452 1516
1453 ParameterMirrorImpl( 1517 ParameterMirrorImpl(
1454 String name, 1518 String name,
1455 int descriptor, 1519 int descriptor,
1456 int ownerIndex, 1520 int ownerIndex,
1457 ReflectableImpl reflectable, 1521 ReflectableImpl reflectable,
1458 int classMirrorIndex, 1522 int classMirrorIndex,
1459 Type reflectedType, 1523 Type reflectedType,
1524 Type dynamicReflectedType,
1460 List<Object> metadata, 1525 List<Object> metadata,
1461 this.defaultValue) 1526 this.defaultValue)
1462 : super(name, descriptor, ownerIndex, reflectable, classMirrorIndex, 1527 : super(name, descriptor, ownerIndex, reflectable, classMirrorIndex,
1463 reflectedType, metadata); 1528 reflectedType, dynamicReflectedType, metadata);
1464 1529
1465 // Note that the corresponding implementation of [hashCode] is inherited from 1530 // Note that the corresponding implementation of [hashCode] is inherited from
1466 // [VariableMirrorBase]. 1531 // [VariableMirrorBase].
1467 @override 1532 @override
1468 bool operator ==(other) => other is ParameterMirrorImpl && 1533 bool operator ==(other) => other is ParameterMirrorImpl &&
1469 other.simpleName == simpleName && 1534 other.simpleName == simpleName &&
1470 other.owner == owner; 1535 other.owner == owner;
1471 } 1536 }
1472 1537
1473 class DynamicMirrorImpl implements TypeMirror { 1538 class DynamicMirrorImpl implements TypeMirror {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 1596
1532 // TODO(eernst) implement: test what 'dart:mirrors' does, then do the same. 1597 // TODO(eernst) implement: test what 'dart:mirrors' does, then do the same.
1533 @override 1598 @override
1534 bool get isOriginalDeclaration => true; 1599 bool get isOriginalDeclaration => true;
1535 1600
1536 @override 1601 @override
1537 bool get hasReflectedType => false; 1602 bool get hasReflectedType => false;
1538 1603
1539 @override 1604 @override
1540 Type get reflectedType => 1605 Type get reflectedType =>
1541 throw new UnsupportedError("Attempt to get the reflected type of 'void'"); 1606 throw new UnsupportedError("Attempt to get the reflected type of `void`");
1542 1607
1543 @override 1608 @override
1544 String get simpleName => "void"; 1609 String get simpleName => "void";
1545 1610
1546 // TODO(eernst) implement: do as in 'dart:mirrors'. 1611 // TODO(eernst) implement: do as in 'dart:mirrors'.
1547 @override 1612 @override
1548 List<TypeVariableMirror> get typeVariables => <TypeVariableMirror>[]; 1613 List<TypeVariableMirror> get typeVariables => <TypeVariableMirror>[];
1549 1614
1550 @override 1615 @override
1551 List<TypeMirror> get typeArguments => <TypeMirror>[]; 1616 List<TypeMirror> get typeArguments => <TypeMirror>[];
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 const FakeType(this.description); 1729 const FakeType(this.description);
1665 1730
1666 final String description; 1731 final String description;
1667 1732
1668 String toString() => "Type($description)"; 1733 String toString() => "Type($description)";
1669 } 1734 }
1670 1735
1671 bool _isSetterName(String name) => name.endsWith("="); 1736 bool _isSetterName(String name) => name.endsWith("=");
1672 1737
1673 String _getterNameToSetterName(String name) => name + "="; 1738 String _getterNameToSetterName(String name) => name + "=";
OLDNEW
« no previous file with comments | « reflectable/lib/src/reflectable_mirror_based.dart ('k') | reflectable/lib/src/setup_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698