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

Side by Side Diff: tests/compiler/dart2js/semantic_visitor_test.dart

Issue 1001243003: Pass the call selector for local invocations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library dart2js.semantics_visitor_test; 5 library dart2js.semantics_visitor_test;
6 6
7 import 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 import 'package:compiler/src/constants/expressions.dart'; 9 import 'package:compiler/src/constants/expressions.dart';
10 import 'package:compiler/src/dart_types.dart'; 10 import 'package:compiler/src/dart_types.dart';
(...skipping 15 matching lines...) Expand all
26 final name; 26 final name;
27 final expression; 27 final expression;
28 final left; 28 final left;
29 final right; 29 final right;
30 final type; 30 final type;
31 final operator; 31 final operator;
32 final index; 32 final index;
33 final getter; 33 final getter;
34 final setter; 34 final setter;
35 final constant; 35 final constant;
36 final selector;
36 37
37 const Visit(this.method, 38 const Visit(this.method,
38 {this.element, 39 {this.element,
39 this.rhs, 40 this.rhs,
40 this.arguments, 41 this.arguments,
41 this.receiver, 42 this.receiver,
42 this.name, 43 this.name,
43 this.expression, 44 this.expression,
44 this.left, 45 this.left,
45 this.right, 46 this.right,
46 this.type, 47 this.type,
47 this.operator, 48 this.operator,
48 this.index, 49 this.index,
49 this.getter, 50 this.getter,
50 this.setter, 51 this.setter,
51 this.constant}); 52 this.constant,
53 this.selector});
52 54
53 int get hashCode => toString().hashCode; 55 int get hashCode => toString().hashCode;
54 56
55 bool operator ==(other) => '$this' == '$other'; 57 bool operator ==(other) => '$this' == '$other';
56 58
57 String toString() { 59 String toString() {
58 StringBuffer sb = new StringBuffer(); 60 StringBuffer sb = new StringBuffer();
59 sb.write('method=$method'); 61 sb.write('method=$method');
60 if (element != null) { 62 if (element != null) {
61 sb.write(',element=$element'); 63 sb.write(',element=$element');
(...skipping 30 matching lines...) Expand all
92 } 94 }
93 if (getter != null) { 95 if (getter != null) {
94 sb.write(',getter=$getter'); 96 sb.write(',getter=$getter');
95 } 97 }
96 if (setter != null) { 98 if (setter != null) {
97 sb.write(',setter=$setter'); 99 sb.write(',setter=$setter');
98 } 100 }
99 if (constant != null) { 101 if (constant != null) {
100 sb.write(',constant=$constant'); 102 sb.write(',constant=$constant');
101 } 103 }
104 if (selector != null) {
105 sb.write(',selector=$selector');
106 }
102 return sb.toString(); 107 return sb.toString();
103 } 108 }
104 } 109 }
105 110
106 class Test { 111 class Test {
107 final String codeByPrefix; 112 final String codeByPrefix;
108 final String code; 113 final String code;
109 final /*Visit | List<Visit>*/ expectedVisits; 114 final /*Visit | List<Visit>*/ expectedVisits;
110 final String cls; 115 final String cls;
111 116
(...skipping 23 matching lines...) Expand all
135 const Test('m(o) => o;', 140 const Test('m(o) => o;',
136 const Visit(VisitKind.VISIT_PARAMETER_GET, 141 const Visit(VisitKind.VISIT_PARAMETER_GET,
137 element: 'parameter(m#o)')), 142 element: 'parameter(m#o)')),
138 const Test('m(o) { o = 42; }', 143 const Test('m(o) { o = 42; }',
139 const Visit(VisitKind.VISIT_PARAMETER_SET, 144 const Visit(VisitKind.VISIT_PARAMETER_SET,
140 element: 'parameter(m#o)', 145 element: 'parameter(m#o)',
141 rhs:'42')), 146 rhs:'42')),
142 const Test('m(o) { o(null, 42); }', 147 const Test('m(o) { o(null, 42); }',
143 const Visit(VisitKind.VISIT_PARAMETER_INVOKE, 148 const Visit(VisitKind.VISIT_PARAMETER_INVOKE,
144 element: 'parameter(m#o)', 149 element: 'parameter(m#o)',
145 arguments: '(null,42)')), 150 arguments: '(null,42)',
151 selector: 'Selector(call, call, arity=2)')),
146 152
147 // Local variables 153 // Local variables
148 const Test('m() { var o; return o; }', 154 const Test('m() { var o; return o; }',
149 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET, 155 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET,
150 element: 'variable(m#o)')), 156 element: 'variable(m#o)')),
151 const Test('m() { var o; o = 42; }', 157 const Test('m() { var o; o = 42; }',
152 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET, 158 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET,
153 element: 'variable(m#o)', 159 element: 'variable(m#o)',
154 rhs:'42')), 160 rhs:'42')),
155 const Test('m() { var o; o(null, 42); }', 161 const Test('m() { var o; o(null, 42); }',
156 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE, 162 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE,
157 element: 'variable(m#o)', 163 element: 'variable(m#o)',
158 arguments: '(null,42)')), 164 arguments: '(null,42)',
165 selector: 'Selector(call, call, arity=2)')),
159 166
160 // Local functions 167 // Local functions
161 const Test('m() { o(a, b) {}; return o; }', 168 const Test('m() { o(a, b) {}; return o; }',
162 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_GET, 169 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_GET,
163 element: 'function(m#o)')), 170 element: 'function(m#o)')),
164 const Test('m() { o(a, b) {}; o(null, 42); }', 171 const Test('m() { o(a, b) {}; o(null, 42); }',
165 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE, 172 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE,
166 element: 'function(m#o)', 173 element: 'function(m#o)',
167 arguments: '(null,42)')), 174 arguments: '(null,42)',
175 selector: 'Selector(call, call, arity=2)')),
168 176
169 // Static fields 177 // Static fields
170 const Test( 178 const Test(
171 ''' 179 '''
172 class C { static var o; } 180 class C { static var o; }
173 m() => C.o; 181 m() => C.o;
174 ''', 182 ''',
175 const Visit(VisitKind.VISIT_STATIC_FIELD_GET, 183 const Visit(VisitKind.VISIT_STATIC_FIELD_GET,
176 element: 'field(C#o)')), 184 element: 'field(C#o)')),
177 const Test.clazz( 185 const Test.clazz(
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 } 2278 }
2271 2279
2272 @override 2280 @override
2273 visitLocalFunctionInvoke( 2281 visitLocalFunctionInvoke(
2274 Send node, 2282 Send node,
2275 LocalFunctionElement function, 2283 LocalFunctionElement function,
2276 NodeList arguments, 2284 NodeList arguments,
2277 Selector selector, 2285 Selector selector,
2278 arg) { 2286 arg) {
2279 visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE, 2287 visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE,
2280 element: function, arguments: arguments)); 2288 element: function, arguments: arguments, selector: selector));
2281 apply(arguments, arg); 2289 apply(arguments, arg);
2282 } 2290 }
2283 2291
2284 @override 2292 @override
2285 visitLocalVariableGet( 2293 visitLocalVariableGet(
2286 Send node, 2294 Send node,
2287 LocalVariableElement variable, 2295 LocalVariableElement variable,
2288 arg) { 2296 arg) {
2289 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET, 2297 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET,
2290 element: variable)); 2298 element: variable));
2291 } 2299 }
2292 2300
2293 @override 2301 @override
2294 visitLocalVariableInvoke( 2302 visitLocalVariableInvoke(
2295 Send node, 2303 Send node,
2296 LocalVariableElement variable, 2304 LocalVariableElement variable,
2297 NodeList arguments, 2305 NodeList arguments,
2298 Selector selector, 2306 Selector selector,
2299 arg) { 2307 arg) {
2300 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE, 2308 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE,
2301 element: variable, arguments: arguments)); 2309 element: variable, arguments: arguments, selector: selector));
2302 apply(arguments, arg); 2310 apply(arguments, arg);
2303 } 2311 }
2304 2312
2305 @override 2313 @override
2306 visitLocalVariableSet( 2314 visitLocalVariableSet(
2307 SendSet node, 2315 SendSet node,
2308 LocalVariableElement variable, 2316 LocalVariableElement variable,
2309 Node rhs, 2317 Node rhs,
2310 arg) { 2318 arg) {
2311 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET, 2319 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET,
(...skipping 10 matching lines...) Expand all
2322 } 2330 }
2323 2331
2324 @override 2332 @override
2325 visitParameterInvoke( 2333 visitParameterInvoke(
2326 Send node, 2334 Send node,
2327 ParameterElement parameter, 2335 ParameterElement parameter,
2328 NodeList arguments, 2336 NodeList arguments,
2329 Selector selector, 2337 Selector selector,
2330 arg) { 2338 arg) {
2331 visits.add(new Visit(VisitKind.VISIT_PARAMETER_INVOKE, 2339 visits.add(new Visit(VisitKind.VISIT_PARAMETER_INVOKE,
2332 element: parameter, arguments: arguments)); 2340 element: parameter, arguments: arguments, selector: selector));
2333 apply(arguments, arg); 2341 apply(arguments, arg);
2334 } 2342 }
2335 2343
2336 @override 2344 @override
2337 visitParameterSet( 2345 visitParameterSet(
2338 SendSet node, 2346 SendSet node,
2339 ParameterElement parameter, 2347 ParameterElement parameter,
2340 Node rhs, 2348 Node rhs,
2341 arg) { 2349 arg) {
2342 visits.add(new Visit(VisitKind.VISIT_PARAMETER_SET, 2350 visits.add(new Visit(VisitKind.VISIT_PARAMETER_SET,
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after
3994 4002
3995 VISIT_ASSERT, 4003 VISIT_ASSERT,
3996 VISIT_LOGICAL_AND, 4004 VISIT_LOGICAL_AND,
3997 VISIT_LOGICAL_OR, 4005 VISIT_LOGICAL_OR,
3998 VISIT_IS, 4006 VISIT_IS,
3999 VISIT_IS_NOT, 4007 VISIT_IS_NOT,
4000 VISIT_AS, 4008 VISIT_AS,
4001 4009
4002 // TODO(johnniwinther): Add tests for error cases. 4010 // TODO(johnniwinther): Add tests for error cases.
4003 } 4011 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698