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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 | 440 |
441 MethodMirror _function; | 441 MethodMirror _function; |
442 MethodMirror get function { | 442 MethodMirror get function { |
443 if (_function == null) { | 443 if (_function == null) { |
444 _function = _computeFunction(reflectee); | 444 _function = _computeFunction(reflectee); |
445 } | 445 } |
446 return _function; | 446 return _function; |
447 } | 447 } |
448 | 448 |
449 // TODO(12602): Remove this special case. | 449 // TODO(12602): Remove this special case. |
450 delegate(Invocation invocation) { | 450 InstanceMirror invoke(Symbol memberName, |
451 if (invocation.isMethod && (invocation.memberName == #call)) { | 451 List positionalArguments, |
452 return this.apply(invocation.positionalArguments, | 452 [Map<Symbol, dynamic> namedArguments]) { |
453 invocation.namedArguments).reflectee; | 453 if (memberName == #call) { |
454 return this.apply(positionalArguments, namedArguments); | |
454 } | 455 } |
455 return super.delegate(invocation); | 456 return super.invoke(memberName, positionalArguments, namedArguments); |
456 } | 457 } |
457 | 458 |
458 InstanceMirror apply(List<Object> positionalArguments, | 459 InstanceMirror apply(List<Object> positionalArguments, |
459 [Map<Symbol, Object> namedArguments]) { | 460 [Map<Symbol, Object> namedArguments]) { |
460 // TODO(12602): When closures get an ordinary call method, this can be | 461 // TODO(12602): When closures get an ordinary call method, this can be |
461 // replaced with | 462 // replaced with |
462 // return this.invoke(#call, positionalArguments, namedArguments); | 463 // return this.invoke(#call, positionalArguments, namedArguments); |
Florian Schneider
2014/03/13 08:14:18
Functions now have a .call method for invocation.
| |
463 // and the native ClosureMirror_apply can be removed. | 464 // and the native ClosureMirror_apply can be removed. |
464 int numPositionalArguments = positionalArguments.length + 1; // Receiver. | 465 int numPositionalArguments = positionalArguments.length + 1; // Receiver. |
465 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; | 466 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; |
466 int numArguments = numPositionalArguments + numNamedArguments; | 467 int numArguments = numPositionalArguments + numNamedArguments; |
467 List arguments = new List(numArguments); | 468 List arguments = new List(numArguments); |
468 arguments[0] = _reflectee; // Receiver. | 469 arguments[0] = _reflectee; // Receiver. |
469 arguments.setRange(1, numPositionalArguments, positionalArguments); | 470 arguments.setRange(1, numPositionalArguments, positionalArguments); |
470 List names = new List(numNamedArguments); | 471 List names = new List(numNamedArguments); |
471 int argumentIndex = numPositionalArguments; | 472 int argumentIndex = numPositionalArguments; |
472 int nameIndex = 0; | 473 int nameIndex = 0; |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1630 if (typeMirror == null) { | 1631 if (typeMirror == null) { |
1631 typeMirror = makeLocalTypeMirror(key); | 1632 typeMirror = makeLocalTypeMirror(key); |
1632 _instanitationCache[key] = typeMirror; | 1633 _instanitationCache[key] = typeMirror; |
1633 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1634 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1634 _declarationCache[key] = typeMirror; | 1635 _declarationCache[key] = typeMirror; |
1635 } | 1636 } |
1636 } | 1637 } |
1637 return typeMirror; | 1638 return typeMirror; |
1638 } | 1639 } |
1639 } | 1640 } |
OLD | NEW |