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

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

Issue 19188004: Make the ClassMirrors created through reflectClass() find their owners (libraries) lazily. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 Symbol _qualifiedName = null; 415 Symbol _qualifiedName = null;
416 Symbol get qualifiedName { 416 Symbol get qualifiedName {
417 if (_qualifiedName == null) { 417 if (_qualifiedName == null) {
418 _qualifiedName = _computeQualifiedName(owner, simpleName); 418 _qualifiedName = _computeQualifiedName(owner, simpleName);
419 } 419 }
420 return _qualifiedName; 420 return _qualifiedName;
421 } 421 }
422 422
423 var _owner; 423 var _owner;
424 DeclarationMirror get owner { 424 DeclarationMirror get owner {
425 if (_owner != null && _owner is! Mirror) { 425 if (_owner == null) {
426 _owner = _library(_reflectee);
427 }
428 if (_owner is! Mirror) {
426 _owner = _owner.resolve(mirrors); 429 _owner = _owner.resolve(mirrors);
427 } 430 }
428 return _owner; 431 return _owner;
429 } 432 }
430 433
431 bool get isPrivate => _n(simpleName).startsWith('_'); 434 bool get isPrivate => _n(simpleName).startsWith('_');
432 435
433 final bool isTopLevel = true; 436 final bool isTopLevel = true;
434 437
435 SourceLocation get location { 438 SourceLocation get location {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 569
567 List<InstanceMirror> get metadata { 570 List<InstanceMirror> get metadata {
568 // Get the metadata objects, convert them into InstanceMirrors using 571 // Get the metadata objects, convert them into InstanceMirrors using
569 // reflect() and then make them into a Dart list. 572 // reflect() and then make them into a Dart list.
570 return _metadata(_reflectee).map(reflect).toList(growable:false); 573 return _metadata(_reflectee).map(reflect).toList(growable:false);
571 } 574 }
572 575
573 static _name(reflectee) 576 static _name(reflectee)
574 native "ClassMirror_name"; 577 native "ClassMirror_name";
575 578
579 static _library(reflectee)
580 native "ClassMirror_library";
581
576 _invoke(reflectee, memberName, positionalArguments) 582 _invoke(reflectee, memberName, positionalArguments)
577 native 'ClassMirror_invoke'; 583 native 'ClassMirror_invoke';
578 584
579 _invokeGetter(reflectee, getterName) 585 _invokeGetter(reflectee, getterName)
580 native 'ClassMirror_invokeGetter'; 586 native 'ClassMirror_invokeGetter';
581 587
582 _invokeSetter(reflectee, setterName, value) 588 _invokeSetter(reflectee, setterName, value)
583 native 'ClassMirror_invokeSetter'; 589 native 'ClassMirror_invokeSetter';
584 590
585 static _invokeConstructor(reflectee, constructorName, positionalArguments) 591 static _invokeConstructor(reflectee, constructorName, positionalArguments)
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); 1138 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror");
1133 static ClassMirror reflectClass(Type key) { 1139 static ClassMirror reflectClass(Type key) {
1134 var classMirror = _classMirrorCache[key]; 1140 var classMirror = _classMirrorCache[key];
1135 if (classMirror == null) { 1141 if (classMirror == null) {
1136 classMirror = makeLocalClassMirror(key); 1142 classMirror = makeLocalClassMirror(key);
1137 _classMirrorCache[key] = classMirror; 1143 _classMirrorCache[key] = classMirror;
1138 } 1144 }
1139 return classMirror; 1145 return classMirror;
1140 } 1146 }
1141 } 1147 }
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