| 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" show UnmodifiableListView, UnmodifiableMapView; | 7 import "dart:collection" show UnmodifiableListView, UnmodifiableMapView; |
| 8 import "dart:async" show Future; | 8 import "dart:async" show Future; |
| 9 | 9 |
| 10 var dirty = false; | 10 var dirty = false; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 return _eval('(x) => x.$withoutKey', privateKey); | 440 return _eval('(x) => x.$withoutKey', privateKey); |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 | 443 |
| 444 _getFieldSlow(unwrapped) { | 444 _getFieldSlow(unwrapped) { |
| 445 // Slow path factored out to give the fast path a better chance at being | 445 // Slow path factored out to give the fast path a better chance at being |
| 446 // inlined. | 446 // inlined. |
| 447 var result = reflect(_invokeGetter(_reflectee, unwrapped)); | 447 var result = reflect(_invokeGetter(_reflectee, unwrapped)); |
| 448 // Wait until success to avoid creating closures for non-existent getters, | 448 // Wait until success to avoid creating closures for non-existent getters, |
| 449 // and defer the creation until the next getField invocation. | 449 // and defer the creation until the next getField invocation. |
| 450 _getFieldClosures[unwrapped] = (receiver) { | 450 // o.<operator> is not valid Dart and will cause a compilation error, so |
| 451 var getterClosure = _createGetterClosure(unwrapped); | 451 // don't attempt to generate such a closure. |
| 452 _getFieldClosures[unwrapped] = getterClosure; | 452 bool isOperator = _LocalMethodMirror._operators.contains(unwrapped); |
| 453 return getterClosure(receiver); | 453 if (!isOperator) { |
| 454 }; | 454 _getFieldClosures[unwrapped] = (receiver) { |
| 455 var getterClosure = _createGetterClosure(unwrapped); |
| 456 _getFieldClosures[unwrapped] = getterClosure; |
| 457 return getterClosure(receiver); |
| 458 }; |
| 459 } |
| 455 return result; | 460 return result; |
| 456 } | 461 } |
| 457 | 462 |
| 458 InstanceMirror getField(Symbol memberName) { | 463 InstanceMirror getField(Symbol memberName) { |
| 459 var unwrapped = _n(memberName); | 464 var unwrapped = _n(memberName); |
| 460 var f = _getFieldClosures[unwrapped]; | 465 var f = _getFieldClosures[unwrapped]; |
| 461 return (f == null) ? _getFieldSlow(unwrapped) : reflect(f(_reflectee)); | 466 return (f == null) ? _getFieldSlow(unwrapped) : reflect(f(_reflectee)); |
| 462 } | 467 } |
| 463 | 468 |
| 464 _createSetterClosure(unwrapped) { | 469 _createSetterClosure(unwrapped) { |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 if (typeMirror == null) { | 1664 if (typeMirror == null) { |
| 1660 typeMirror = makeLocalTypeMirror(key); | 1665 typeMirror = makeLocalTypeMirror(key); |
| 1661 _instanitationCache[key] = typeMirror; | 1666 _instanitationCache[key] = typeMirror; |
| 1662 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1667 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1663 _declarationCache[key] = typeMirror; | 1668 _declarationCache[key] = typeMirror; |
| 1664 } | 1669 } |
| 1665 } | 1670 } |
| 1666 return typeMirror; | 1671 return typeMirror; |
| 1667 } | 1672 } |
| 1668 } | 1673 } |
| OLD | NEW |