| 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 // 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 buf.add(output); | 177 buf.add(output); |
| 178 } | 178 } |
| 179 return buf.toString(); | 179 return buf.toString(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl | 182 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl |
| 183 implements InstanceMirror { | 183 implements InstanceMirror { |
| 184 _LocalInstanceMirrorImpl(ref, | 184 _LocalInstanceMirrorImpl(ref, |
| 185 this._class, | 185 this._class, |
| 186 this._hasSimpleValue, | |
| 187 this._reflectee) : super(ref) {} | 186 this._reflectee) : super(ref) {} |
| 188 | 187 |
| 189 var _class; | 188 var _class; |
| 190 InterfaceMirror getClass() { | 189 InterfaceMirror getClass() { |
| 191 if (_class is _LazyInterfaceMirror) { | 190 if (_class is _LazyInterfaceMirror) { |
| 192 _class = _class.resolve(mirrors); | 191 _class = _class.resolve(mirrors); |
| 193 } | 192 } |
| 194 return _class; | 193 return _class; |
| 195 } | 194 } |
| 196 | 195 |
| 197 // LocalInstanceMirrors always reflect local instances | 196 // LocalInstanceMirrors always reflect local instances |
| 198 bool hasReflectee = true; | 197 bool hasReflectee = true; |
| 199 | 198 |
| 200 var _hasSimpleValue; | |
| 201 var _reflectee; | 199 var _reflectee; |
| 202 get reflectee() => _reflectee; | 200 get reflectee() => _reflectee; |
| 203 | 201 |
| 204 String toString() { | 202 String toString() { |
| 205 if (_hasSimpleValue) { | 203 if (isSimpleValue(_reflectee)) { |
| 206 if (_reflectee is String) { | 204 if (_reflectee is String) { |
| 207 return "InstanceMirror on <'${_dartEscape(_reflectee)}'>"; | 205 return "InstanceMirror on <'${_dartEscape(_reflectee)}'>"; |
| 208 } else { | 206 } else { |
| 209 return "InstanceMirror on <$_reflectee>"; | 207 return "InstanceMirror on <$_reflectee>"; |
| 210 } | 208 } |
| 211 } else { | 209 } else { |
| 212 return "InstanceMirror on instance of '${getClass().simpleName}'"; | 210 return "InstanceMirror on instance of '${getClass().simpleName}'"; |
| 213 } | 211 } |
| 214 } | 212 } |
| 215 } | 213 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 363 |
| 366 String toString() { | 364 String toString() { |
| 367 return "LibraryMirror on '$simpleName'"; | 365 return "LibraryMirror on '$simpleName'"; |
| 368 } | 366 } |
| 369 } | 367 } |
| 370 | 368 |
| 371 class _LocalMethodMirrorImpl extends _LocalMirrorImpl | 369 class _LocalMethodMirrorImpl extends _LocalMirrorImpl |
| 372 implements MethodMirror { | 370 implements MethodMirror { |
| 373 _LocalMethodMirrorImpl(this.simpleName, | 371 _LocalMethodMirrorImpl(this.simpleName, |
| 374 this._owner, | 372 this._owner, |
| 373 this._parameters, |
| 375 this.isStatic, | 374 this.isStatic, |
| 376 this.isAbstract, | 375 this.isAbstract, |
| 377 this.isGetter, | 376 this.isGetter, |
| 378 this.isSetter, | 377 this.isSetter, |
| 379 this.isConstructor, | 378 this.isConstructor, |
| 380 this.isConstConstructor, | 379 this.isConstConstructor, |
| 381 this.isGenerativeConstructor, | 380 this.isGenerativeConstructor, |
| 382 this.isRedirectingConstructor, | 381 this.isRedirectingConstructor, |
| 383 this.isFactoryConstructor) {} | 382 this.isFactoryConstructor) {} |
| 384 | 383 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 405 final bool isAbstract; | 404 final bool isAbstract; |
| 406 final bool isGetter; | 405 final bool isGetter; |
| 407 final bool isSetter; | 406 final bool isSetter; |
| 408 final bool isConstructor; | 407 final bool isConstructor; |
| 409 | 408 |
| 410 final bool isConstConstructor; | 409 final bool isConstConstructor; |
| 411 final bool isGenerativeConstructor; | 410 final bool isGenerativeConstructor; |
| 412 final bool isRedirectingConstructor; | 411 final bool isRedirectingConstructor; |
| 413 final bool isFactoryConstructor; | 412 final bool isFactoryConstructor; |
| 414 | 413 |
| 414 List<ParameterMirror> _parameters; |
| 415 List<ParameterMirror> parameters() => _parameters; |
| 416 |
| 415 String toString() { | 417 String toString() { |
| 416 return "MethodMirror on '$simpleName'"; | 418 return "MethodMirror on '$simpleName'"; |
| 417 } | 419 } |
| 418 } | 420 } |
| 419 | 421 |
| 422 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |
| 423 implements ParameterMirror { |
| 424 // TODO(rmacnak): Fill these mirrors will real information |
| 425 _LocalParameterMirrorImpl(this._isOptional) |
| 426 : super(null, null, false, false) {} |
| 427 |
| 428 |
| 429 bool _isOptional; |
| 430 |
| 431 TypeMirror type() => null; |
| 432 String defaultValue() => null; |
| 433 bool hasDefaultValue() => null; |
| 434 bool isOptional() => _isOptional; |
| 435 } |
| 436 |
| 420 class _LocalVariableMirrorImpl extends _LocalMirrorImpl | 437 class _LocalVariableMirrorImpl extends _LocalMirrorImpl |
| 421 implements VariableMirror { | 438 implements VariableMirror { |
| 422 _LocalVariableMirrorImpl(this.simpleName, | 439 _LocalVariableMirrorImpl(this.simpleName, |
| 423 this._owner, | 440 this._owner, |
| 424 this.isStatic, | 441 this.isStatic, |
| 425 this.isFinal) {} | 442 this.isFinal) {} |
| 426 | 443 |
| 427 final String simpleName; | 444 final String simpleName; |
| 428 | 445 |
| 429 var _owner; | 446 var _owner; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 499 |
| 483 // Creates a new local InstanceMirror | 500 // Creates a new local InstanceMirror |
| 484 static InstanceMirror makeLocalInstanceMirror(Object reflectee) | 501 static InstanceMirror makeLocalInstanceMirror(Object reflectee) |
| 485 native 'Mirrors_makeLocalInstanceMirror'; | 502 native 'Mirrors_makeLocalInstanceMirror'; |
| 486 | 503 |
| 487 // Creates a new local mirror for some Object. | 504 // Creates a new local mirror for some Object. |
| 488 static InstanceMirror mirrorOf(Object reflectee) { | 505 static InstanceMirror mirrorOf(Object reflectee) { |
| 489 return makeLocalInstanceMirror(reflectee); | 506 return makeLocalInstanceMirror(reflectee); |
| 490 } | 507 } |
| 491 } | 508 } |
| OLD | NEW |