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

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: rename StripAccessorPrefix 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; 637 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration;
638 638
639 ClassMirror get originalDeclaration { 639 ClassMirror get originalDeclaration {
640 if (isOriginalDeclaration) { 640 if (isOriginalDeclaration) {
641 return this; 641 return this;
642 } else { 642 } else {
643 return reflectClass(_reflectedType); 643 return reflectClass(_reflectedType);
644 } 644 }
645 } 645 }
646 646
647 String toString() => "ClassMirror on '${_n(simpleName)}'"; 647 String toString() => "ClassMirror on '${MirrorSystem.getName(simpleName)}'";
648 648
649 InstanceMirror newInstance(Symbol constructorName, 649 InstanceMirror newInstance(Symbol constructorName,
650 List positionalArguments, 650 List positionalArguments,
651 [Map<Symbol, dynamic> namedArguments]) { 651 [Map<Symbol, dynamic> namedArguments]) {
652 // Native code will add the 1 or 2 implicit arguments depending on whether 652 // Native code will add the 1 or 2 implicit arguments depending on whether
653 // we end up invoking a factory or constructor respectively. 653 // we end up invoking a factory or constructor respectively.
654 int numPositionalArguments = positionalArguments.length; 654 int numPositionalArguments = positionalArguments.length;
655 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; 655 int numNamedArguments = namedArguments != null ? namedArguments.length : 0;
656 int numArguments = numPositionalArguments + numNamedArguments; 656 int numArguments = numPositionalArguments + numNamedArguments;
657 List arguments = new List(numArguments); 657 List arguments = new List(numArguments);
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1120
1121 void _patchConstructorName(ownerName) { 1121 void _patchConstructorName(ownerName) {
1122 var cn = _n(constructorName); 1122 var cn = _n(constructorName);
1123 if(cn == ''){ 1123 if(cn == ''){
1124 _simpleName = _s(ownerName); 1124 _simpleName = _s(ownerName);
1125 } else { 1125 } else {
1126 _simpleName = _s(ownerName + "." + cn); 1126 _simpleName = _s(ownerName + "." + cn);
1127 } 1127 }
1128 } 1128 }
1129 1129
1130 String toString() => "MethodMirror on '${_n(simpleName)}'"; 1130 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'";
1131 1131
1132 static dynamic _MethodMirror_owner(reflectee) 1132 static dynamic _MethodMirror_owner(reflectee)
1133 native "MethodMirror_owner"; 1133 native "MethodMirror_owner";
1134 1134
1135 static dynamic _MethodMirror_return_type(reflectee) 1135 static dynamic _MethodMirror_return_type(reflectee)
1136 native "MethodMirror_return_type"; 1136 native "MethodMirror_return_type";
1137 1137
1138 List<ParameterMirror> _MethodMirror_parameters(reflectee) 1138 List<ParameterMirror> _MethodMirror_parameters(reflectee)
1139 native "MethodMirror_parameters"; 1139 native "MethodMirror_parameters";
1140 1140
(...skipping 24 matching lines...) Expand all
1165 } 1165 }
1166 1166
1167 TypeMirror _type; 1167 TypeMirror _type;
1168 TypeMirror get type { 1168 TypeMirror get type {
1169 if (_type == null) { 1169 if (_type == null) {
1170 _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee)); 1170 _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee));
1171 } 1171 }
1172 return _type; 1172 return _type;
1173 } 1173 }
1174 1174
1175 String toString() => "VariableMirror on '${_n(simpleName)}'"; 1175 String toString() => "VariableMirror on '${MirrorSystem.getName(simpleName)}'" ;
1176 1176
1177 static _VariableMirror_type(reflectee) 1177 static _VariableMirror_type(reflectee)
1178 native "VariableMirror_type"; 1178 native "VariableMirror_type";
1179 } 1179 }
1180 1180
1181 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl 1181 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
1182 implements ParameterMirror { 1182 implements ParameterMirror {
1183 _LocalParameterMirrorImpl(reflectee, 1183 _LocalParameterMirrorImpl(reflectee,
1184 String simpleName, 1184 String simpleName,
1185 DeclarationMirror owner, 1185 DeclarationMirror owner,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 if (typeMirror == null) { 1331 if (typeMirror == null) {
1332 typeMirror = makeLocalTypeMirror(key); 1332 typeMirror = makeLocalTypeMirror(key);
1333 _instanitationCache[key] = typeMirror; 1333 _instanitationCache[key] = typeMirror;
1334 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1334 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1335 _declarationCache[key] = typeMirror; 1335 _declarationCache[key] = typeMirror;
1336 } 1336 }
1337 } 1337 }
1338 return typeMirror; 1338 return typeMirror;
1339 } 1339 }
1340 } 1340 }
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