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

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

Issue 11523002: Pass the proper invocation mirror argument to noSuchMethod. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/error.dart ('k') | runtime/lib/object.cc » ('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 class _InvocationMirror implements InvocationMirror { 5 class _InvocationMirror implements InvocationMirror {
6 static final int METHOD = 0; 6 static final int METHOD = 0;
7 static final int GETTER = 1; 7 static final int GETTER = 1;
8 static final int SETTER = 2; 8 static final int SETTER = 2;
9 9
10 // TODO(regis): Compute lazily the value of these fields, and save the
11 // arguments passed into _allocateInvocationMirror.
12
10 final String memberName; 13 final String memberName;
11 final List positionalArguments; 14 final List positionalArguments;
12 final Map<String,dynamic> namedArguments = null; 15 final Map<String, dynamic> namedArguments;
13 16
14 final int _type; 17 final int _type;
15 18
16 _InvocationMirror(this.memberName, this._type, this.positionalArguments); 19 _InvocationMirror(this.memberName,
20 this._type,
21 this.positionalArguments,
22 this.namedArguments);
17 23
18 static _allocateInvocationMirror(name, arguments) { 24 static _allocateInvocationMirror(String name,
19 return new _InvocationMirror(name, METHOD, arguments); 25 List argumentsDescriptor,
26 List arguments) {
27 var memberName;
28 var type;
29 if (name.startsWith("get:")) {
30 type = GETTER;
31 memberName = name.substring(4);
32 } else if (name.startsWith("set:")) {
33 type = SETTER;
34 memberName = name.substring(4).concat("=");
35 } else {
36 type = METHOD;
37 memberName = name;
38 }
39 // Exclude receiver.
40 int numArguments = argumentsDescriptor[0] - 1;
41 int numPositionalArguments = argumentsDescriptor[1] - 1;
42 int numNamedArguments = numArguments - numPositionalArguments;
43 List positionalArguments = arguments.getRange(1, numPositionalArguments);
44 Map<String, dynamic> namedArguments;
45 if (numNamedArguments > 0) {
46 namedArguments = new Map<String, dynamic>();
47 for (int i = 0; i < numNamedArguments; i++) {
48 String arg_name = argumentsDescriptor[2 + 2*i];
49 var arg_value = arguments[argumentsDescriptor[3 + 2*i]];
50 namedArguments[arg_name] = arg_value;
51 }
52 }
53 return new _InvocationMirror(memberName, type,
54 positionalArguments, namedArguments);
20 } 55 }
21 56
22 bool get isMethod => _type == METHOD; 57 bool get isMethod => _type == METHOD;
23 bool get isAccessor => _type != METHOD; 58 bool get isAccessor => _type != METHOD;
24 bool get isGetter => _type == GETTER; 59 bool get isGetter => _type == GETTER;
25 bool get isSetter => _type == SETTER; 60 bool get isSetter => _type == SETTER;
26 61
27 invokeOn(Object receiver) { 62 invokeOn(Object receiver) {
28 throw new UnsupportedError("invokeOn not implemented yet"); 63 throw new UnsupportedError("invokeOn not implemented yet");
29 } 64 }
30 } 65 }
31 66
OLDNEW
« no previous file with comments | « runtime/lib/error.dart ('k') | runtime/lib/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698