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 final emptyList = new UnmodifiableListView([]); | 9 final emptyList = new UnmodifiableListView([]); |
10 final emptyMap = new _UnmodifiableMapView({}); | 10 final emptyMap = new _UnmodifiableMapView({}); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 _unwrapAsyncNamed(namedArguments)); | 462 _unwrapAsyncNamed(namedArguments)); |
463 }); | 463 }); |
464 } | 464 } |
465 | 465 |
466 InstanceMirror findInContext(Symbol name, {ifAbsent: null}) { | 466 InstanceMirror findInContext(Symbol name, {ifAbsent: null}) { |
467 List<String> parts = _n(name).split(".").toList(growable: false); | 467 List<String> parts = _n(name).split(".").toList(growable: false); |
468 if (parts.length > 3) { | 468 if (parts.length > 3) { |
469 throw new ArgumentError("Invalid symbol: ${name}"); | 469 throw new ArgumentError("Invalid symbol: ${name}"); |
470 } | 470 } |
471 List tuple = _computeFindInContext(_reflectee, parts); | 471 List tuple = _computeFindInContext(_reflectee, parts); |
| 472 if (tuple.length == 0) { |
| 473 throw new UnsupportedError( |
| 474 "ClosureMirror.findInContext not yet supported"); |
| 475 } |
472 if (tuple[0]) { | 476 if (tuple[0]) { |
473 return reflect(tuple[1]); | 477 return reflect(tuple[1]); |
474 } | 478 } |
475 return ifAbsent == null ? null : ifAbsent(); | 479 return ifAbsent == null ? null : ifAbsent(); |
476 } | 480 } |
477 | 481 |
478 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; | 482 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; |
479 | 483 |
480 static _apply(arguments, argumentNames) | 484 static _apply(arguments, argumentNames) |
481 native 'ClosureMirror_apply'; | 485 native 'ClosureMirror_apply'; |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 if (typeMirror == null) { | 1579 if (typeMirror == null) { |
1576 typeMirror = makeLocalTypeMirror(key); | 1580 typeMirror = makeLocalTypeMirror(key); |
1577 _instanitationCache[key] = typeMirror; | 1581 _instanitationCache[key] = typeMirror; |
1578 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1582 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1579 _declarationCache[key] = typeMirror; | 1583 _declarationCache[key] = typeMirror; |
1580 } | 1584 } |
1581 } | 1585 } |
1582 return typeMirror; | 1586 return typeMirror; |
1583 } | 1587 } |
1584 } | 1588 } |
OLD | NEW |