| OLD | NEW |
| 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 Loading... |
| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; | 639 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; |
| 640 | 640 |
| 641 ClassMirror get originalDeclaration { | 641 ClassMirror get originalDeclaration { |
| 642 if (isOriginalDeclaration) { | 642 if (isOriginalDeclaration) { |
| 643 return this; | 643 return this; |
| 644 } else { | 644 } else { |
| 645 return reflectClass(_reflectedType); | 645 return reflectClass(_reflectedType); |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 | 648 |
| 649 String toString() => "ClassMirror on '${_n(simpleName)}'"; | 649 String toString() => "ClassMirror on '${MirrorSystem.getName(simpleName)}'"; |
| 650 | 650 |
| 651 InstanceMirror newInstance(Symbol constructorName, | 651 InstanceMirror newInstance(Symbol constructorName, |
| 652 List positionalArguments, | 652 List positionalArguments, |
| 653 [Map<Symbol, dynamic> namedArguments]) { | 653 [Map<Symbol, dynamic> namedArguments]) { |
| 654 // Native code will add the 1 or 2 implicit arguments depending on whether | 654 // Native code will add the 1 or 2 implicit arguments depending on whether |
| 655 // we end up invoking a factory or constructor respectively. | 655 // we end up invoking a factory or constructor respectively. |
| 656 int numPositionalArguments = positionalArguments.length; | 656 int numPositionalArguments = positionalArguments.length; |
| 657 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; | 657 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; |
| 658 int numArguments = numPositionalArguments + numNamedArguments; | 658 int numArguments = numPositionalArguments + numNamedArguments; |
| 659 List arguments = new List(numArguments); | 659 List arguments = new List(numArguments); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 | 1151 |
| 1152 void _patchConstructorName(ownerName) { | 1152 void _patchConstructorName(ownerName) { |
| 1153 var cn = _n(constructorName); | 1153 var cn = _n(constructorName); |
| 1154 if(cn == ''){ | 1154 if(cn == ''){ |
| 1155 _simpleName = _s(ownerName); | 1155 _simpleName = _s(ownerName); |
| 1156 } else { | 1156 } else { |
| 1157 _simpleName = _s(ownerName + "." + cn); | 1157 _simpleName = _s(ownerName + "." + cn); |
| 1158 } | 1158 } |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 String toString() => "MethodMirror on '${_n(simpleName)}'"; | 1161 String toString() => "MethodMirror on '${MirrorSystem.getName(simpleName)}'"; |
| 1162 | 1162 |
| 1163 static dynamic _MethodMirror_owner(reflectee) | 1163 static dynamic _MethodMirror_owner(reflectee) |
| 1164 native "MethodMirror_owner"; | 1164 native "MethodMirror_owner"; |
| 1165 | 1165 |
| 1166 static dynamic _MethodMirror_return_type(reflectee) | 1166 static dynamic _MethodMirror_return_type(reflectee) |
| 1167 native "MethodMirror_return_type"; | 1167 native "MethodMirror_return_type"; |
| 1168 | 1168 |
| 1169 List<ParameterMirror> _MethodMirror_parameters(reflectee) | 1169 List<ParameterMirror> _MethodMirror_parameters(reflectee) |
| 1170 native "MethodMirror_parameters"; | 1170 native "MethodMirror_parameters"; |
| 1171 | 1171 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1197 | 1197 |
| 1198 TypeMirror _type; | 1198 TypeMirror _type; |
| 1199 TypeMirror get type { | 1199 TypeMirror get type { |
| 1200 if (_type == null) { | 1200 if (_type == null) { |
| 1201 _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee)); | 1201 _type = _Mirrors._reflectType(_VariableMirror_type(_reflectee)); |
| 1202 _type = _type._instantiateInContextOf(owner); | 1202 _type = _type._instantiateInContextOf(owner); |
| 1203 } | 1203 } |
| 1204 return _type; | 1204 return _type; |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 String toString() => "VariableMirror on '${_n(simpleName)}'"; | 1207 String toString() => "VariableMirror on '${MirrorSystem.getName(simpleName)}'"
; |
| 1208 | 1208 |
| 1209 static _VariableMirror_type(reflectee) | 1209 static _VariableMirror_type(reflectee) |
| 1210 native "VariableMirror_type"; | 1210 native "VariableMirror_type"; |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl | 1213 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |
| 1214 implements ParameterMirror { | 1214 implements ParameterMirror { |
| 1215 _LocalParameterMirrorImpl(reflectee, | 1215 _LocalParameterMirrorImpl(reflectee, |
| 1216 String simpleName, | 1216 String simpleName, |
| 1217 DeclarationMirror owner, | 1217 DeclarationMirror owner, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 if (typeMirror == null) { | 1366 if (typeMirror == null) { |
| 1367 typeMirror = makeLocalTypeMirror(key); | 1367 typeMirror = makeLocalTypeMirror(key); |
| 1368 _instanitationCache[key] = typeMirror; | 1368 _instanitationCache[key] = typeMirror; |
| 1369 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1369 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1370 _declarationCache[key] = typeMirror; | 1370 _declarationCache[key] = typeMirror; |
| 1371 } | 1371 } |
| 1372 } | 1372 } |
| 1373 return typeMirror; | 1373 return typeMirror; |
| 1374 } | 1374 } |
| 1375 } | 1375 } |
| OLD | NEW |