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

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

Issue 24631003: Add proper API for creating private symbols wrt a library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: amend tests Created 7 years, 2 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 delegate(Invocation invocation) { 282 delegate(Invocation invocation) {
283 if (_invokeOnClosure == null) { 283 if (_invokeOnClosure == null) {
284 // TODO(ahe): This is a total hack. We're using the mirror 284 // TODO(ahe): This is a total hack. We're using the mirror
285 // system to access a private field in a different library. For 285 // system to access a private field in a different library. For
286 // some reason, that works. On the other hand, calling a 286 // some reason, that works. On the other hand, calling a
287 // private method does not work. 287 // private method does not work.
288 288
289 _LocalInstanceMirrorImpl mirror = 289 _LocalInstanceMirrorImpl mirror =
290 reflect(invocation); 290 reflect(invocation);
291 _invokeOnClosure = reflectClass(invocation.runtimeType) 291 _invokeOnClosure = reflectClass(invocation.runtimeType)
292 .getField(const Symbol('_invokeOnClosure')).reflectee; 292 .getField(MirrorSystem.getSymbol('_invokeOnClosure', mirror.type.owner )).reflectee;
293 } 293 }
294 return _invokeOnClosure(reflectee, invocation); 294 return _invokeOnClosure(reflectee, invocation);
295 } 295 }
296 296
297 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}'; 297 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}';
298 298
299 bool operator ==(other) { 299 bool operator ==(other) {
300 return other is _LocalInstanceMirrorImpl && 300 return other is _LocalInstanceMirrorImpl &&
301 identical(_reflectee, other._reflectee); 301 identical(_reflectee, other._reflectee);
302 } 302 }
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; 627 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration;
628 628
629 ClassMirror get originalDeclaration { 629 ClassMirror get originalDeclaration {
630 if (isOriginalDeclaration) { 630 if (isOriginalDeclaration) {
631 return this; 631 return this;
632 } else { 632 } else {
633 return reflectClass(_reflectedType); 633 return reflectClass(_reflectedType);
634 } 634 }
635 } 635 }
636 636
637 String toString() => "ClassMirror on '${_n(simpleName)}'"; 637 String toString() => "ClassMirror on '${MirrorSystem.getName(simpleName)}'";
638 638
639 InstanceMirror newInstance(Symbol constructorName, 639 InstanceMirror newInstance(Symbol constructorName,
640 List positionalArguments, 640 List positionalArguments,
641 [Map<Symbol, dynamic> namedArguments]) { 641 [Map<Symbol, dynamic> namedArguments]) {
642 // Native code will add the 1 or 2 implicit arguments depending on whether 642 // Native code will add the 1 or 2 implicit arguments depending on whether
643 // we end up invoking a factory or constructor respectively. 643 // we end up invoking a factory or constructor respectively.
644 int numPositionalArguments = positionalArguments.length; 644 int numPositionalArguments = positionalArguments.length;
645 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; 645 int numNamedArguments = namedArguments != null ? namedArguments.length : 0;
646 int numArguments = numPositionalArguments + numNamedArguments; 646 int numArguments = numPositionalArguments + numNamedArguments;
647 List arguments = new List(numArguments); 647 List arguments = new List(numArguments);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1110
1111 void _patchConstructorName(ownerName) { 1111 void _patchConstructorName(ownerName) {
1112 var cn = _n(constructorName); 1112 var cn = _n(constructorName);
1113 if(cn == ''){ 1113 if(cn == ''){
1114 _simpleName = _s(ownerName); 1114 _simpleName = _s(ownerName);
1115 } else { 1115 } else {
1116 _simpleName = _s(ownerName + "." + cn); 1116 _simpleName = _s(ownerName + "." + cn);
1117 } 1117 }
1118 } 1118 }
1119 1119
1120 String toString() => "MethodMirror on '${_n(simpleName)}'"; 1120 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'";
1121 1121
1122 static dynamic _MethodMirror_owner(reflectee) 1122 static dynamic _MethodMirror_owner(reflectee)
1123 native "MethodMirror_owner"; 1123 native "MethodMirror_owner";
1124 1124
1125 static dynamic _MethodMirror_return_type(reflectee) 1125 static dynamic _MethodMirror_return_type(reflectee)
1126 native "MethodMirror_return_type"; 1126 native "MethodMirror_return_type";
1127 1127
1128 List<ParameterMirror> _MethodMirror_parameters(reflectee) 1128 List<ParameterMirror> _MethodMirror_parameters(reflectee)
1129 native "MethodMirror_parameters"; 1129 native "MethodMirror_parameters";
1130 1130
(...skipping 24 matching lines...) Expand all
1155 } 1155 }
1156 1156
1157 TypeMirror _type; 1157 TypeMirror _type;
1158 TypeMirror get type { 1158 TypeMirror get type {
1159 if (_type == null) { 1159 if (_type == null) {
1160 _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee)); 1160 _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee));
1161 } 1161 }
1162 return _type; 1162 return _type;
1163 } 1163 }
1164 1164
1165 String toString() => "VariableMirror on '${_n(simpleName)}'"; 1165 String toString() => "VariableMirror on '${MirrorSystem.getName(simpleName)}'" ;
1166 1166
1167 static _VariableMirror_type(reflectee) 1167 static _VariableMirror_type(reflectee)
1168 native "VariableMirror_type"; 1168 native "VariableMirror_type";
1169 } 1169 }
1170 1170
1171 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl 1171 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
1172 implements ParameterMirror { 1172 implements ParameterMirror {
1173 _LocalParameterMirrorImpl(reflectee, 1173 _LocalParameterMirrorImpl(reflectee,
1174 String simpleName, 1174 String simpleName,
1175 DeclarationMirror owner, 1175 DeclarationMirror owner,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 if (typeMirror == null) { 1321 if (typeMirror == null) {
1322 typeMirror = makeLocalTypeMirror(key); 1322 typeMirror = makeLocalTypeMirror(key);
1323 _instanitationCache[key] = typeMirror; 1323 _instanitationCache[key] = typeMirror;
1324 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1324 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1325 _declarationCache[key] = typeMirror; 1325 _declarationCache[key] = typeMirror;
1326 } 1326 }
1327 } 1327 }
1328 return typeMirror; 1328 return typeMirror;
1329 } 1329 }
1330 } 1330 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/lib/mirrors_patch.dart » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698