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

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

Issue 22849015: Provide a way to get a Type back from a ClassMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments Created 7 years, 4 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
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 // These values are allowed to be passed directly over the wire. 9 // These values are allowed to be passed directly over the wire.
10 bool _isSimpleValue(var value) { 10 bool _isSimpleValue(var value) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 _LocalClassMirrorImpl(reflectee, 362 _LocalClassMirrorImpl(reflectee,
363 this._reflectedType, 363 this._reflectedType,
364 String simpleName, 364 String simpleName,
365 this._isGeneric) 365 this._isGeneric)
366 : this._simpleName = _s(simpleName), 366 : this._simpleName = _s(simpleName),
367 super(reflectee); 367 super(reflectee);
368 368
369 final Type _reflectedType; 369 final Type _reflectedType;
370 final bool _isGeneric; 370 final bool _isGeneric;
371 371
372 bool get hasReflectedType => _reflectedType != null;
373 Type get reflectedType {
374 if (!hasReflectedType) {
375 throw new UnsupportedError(
376 "Declarations of generics have no reflected type");
377 }
378 return _reflectedType;
379 }
380
372 Symbol _simpleName; 381 Symbol _simpleName;
373 Symbol get simpleName { 382 Symbol get simpleName {
374 // dynamic, void and the function types have their names set eagerly in the 383 // dynamic, void and the function types have their names set eagerly in the
375 // constructor. 384 // constructor.
376 if(_simpleName == null) { 385 if(_simpleName == null) {
377 _simpleName = _s(_name(_reflectee)); 386 _simpleName = _s(_name(_reflectee));
378 } 387 }
379 return _simpleName; 388 return _simpleName;
380 } 389 }
381 390
(...skipping 28 matching lines...) Expand all
410 ClassMirror get defaultFactory => null; 419 ClassMirror get defaultFactory => null;
411 420
412 ClassMirror _superclass; 421 ClassMirror _superclass;
413 ClassMirror get superclass { 422 ClassMirror get superclass {
414 if (_superclass == null) { 423 if (_superclass == null) {
415 Type supertype = _supertype(_reflectee); 424 Type supertype = _supertype(_reflectee);
416 if (supertype == null) { 425 if (supertype == null) {
417 // Object has no superclass. 426 // Object has no superclass.
418 return null; 427 return null;
419 } 428 }
420 _superclass = reflectClass(supertype); 429 _superclass = _Mirrors._reflectType(supertype);
421 } 430 }
422 return _superclass; 431 return _superclass;
423 } 432 }
424 433
425 var _superinterfaces; 434 var _superinterfaces;
426 List<ClassMirror> get superinterfaces { 435 List<ClassMirror> get superinterfaces {
427 if (_superinterfaces == null) { 436 if (_superinterfaces == null) {
428 _superinterfaces = _interfaces(_reflectee) 437 _superinterfaces = _interfaces(_reflectee)
429 .map((i) => reflectClass(i)).toList(growable:false); 438 .map((i) => reflectClass(i)).toList(growable:false);
430 } 439 }
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 if (typeMirror == null) { 1219 if (typeMirror == null) {
1211 typeMirror = makeLocalTypeMirror(key); 1220 typeMirror = makeLocalTypeMirror(key);
1212 _instanitationCache[key] = typeMirror; 1221 _instanitationCache[key] = typeMirror;
1213 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1222 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1214 _declarationCache[key] = typeMirror; 1223 _declarationCache[key] = typeMirror;
1215 } 1224 }
1216 } 1225 }
1217 return typeMirror; 1226 return typeMirror;
1218 } 1227 }
1219 } 1228 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | sdk/lib/mirrors/mirrors.dart » ('j') | tests/lib/lib.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698