| 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 class _InvocationMirror implements Invocation { | 5 class _InvocationMirror implements Invocation { |
| 6 // Constants describing the invocation type. | 6 // Constants describing the invocation type. |
| 7 // _FIELD cannot be generated by regular invocation mirrors. | 7 // _FIELD cannot be generated by regular invocation mirrors. |
| 8 static const int _METHOD = 0; | 8 static const int _METHOD = 0; |
| 9 static const int _GETTER = 1; | 9 static const int _GETTER = 1; |
| 10 static const int _SETTER = 2; | 10 static const int _SETTER = 2; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 Symbol get memberName { | 53 Symbol get memberName { |
| 54 if (_memberName == null) { | 54 if (_memberName == null) { |
| 55 _setMemberNameAndType(); | 55 _setMemberNameAndType(); |
| 56 } | 56 } |
| 57 return _memberName; | 57 return _memberName; |
| 58 } | 58 } |
| 59 | 59 |
| 60 List get positionalArguments { | 60 List get positionalArguments { |
| 61 if (_positionalArguments == null) { | 61 if (_positionalArguments == null) { |
| 62 int numPositionalArguments = _argumentsDescriptor[1]; | 62 int numPositionalArguments = _argumentsDescriptor[1]; |
| 63 // Don't count receiver. |
| 64 if (numPositionalArguments == 1) { |
| 65 return _positionalArguments = const []; |
| 66 } |
| 63 // Exclude receiver. | 67 // Exclude receiver. |
| 64 _positionalArguments = _arguments.sublist(1, numPositionalArguments); | 68 _positionalArguments = _arguments.sublist(1, numPositionalArguments); |
| 65 } | 69 } |
| 66 return _positionalArguments; | 70 return _positionalArguments; |
| 67 } | 71 } |
| 68 | 72 |
| 69 Map<Symbol, dynamic> get namedArguments { | 73 Map<Symbol, dynamic> get namedArguments { |
| 70 if (_namedArguments == null) { | 74 if (_namedArguments == null) { |
| 71 _namedArguments = new Map<Symbol, dynamic>(); | |
| 72 int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver. | 75 int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver. |
| 73 int numPositionalArguments = _argumentsDescriptor[1] - 1; | 76 int numPositionalArguments = _argumentsDescriptor[1] - 1; |
| 74 int numNamedArguments = numArguments - numPositionalArguments; | 77 int numNamedArguments = numArguments - numPositionalArguments; |
| 78 if (numNamedArguments == 0) { |
| 79 return _namedArguments = const <Symbol, dynamic>{}; |
| 80 } |
| 81 _namedArguments = new Map<Symbol, dynamic>(); |
| 75 for (int i = 0; i < numNamedArguments; i++) { | 82 for (int i = 0; i < numNamedArguments; i++) { |
| 76 String arg_name = _argumentsDescriptor[2 + 2*i]; | 83 String arg_name = _argumentsDescriptor[2 + 2*i]; |
| 77 var arg_value = _arguments[_argumentsDescriptor[3 + 2*i]]; | 84 var arg_value = _arguments[_argumentsDescriptor[3 + 2*i]]; |
| 78 _namedArguments[new _collection_dev.Symbol.unvalidated(arg_name)] = | 85 _namedArguments[new _collection_dev.Symbol.unvalidated(arg_name)] = |
| 79 arg_value; | 86 arg_value; |
| 80 } | 87 } |
| 81 } | 88 } |
| 82 return _namedArguments; | 89 return _namedArguments; |
| 83 } | 90 } |
| 84 | 91 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 native "InvocationMirror_invoke"; | 134 native "InvocationMirror_invoke"; |
| 128 | 135 |
| 129 _invokeOn(Object receiver) { | 136 _invokeOn(Object receiver) { |
| 130 return _invoke(receiver, _functionName, _argumentsDescriptor, _arguments); | 137 return _invoke(receiver, _functionName, _argumentsDescriptor, _arguments); |
| 131 } | 138 } |
| 132 | 139 |
| 133 // TODO(ahe): This is a hack. See _LocalInstanceMirrorImpl.delegate | 140 // TODO(ahe): This is a hack. See _LocalInstanceMirrorImpl.delegate |
| 134 // in mirrors_impl.dart | 141 // in mirrors_impl.dart |
| 135 static final _invokeOnClosure = (x, y) => y._invokeOn(x); | 142 static final _invokeOnClosure = (x, y) => y._invokeOn(x); |
| 136 } | 143 } |
| OLD | NEW |