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

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

Issue 137123005: dart2js: Implement instanceMembers and staticMembers. (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 | sdk/lib/_internal/lib/js_mirrors.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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 Symbol get constructorName => const Symbol(''); 192 Symbol get constructorName => const Symbol('');
193 193
194 TypeMirror get returnType => _target.type; 194 TypeMirror get returnType => _target.type;
195 List<ParameterMirror> get parameters { 195 List<ParameterMirror> get parameters {
196 if (isGetter) return emptyList; 196 if (isGetter) return emptyList;
197 return new UnmodifiableListView( 197 return new UnmodifiableListView(
198 [new _SyntheticSetterParameter(this, this._target)]); 198 [new _SyntheticSetterParameter(this, this._target)]);
199 } 199 }
200 200
201 List<InstanceMirror> get metadata => emptyList; 201 List<InstanceMirror> get metadata => emptyList;
202
203 String get source => null; 202 String get source => null;
203 SourceLocation get location => throw new UnimplementedError();
204 } 204 }
205 205
206 class _SyntheticSetterParameter implements ParameterMirror { 206 class _SyntheticSetterParameter implements ParameterMirror {
207 final DeclarationMirror owner; 207 final DeclarationMirror owner;
208 final VariableMirror _target; 208 final VariableMirror _target;
209 209
210 _SyntheticSetterParameter(this.owner, this._target); 210 _SyntheticSetterParameter(this.owner, this._target);
211 211
212 Symbol get simpleName => _target.simpleName; 212 Symbol get simpleName => _target.simpleName;
213 Symbol get qualifiedName => _computeQualifiedName(owner, simpleName); 213 Symbol get qualifiedName => _computeQualifiedName(owner, simpleName);
214 TypeMirror get type => _target.type; 214 TypeMirror get type => _target.type;
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 List<InstanceMirror> get metadata => emptyList;
226 SourceLocation get location => throw new UnimplementedError();
226 } 227 }
227 228
228 abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror { 229 abstract class _LocalObjectMirror extends _LocalMirror implements ObjectMirror {
229 final _reflectee; // May be a MirrorReference or an ordinary object. 230 final _reflectee; // May be a MirrorReference or an ordinary object.
230 231
231 _LocalObjectMirror(this._reflectee); 232 _LocalObjectMirror(this._reflectee);
232 233
233 InstanceMirror invoke(Symbol memberName, 234 InstanceMirror invoke(Symbol memberName,
234 List positionalArguments, 235 List positionalArguments,
235 [Map<Symbol, dynamic> namedArguments]) { 236 [Map<Symbol, dynamic> namedArguments]) {
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 561 }
561 } 562 }
562 return _mixin; 563 return _mixin;
563 } 564 }
564 565
565 var _cachedStaticMembers; 566 var _cachedStaticMembers;
566 Map<Symbol, MethodMirror> get staticMembers { 567 Map<Symbol, MethodMirror> get staticMembers {
567 if (_cachedStaticMembers == null) { 568 if (_cachedStaticMembers == null) {
568 var result = new Map<Symbol, MethodMirror>(); 569 var result = new Map<Symbol, MethodMirror>();
569 declarations.values.forEach((decl) { 570 declarations.values.forEach((decl) {
570 if (decl is MethodMirror && decl.isStatic && 571 if (decl is MethodMirror && decl.isStatic && !decl.isConstructor) {
571 !decl.isConstructor && !decl.isAbstract) {
572 result[decl.simpleName] = decl; 572 result[decl.simpleName] = decl;
573 } 573 }
574 if (decl is VariableMirror && decl.isStatic) { 574 if (decl is VariableMirror && decl.isStatic) {
575 var getterName = decl.simpleName; 575 var getterName = decl.simpleName;
576 result[getterName] = 576 result[getterName] =
577 new _SyntheticAccessor(this, getterName, true, true, false, decl); 577 new _SyntheticAccessor(this, getterName, true, true, false, decl);
578 if (!decl.isFinal) { 578 if (!decl.isFinal) {
579 var setterName = _asSetter(decl.simpleName, this.owner); 579 var setterName = _asSetter(decl.simpleName, this.owner);
580 result[setterName] = new _SyntheticAccessor( 580 result[setterName] = new _SyntheticAccessor(
581 this, setterName, false, true, false, decl); 581 this, setterName, false, true, false, decl);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 return _declarations = 1079 return _declarations =
1080 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); 1080 new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members);
1081 } 1081 }
1082 1082
1083 1083
1084 var _cachedTopLevelMembers; 1084 var _cachedTopLevelMembers;
1085 Map<Symbol, MethodMirror> get topLevelMembers { 1085 Map<Symbol, MethodMirror> get topLevelMembers {
1086 if (_cachedTopLevelMembers == null) { 1086 if (_cachedTopLevelMembers == null) {
1087 var result = new Map<Symbol, MethodMirror>(); 1087 var result = new Map<Symbol, MethodMirror>();
1088 declarations.values.forEach((decl) { 1088 declarations.values.forEach((decl) {
1089 if (decl is MethodMirror && !decl.isAbstract) { 1089 if (decl is MethodMirror) {
1090 result[decl.simpleName] = decl; 1090 result[decl.simpleName] = decl;
1091 } 1091 }
1092 if (decl is VariableMirror) { 1092 if (decl is VariableMirror) {
1093 var getterName = decl.simpleName; 1093 var getterName = decl.simpleName;
1094 result[getterName] = 1094 result[getterName] =
1095 new _SyntheticAccessor(this, getterName, true, true, true, decl); 1095 new _SyntheticAccessor(this, getterName, true, true, true, decl);
1096 if (!decl.isFinal) { 1096 if (!decl.isFinal) {
1097 var setterName = _asSetter(decl.simpleName, this); 1097 var setterName = _asSetter(decl.simpleName, this);
1098 result[setterName] = new _SyntheticAccessor( 1098 result[setterName] = new _SyntheticAccessor(
1099 this, setterName, false, true, true, decl); 1099 this, setterName, false, true, true, decl);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 if (typeMirror == null) { 1490 if (typeMirror == null) {
1491 typeMirror = makeLocalTypeMirror(key); 1491 typeMirror = makeLocalTypeMirror(key);
1492 _instanitationCache[key] = typeMirror; 1492 _instanitationCache[key] = typeMirror;
1493 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1493 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1494 _declarationCache[key] = typeMirror; 1494 _declarationCache[key] = typeMirror;
1495 } 1495 }
1496 } 1496 }
1497 return typeMirror; 1497 return typeMirror;
1498 } 1498 }
1499 } 1499 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698