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 11 matching lines...) Expand all Loading... |
22 static const int _CALL_SHIFT = _TYPE_BITS; | 22 static const int _CALL_SHIFT = _TYPE_BITS; |
23 static const int _CALL_BITS = 2; | 23 static const int _CALL_BITS = 2; |
24 static const int _CALL_MASK = (1 << _CALL_BITS) - 1; | 24 static const int _CALL_MASK = (1 << _CALL_BITS) - 1; |
25 | 25 |
26 // Internal representation of the invocation mirror. | 26 // Internal representation of the invocation mirror. |
27 final String _functionName; | 27 final String _functionName; |
28 final List _argumentsDescriptor; | 28 final List _argumentsDescriptor; |
29 final List _arguments; | 29 final List _arguments; |
30 | 30 |
31 // External representation of the invocation mirror; populated on demand. | 31 // External representation of the invocation mirror; populated on demand. |
32 String _memberName; | 32 Symbol _memberName; |
33 int _type; | 33 int _type; |
34 List _positionalArguments; | 34 List _positionalArguments; |
35 Map<String, dynamic> _namedArguments; | 35 Map<Symbol, dynamic> _namedArguments; |
36 | 36 |
37 void _setMemberNameAndType() { | 37 void _setMemberNameAndType() { |
38 if (_functionName.startsWith("get:")) { | 38 if (_functionName.startsWith("get:")) { |
39 _type = _GETTER; | 39 _type = _GETTER; |
40 _memberName = _functionName.substring(4); | 40 _memberName = |
| 41 new _collection_dev.Symbol.unvalidated(_functionName.substring(4)); |
41 } else if (_functionName.startsWith("set:")) { | 42 } else if (_functionName.startsWith("set:")) { |
42 _type = _SETTER; | 43 _type = _SETTER; |
43 _memberName = _functionName.substring(4) + "="; | 44 _memberName = |
| 45 new _collection_dev.Symbol.unvalidated( |
| 46 _functionName.substring(4) + "="); |
44 } else { | 47 } else { |
45 _type = _METHOD; | 48 _type = _METHOD; |
46 _memberName = _functionName; | 49 _memberName = new _collection_dev.Symbol.unvalidated(_functionName); |
47 } | 50 } |
48 } | 51 } |
49 | 52 |
50 String get memberName { | 53 Symbol get memberName { |
51 if (_memberName == null) { | 54 if (_memberName == null) { |
52 _setMemberNameAndType(); | 55 _setMemberNameAndType(); |
53 } | 56 } |
54 return _memberName; | 57 return _memberName; |
55 } | 58 } |
56 | 59 |
57 List get positionalArguments { | 60 List get positionalArguments { |
58 if (_positionalArguments == null) { | 61 if (_positionalArguments == null) { |
59 int numPositionalArguments = _argumentsDescriptor[1]; | 62 int numPositionalArguments = _argumentsDescriptor[1]; |
60 // Exclude receiver. | 63 // Exclude receiver. |
61 _positionalArguments = _arguments.sublist(1, numPositionalArguments); | 64 _positionalArguments = _arguments.sublist(1, numPositionalArguments); |
62 } | 65 } |
63 return _positionalArguments; | 66 return _positionalArguments; |
64 } | 67 } |
65 | 68 |
66 Map<String, dynamic> get namedArguments { | 69 Map<Symbol, dynamic> get namedArguments { |
67 if (_namedArguments == null) { | 70 if (_namedArguments == null) { |
68 _namedArguments = new Map<String, dynamic>(); | 71 _namedArguments = new Map<Symbol, dynamic>(); |
69 int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver. | 72 int numArguments = _argumentsDescriptor[0] - 1; // Exclude receiver. |
70 int numPositionalArguments = _argumentsDescriptor[1] - 1; | 73 int numPositionalArguments = _argumentsDescriptor[1] - 1; |
71 int numNamedArguments = numArguments - numPositionalArguments; | 74 int numNamedArguments = numArguments - numPositionalArguments; |
72 for (int i = 0; i < numNamedArguments; i++) { | 75 for (int i = 0; i < numNamedArguments; i++) { |
73 String arg_name = _argumentsDescriptor[2 + 2*i]; | 76 String arg_name = _argumentsDescriptor[2 + 2*i]; |
74 var arg_value = _arguments[_argumentsDescriptor[3 + 2*i]]; | 77 var arg_value = _arguments[_argumentsDescriptor[3 + 2*i]]; |
75 _namedArguments[arg_name] = arg_value; | 78 _namedArguments[new _collection_dev.Symbol.unvalidated(arg_name)] = |
| 79 arg_value; |
76 } | 80 } |
77 } | 81 } |
78 return _namedArguments; | 82 return _namedArguments; |
79 } | 83 } |
80 | 84 |
81 bool get isMethod { | 85 bool get isMethod { |
82 if (_type == null) { | 86 if (_type == null) { |
83 _setMemberNameAndType(); | 87 _setMemberNameAndType(); |
84 } | 88 } |
85 return _type == _METHOD; | 89 return _type == _METHOD; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 String functionName, | 124 String functionName, |
121 List argumentsDescriptor, | 125 List argumentsDescriptor, |
122 List arguments) | 126 List arguments) |
123 native "InvocationMirror_invoke"; | 127 native "InvocationMirror_invoke"; |
124 | 128 |
125 invokeOn(Object receiver) { | 129 invokeOn(Object receiver) { |
126 return _invoke(receiver, _functionName, _argumentsDescriptor, _arguments); | 130 return _invoke(receiver, _functionName, _argumentsDescriptor, _arguments); |
127 } | 131 } |
128 } | 132 } |
129 | 133 |
OLD | NEW |