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

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

Issue 132133003: Extend the immutable collections test to the new API. Make *Members return immutable collections. A… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « no previous file | tests/lib/mirrors/immutable_collections_test.dart » ('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"; 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 bool get isOptional => false; 216 bool get isOptional => false;
217 bool get isNamed => false; 217 bool get isNamed => false;
218 bool get isStatic => false; 218 bool get isStatic => false;
219 bool get isTopLevel => false; 219 bool get isTopLevel => false;
220 bool get isConst => false; 220 bool get isConst => false;
221 bool get isFinal => true; 221 bool get isFinal => true;
222 bool get isPrivate => false; 222 bool get isPrivate => false;
223 bool get hasDefaultValue => false; 223 bool get hasDefaultValue => false;
224 InstanceMirror get defaultValue => null; 224 InstanceMirror get defaultValue => null;
225 List<InstanceMirror> get metadata => emptyList;
225 } 226 }
226 227
227 abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror { 228 abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror {
228 final _reflectee; // May be a MirrorReference or an ordinary object. 229 final _reflectee; // May be a MirrorReference or an ordinary object.
229 230
230 _LocalObjectMirror(this._reflectee); 231 _LocalObjectMirror(this._reflectee);
231 232
232 InstanceMirror invoke(Symbol memberName, 233 InstanceMirror invoke(Symbol memberName,
233 List positionalArguments, 234 List positionalArguments,
234 [Map<Symbol, dynamic> namedArguments]) { 235 [Map<Symbol, dynamic> namedArguments]) {
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 var getterName = decl.simpleName; 575 var getterName = decl.simpleName;
575 result[getterName] = 576 result[getterName] =
576 new _SyntheticAccessor(this, getterName, true, true, false, decl); 577 new _SyntheticAccessor(this, getterName, true, true, false, decl);
577 if (!decl.isFinal) { 578 if (!decl.isFinal) {
578 var setterName = _asSetter(decl.simpleName, this.owner); 579 var setterName = _asSetter(decl.simpleName, this.owner);
579 result[setterName] = new _SyntheticAccessor( 580 result[setterName] = new _SyntheticAccessor(
580 this, setterName, false, true, false, decl); 581 this, setterName, false, true, false, decl);
581 } 582 }
582 } 583 }
583 }); 584 });
584 _cachedStaticMembers = result; 585 _cachedStaticMembers =
586 new _UnmodifiableMapView<Symbol, MethodMirror>(result);
585 } 587 }
586 return _cachedStaticMembers; 588 return _cachedStaticMembers;
587 } 589 }
588 590
589 var _cachedInstanceMembers; 591 var _cachedInstanceMembers;
590 Map<Symbol, MethodMirror> get instanceMembers { 592 Map<Symbol, MethodMirror> get instanceMembers {
591 if (_cachedInstanceMembers == null) { 593 if (_cachedInstanceMembers == null) {
592 var result = new Map<Symbol, MethodMirror>(); 594 var result = new Map<Symbol, MethodMirror>();
593 if (superclass != null) { 595 if (superclass != null) {
594 result.addAll(superclass.instanceMembers); 596 result.addAll(superclass.instanceMembers);
595 } 597 }
596 declarations.values.forEach((decl) { 598 declarations.values.forEach((decl) {
597 if (decl is MethodMirror && !decl.isStatic && 599 if (decl is MethodMirror && !decl.isStatic &&
598 !decl.isConstructor && !decl.isAbstract) { 600 !decl.isConstructor && !decl.isAbstract) {
599 result[decl.simpleName] = decl; 601 result[decl.simpleName] = decl;
600 } 602 }
601 if (decl is VariableMirror && !decl.isStatic) { 603 if (decl is VariableMirror && !decl.isStatic) {
602 var getterName = decl.simpleName; 604 var getterName = decl.simpleName;
603 result[getterName] = 605 result[getterName] =
604 new _SyntheticAccessor(this, getterName, true, false, false, decl) ; 606 new _SyntheticAccessor(this, getterName, true, false, false, decl) ;
605 if (!decl.isFinal) { 607 if (!decl.isFinal) {
606 var setterName = _asSetter(decl.simpleName, this.owner); 608 var setterName = _asSetter(decl.simpleName, this.owner);
607 result[setterName] = new _SyntheticAccessor( 609 result[setterName] = new _SyntheticAccessor(
608 this, setterName, false, false, false, decl); 610 this, setterName, false, false, false, decl);
609 } 611 }
610 } 612 }
611 }); 613 });
612 _cachedInstanceMembers = result; 614 _cachedInstanceMembers =
615 new _UnmodifiableMapView<Symbol, MethodMirror>(result);
613 } 616 }
614 return _cachedInstanceMembers; 617 return _cachedInstanceMembers;
615 } 618 }
616 619
617 Map<Symbol, DeclarationMirror> _declarations; 620 Map<Symbol, DeclarationMirror> _declarations;
618 Map<Symbol, DeclarationMirror> get declarations { 621 Map<Symbol, DeclarationMirror> get declarations {
619 if (_declarations != null) return _declarations; 622 if (_declarations != null) return _declarations;
620 var decls = new Map<Symbol, DeclarationMirror>(); 623 var decls = new Map<Symbol, DeclarationMirror>();
621 decls.addAll(_members); 624 decls.addAll(_members);
622 decls.addAll(_constructors); 625 decls.addAll(_constructors);
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 Map<Symbol, DeclarationMirror> _declarations; 1076 Map<Symbol, DeclarationMirror> _declarations;
1074 Map<Symbol, DeclarationMirror> get declarations { 1077 Map<Symbol, DeclarationMirror> get declarations {
1075 if (_declarations != null) return _declarations; 1078 if (_declarations != null) return _declarations;
1076 return _declarations = 1079 return _declarations =
1077 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); 1080 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members);
1078 } 1081 }
1079 1082
1080 1083
1081 var _cachedTopLevelMembers; 1084 var _cachedTopLevelMembers;
1082 Map<Symbol, MethodMirror> get topLevelMembers { 1085 Map<Symbol, MethodMirror> get topLevelMembers {
1083 if (_cachedTopLevelMembers != null) return _cachedTopLevelMembers; 1086 if (_cachedTopLevelMembers == null) {
1084 var result = new Map<Symbol, MethodMirror>(); 1087 var result = new Map<Symbol, MethodMirror>();
1085 declarations.values.forEach((decl) { 1088 declarations.values.forEach((decl) {
1086 if (decl is MethodMirror && !decl.isAbstract) { 1089 if (decl is MethodMirror && !decl.isAbstract) {
1087 result[decl.simpleName] = decl; 1090 result[decl.simpleName] = decl;
1088 }
1089 if (decl is VariableMirror) {
1090 var getterName = decl.simpleName;
1091 result[getterName] =
1092 new _SyntheticAccessor(this, getterName, true, true, true, decl);
1093 if (!decl.isFinal) {
1094 var setterName = _asSetter(decl.simpleName, this);
1095 result[setterName] = new _SyntheticAccessor(
1096 this, setterName, false, true, true, decl);
1097 } 1091 }
1098 } 1092 if (decl is VariableMirror) {
1099 // if (decl is TypeMirror) { 1093 var getterName = decl.simpleName;
1100 // var getterName = decl.simpleName; 1094 result[getterName] =
1101 // result[getterName] = new _SyntheticTypeGetter(this, getterName, decl); 1095 new _SyntheticAccessor(this, getterName, true, true, true, decl);
1102 // } 1096 if (!decl.isFinal) {
1103 }); 1097 var setterName = _asSetter(decl.simpleName, this);
1104 return _cachedTopLevelMembers = result; 1098 result[setterName] = new _SyntheticAccessor(
1099 this, setterName, false, true, true, decl);
1100 }
1101 }
1102 // if (decl is TypeMirror) {
1103 // var getterName = decl.simpleName;
1104 // result[getterName] =
1105 // new _SyntheticTypeGetter(this, getterName, decl);
1106 // }
siva 2014/01/09 19:29:49 Why are we carrying this commented out code? Mayb
rmacnak 2014/01/09 20:38:07 This was for behavior that wasn't agreed to. I'll
1107 });
1108 _cachedTopLevelMembers =
1109 new _UnmodifiableMapView<Symbol, MethodMirror>(result);
1110 }
1111 return _cachedTopLevelMembers;
1105 } 1112 }
1106 1113
1107 1114
1108 Map<Symbol, Mirror> _cachedMembers; 1115 Map<Symbol, Mirror> _cachedMembers;
1109 Map<Symbol, Mirror> get _members { 1116 Map<Symbol, Mirror> get _members {
1110 if (_cachedMembers == null) { 1117 if (_cachedMembers == null) {
1111 _cachedMembers = _makeMemberMap(_computeMembers(_reflectee)); 1118 _cachedMembers = _makeMemberMap(_computeMembers(_reflectee));
1112 } 1119 }
1113 return _cachedMembers; 1120 return _cachedMembers;
1114 } 1121 }
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 if (typeMirror == null) { 1495 if (typeMirror == null) {
1489 typeMirror = makeLocalTypeMirror(key); 1496 typeMirror = makeLocalTypeMirror(key);
1490 _instanitationCache[key] = typeMirror; 1497 _instanitationCache[key] = typeMirror;
1491 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1498 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1492 _declarationCache[key] = typeMirror; 1499 _declarationCache[key] = typeMirror;
1493 } 1500 }
1494 } 1501 }
1495 return typeMirror; 1502 return typeMirror;
1496 } 1503 }
1497 } 1504 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/mirrors/immutable_collections_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698