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

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 276043003: Lay waste to ClosureMirror.findInContext. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove stub in dart2js Created 6 years, 7 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
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 final emptyList = new UnmodifiableListView([]); 9 final emptyList = new UnmodifiableListView([]);
10 final emptyMap = new UnmodifiableMapView({}); 10 final emptyMap = new UnmodifiableMapView({});
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 _function = _computeFunction(reflectee); 449 _function = _computeFunction(reflectee);
450 } 450 }
451 return _function; 451 return _function;
452 } 452 }
453 453
454 InstanceMirror apply(List<Object> positionalArguments, 454 InstanceMirror apply(List<Object> positionalArguments,
455 [Map<Symbol, Object> namedArguments]) { 455 [Map<Symbol, Object> namedArguments]) {
456 return this.invoke(#call, positionalArguments, namedArguments); 456 return this.invoke(#call, positionalArguments, namedArguments);
457 } 457 }
458 458
459 InstanceMirror findInContext(Symbol name, {ifAbsent: null}) {
460 List<String> parts = _n(name).split(".").toList(growable: false);
461 if (parts.length > 3) {
462 throw new ArgumentError("Invalid symbol: ${name}");
463 }
464 List tuple = _computeFindInContext(_reflectee, parts);
465 if (tuple.length == 0) {
466 throw new UnsupportedError(
467 "ClosureMirror.findInContext not yet supported");
468 }
469 if (tuple[0]) {
470 return reflect(tuple[1]);
471 }
472 return ifAbsent == null ? null : ifAbsent();
473 }
474
475 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; 459 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'";
476 460
477 static _computeFunction(reflectee) 461 static _computeFunction(reflectee)
478 native 'ClosureMirror_function'; 462 native 'ClosureMirror_function';
479
480 static _computeFindInContext(reflectee, name)
481 native 'ClosureMirror_find_in_context';
482 } 463 }
483 464
484 class _LocalClassMirror extends _LocalObjectMirror 465 class _LocalClassMirror extends _LocalObjectMirror
485 implements ClassMirror { 466 implements ClassMirror {
486 final Type _reflectedType; 467 final Type _reflectedType;
487 Symbol _simpleName; 468 Symbol _simpleName;
488 DeclarationMirror _owner; 469 DeclarationMirror _owner;
489 final bool isAbstract; 470 final bool isAbstract;
490 final bool _isGeneric; 471 final bool _isGeneric;
491 final bool _isMixinAlias; 472 final bool _isMixinAlias;
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 if (typeMirror == null) { 1587 if (typeMirror == null) {
1607 typeMirror = makeLocalTypeMirror(key); 1588 typeMirror = makeLocalTypeMirror(key);
1608 _instanitationCache[key] = typeMirror; 1589 _instanitationCache[key] = typeMirror;
1609 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1590 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1610 _declarationCache[key] = typeMirror; 1591 _declarationCache[key] = typeMirror;
1611 } 1592 }
1612 } 1593 }
1613 return typeMirror; 1594 return typeMirror;
1614 } 1595 }
1615 } 1596 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698