Chromium Code Reviews| Index: runtime/lib/invocation_mirror_patch.dart |
| =================================================================== |
| --- runtime/lib/invocation_mirror_patch.dart (revision 15932) |
| +++ runtime/lib/invocation_mirror_patch.dart (working copy) |
| @@ -7,16 +7,50 @@ |
| static final int GETTER = 1; |
| static final int SETTER = 2; |
| + // TODO(regis): For efficiency, make these fields caches of getters and keep |
| + // the internal representation as an array of positional arguments and an |
| + // arguments descriptor. |
|
srdjan
2012/12/10 23:55:39
Maybe change comment, something like:
Compute laz
regis
2012/12/11 00:11:04
Done.
|
| + |
| final String memberName; |
| final List positionalArguments; |
| - final Map<String,dynamic> namedArguments = null; |
| + final Map<String, dynamic> namedArguments; |
| final int _type; |
| - _InvocationMirror(this.memberName, this._type, this.positionalArguments); |
| + _InvocationMirror(this.memberName, |
| + this._type, |
| + this.positionalArguments, |
| + this.namedArguments); |
| - static _allocateInvocationMirror(name, arguments) { |
| - return new _InvocationMirror(name, METHOD, arguments); |
| + static _allocateInvocationMirror(name, argumentsDescriptor, arguments) { |
|
srdjan
2012/12/10 23:55:39
Add types (result and arguments).
regis
2012/12/11 00:11:04
The types were omitted on purpose, since this is a
|
| + var memberName; |
| + var type; |
| + if (name.startsWith("get:")) { |
| + type = GETTER; |
| + memberName = name.substring(4); |
| + } else if (name.startsWith("set:")) { |
| + type = SETTER; |
| + memberName = name.substring(4).concat("="); |
| + } else { |
| + type = METHOD; |
| + memberName = name; |
| + } |
| + // Exclude receiver. |
| + int numArguments = argumentsDescriptor[0] - 1; |
| + int numPositionalArguments = argumentsDescriptor[1] - 1; |
| + int numNamedArguments = numArguments - numPositionalArguments; |
| + List positionalArguments = arguments.getRange(1, numPositionalArguments); |
| + Map<String, dynamic> namedArguments; |
| + if (numNamedArguments > 0) { |
| + namedArguments = new Map<String, dynamic>(); |
| + for (int i = 0; i < numNamedArguments; i++) { |
| + String arg_name = argumentsDescriptor[2 + 2*i]; |
| + var arg_value = arguments[argumentsDescriptor[3 + 2*i]]; |
| + namedArguments[arg_name] = arg_value; |
| + } |
| + } |
| + return new _InvocationMirror(memberName, type, |
| + positionalArguments, namedArguments); |
| } |
| bool get isMethod => _type == METHOD; |