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

Side by Side Diff: pkg/compiler/lib/src/resolution/send_structure.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
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.resolution.send_structure; 5 library dart2js.resolution.send_structure;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
11 import '../resolution/tree_elements.dart' show 11 import '../resolution/tree_elements.dart' show TreeElements;
12 TreeElements;
13 import '../tree/tree.dart'; 12 import '../tree/tree.dart';
14 import '../universe/call_structure.dart' show 13 import '../universe/call_structure.dart' show CallStructure;
15 CallStructure; 14 import '../universe/selector.dart' show Selector;
16 import '../universe/selector.dart' show
17 Selector;
18 15
19 import 'access_semantics.dart'; 16 import 'access_semantics.dart';
20 import 'operators.dart'; 17 import 'operators.dart';
21 import 'semantic_visitor.dart'; 18 import 'semantic_visitor.dart';
22 19
23 /// Interface for the structure of the semantics of a [Send] or [NewExpression] 20 /// Interface for the structure of the semantics of a [Send] or [NewExpression]
24 /// node. 21 /// node.
25 abstract class SemanticSendStructure<R, A> { 22 abstract class SemanticSendStructure<R, A> {
26 /// Calls the matching visit method on [visitor] with [node] and [arg]. 23 /// Calls the matching visit method on [visitor] with [node] and [arg].
27 R dispatch(SemanticSendVisitor<R, A> visitor, Node node, A arg); 24 R dispatch(SemanticSendVisitor<R, A> visitor, Node node, A arg);
28 } 25 }
29 26
30 /// Interface for the structure of the semantics of a [Send] node. 27 /// Interface for the structure of the semantics of a [Send] node.
31 /// 28 ///
32 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, 29 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`,
33 /// `a.b`, `a.b(c)`, etc. 30 /// `a.b`, `a.b(c)`, etc.
34 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> { 31 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> {
35 /// Calls the matching visit method on [visitor] with [send] and [arg]. 32 /// Calls the matching visit method on [visitor] with [send] and [arg].
36 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); 33 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg);
37 } 34 }
38 35
39 /// The structure for a [Send] of the form `a ?? b`. 36 /// The structure for a [Send] of the form `a ?? b`.
40 class IfNullStructure<R, A> implements SendStructure<R, A> { 37 class IfNullStructure<R, A> implements SendStructure<R, A> {
41 const IfNullStructure(); 38 const IfNullStructure();
42 39
43 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 40 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
44 return visitor.visitIfNull( 41 return visitor.visitIfNull(node, node.receiver, node.arguments.single, arg);
45 node,
46 node.receiver,
47 node.arguments.single,
48 arg);
49 } 42 }
50 43
51 String toString() => '??'; 44 String toString() => '??';
52 } 45 }
53 46
54 /// The structure for a [Send] of the form `a && b`. 47 /// The structure for a [Send] of the form `a && b`.
55 class LogicalAndStructure<R, A> implements SendStructure<R, A> { 48 class LogicalAndStructure<R, A> implements SendStructure<R, A> {
56 const LogicalAndStructure(); 49 const LogicalAndStructure();
57 50
58 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 51 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
59 return visitor.visitLogicalAnd( 52 return visitor.visitLogicalAnd(
60 node, 53 node, node.receiver, node.arguments.single, arg);
61 node.receiver,
62 node.arguments.single,
63 arg);
64 } 54 }
65 55
66 String toString() => '&&'; 56 String toString() => '&&';
67 } 57 }
68 58
69 /// The structure for a [Send] of the form `a || b`. 59 /// The structure for a [Send] of the form `a || b`.
70 class LogicalOrStructure<R, A> implements SendStructure<R, A> { 60 class LogicalOrStructure<R, A> implements SendStructure<R, A> {
71 const LogicalOrStructure(); 61 const LogicalOrStructure();
72 62
73 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 63 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
74 return visitor.visitLogicalOr( 64 return visitor.visitLogicalOr(
75 node, 65 node, node.receiver, node.arguments.single, arg);
76 node.receiver,
77 node.arguments.single,
78 arg);
79 } 66 }
80 67
81 String toString() => '||'; 68 String toString() => '||';
82 } 69 }
83 70
84 /// The structure for a [Send] of the form `a is T`. 71 /// The structure for a [Send] of the form `a is T`.
85 class IsStructure<R, A> implements SendStructure<R, A> { 72 class IsStructure<R, A> implements SendStructure<R, A> {
86 /// The type that the expression is tested against. 73 /// The type that the expression is tested against.
87 final DartType type; 74 final DartType type;
88 75
89 IsStructure(this.type); 76 IsStructure(this.type);
90 77
91 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 78 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
92 return visitor.visitIs( 79 return visitor.visitIs(node, node.receiver, type, arg);
93 node,
94 node.receiver,
95 type,
96 arg);
97 } 80 }
98 81
99 String toString() => 'is $type'; 82 String toString() => 'is $type';
100 } 83 }
101 84
102 /// The structure for a [Send] of the form `a is! T`. 85 /// The structure for a [Send] of the form `a is! T`.
103 class IsNotStructure<R, A> implements SendStructure<R, A> { 86 class IsNotStructure<R, A> implements SendStructure<R, A> {
104 /// The type that the expression is tested against. 87 /// The type that the expression is tested against.
105 final DartType type; 88 final DartType type;
106 89
107 IsNotStructure(this.type); 90 IsNotStructure(this.type);
108 91
109 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 92 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
110 return visitor.visitIsNot( 93 return visitor.visitIsNot(node, node.receiver, type, arg);
111 node,
112 node.receiver,
113 type,
114 arg);
115 } 94 }
116 95
117 String toString() => 'is! $type'; 96 String toString() => 'is! $type';
118 } 97 }
119 98
120 /// The structure for a [Send] of the form `a as T`. 99 /// The structure for a [Send] of the form `a as T`.
121 class AsStructure<R, A> implements SendStructure<R, A> { 100 class AsStructure<R, A> implements SendStructure<R, A> {
122 /// The type that the expression is cast to. 101 /// The type that the expression is cast to.
123 final DartType type; 102 final DartType type;
124 103
125 AsStructure(this.type); 104 AsStructure(this.type);
126 105
127 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 106 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
128 return visitor.visitAs( 107 return visitor.visitAs(node, node.receiver, type, arg);
129 node,
130 node.receiver,
131 type,
132 arg);
133 } 108 }
134 109
135 String toString() => 'as $type'; 110 String toString() => 'as $type';
136 } 111 }
137 112
138 /// The structure for a [Send] that is an invocation. 113 /// The structure for a [Send] that is an invocation.
139 class InvokeStructure<R, A> implements SendStructure<R, A> { 114 class InvokeStructure<R, A> implements SendStructure<R, A> {
140 /// The target of the invocation. 115 /// The target of the invocation.
141 final AccessSemantics semantics; 116 final AccessSemantics semantics;
142 117
143 /// The [Selector] for the invocation. 118 /// The [Selector] for the invocation.
144 // TODO(johnniwinther): Store this only for dynamic invocations. 119 // TODO(johnniwinther): Store this only for dynamic invocations.
145 final Selector selector; 120 final Selector selector;
146 121
147 /// The [CallStructure] of the invocation. 122 /// The [CallStructure] of the invocation.
148 // TODO(johnniwinther): Store this directly for static invocations. 123 // TODO(johnniwinther): Store this directly for static invocations.
149 CallStructure get callStructure => selector.callStructure; 124 CallStructure get callStructure => selector.callStructure;
150 125
151 InvokeStructure(this.semantics, this.selector); 126 InvokeStructure(this.semantics, this.selector);
152 127
153 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 128 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
154 switch (semantics.kind) { 129 switch (semantics.kind) {
155 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 130 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
156 return visitor.visitIfNotNullDynamicPropertyInvoke( 131 return visitor.visitIfNotNullDynamicPropertyInvoke(
157 node, 132 node, node.receiver, node.argumentsNode, selector, arg);
158 node.receiver,
159 node.argumentsNode,
160 selector,
161 arg);
162 case AccessKind.DYNAMIC_PROPERTY: 133 case AccessKind.DYNAMIC_PROPERTY:
163 return visitor.visitDynamicPropertyInvoke( 134 return visitor.visitDynamicPropertyInvoke(
164 node, 135 node, node.receiver, node.argumentsNode, selector, arg);
165 node.receiver,
166 node.argumentsNode,
167 selector,
168 arg);
169 case AccessKind.LOCAL_FUNCTION: 136 case AccessKind.LOCAL_FUNCTION:
170 return visitor.visitLocalFunctionInvoke( 137 return visitor.visitLocalFunctionInvoke(
171 node, 138 node,
172 semantics.element, 139 semantics.element,
173 node.argumentsNode, 140 node.argumentsNode,
174 // TODO(johnniwinther): Store the call selector instead of the 141 // TODO(johnniwinther): Store the call selector instead of the
175 // selector using the name of the function. 142 // selector using the name of the function.
176 callStructure, 143 callStructure,
177 arg); 144 arg);
178 case AccessKind.LOCAL_VARIABLE: 145 case AccessKind.LOCAL_VARIABLE:
(...skipping 12 matching lines...) Expand all
191 node, 158 node,
192 semantics.element, 159 semantics.element,
193 node.argumentsNode, 160 node.argumentsNode,
194 // TODO(johnniwinther): Store the call selector instead of the 161 // TODO(johnniwinther): Store the call selector instead of the
195 // selector using the name of the parameter. 162 // selector using the name of the parameter.
196 callStructure, 163 callStructure,
197 arg); 164 arg);
198 case AccessKind.STATIC_FIELD: 165 case AccessKind.STATIC_FIELD:
199 case AccessKind.FINAL_STATIC_FIELD: 166 case AccessKind.FINAL_STATIC_FIELD:
200 return visitor.visitStaticFieldInvoke( 167 return visitor.visitStaticFieldInvoke(
201 node, 168 node, semantics.element, node.argumentsNode, callStructure, arg);
202 semantics.element,
203 node.argumentsNode,
204 callStructure,
205 arg);
206 case AccessKind.STATIC_METHOD: 169 case AccessKind.STATIC_METHOD:
207 return visitor.visitStaticFunctionInvoke( 170 return visitor.visitStaticFunctionInvoke(
208 node, 171 node, semantics.element, node.argumentsNode, callStructure, arg);
209 semantics.element,
210 node.argumentsNode,
211 callStructure,
212 arg);
213 case AccessKind.STATIC_GETTER: 172 case AccessKind.STATIC_GETTER:
214 return visitor.visitStaticGetterInvoke( 173 return visitor.visitStaticGetterInvoke(
215 node, 174 node, semantics.element, node.argumentsNode, callStructure, arg);
216 semantics.element,
217 node.argumentsNode,
218 callStructure,
219 arg);
220 case AccessKind.STATIC_SETTER: 175 case AccessKind.STATIC_SETTER:
221 return visitor.visitStaticSetterInvoke( 176 return visitor.visitStaticSetterInvoke(
222 node, 177 node, semantics.element, node.argumentsNode, callStructure, arg);
223 semantics.element,
224 node.argumentsNode,
225 callStructure,
226 arg);
227 case AccessKind.TOPLEVEL_FIELD: 178 case AccessKind.TOPLEVEL_FIELD:
228 case AccessKind.FINAL_TOPLEVEL_FIELD: 179 case AccessKind.FINAL_TOPLEVEL_FIELD:
229 return visitor.visitTopLevelFieldInvoke( 180 return visitor.visitTopLevelFieldInvoke(
230 node, 181 node, semantics.element, node.argumentsNode, callStructure, arg);
231 semantics.element,
232 node.argumentsNode,
233 callStructure,
234 arg);
235 case AccessKind.TOPLEVEL_METHOD: 182 case AccessKind.TOPLEVEL_METHOD:
236 return visitor.visitTopLevelFunctionInvoke( 183 return visitor.visitTopLevelFunctionInvoke(
237 node, 184 node, semantics.element, node.argumentsNode, callStructure, arg);
238 semantics.element,
239 node.argumentsNode,
240 callStructure,
241 arg);
242 case AccessKind.TOPLEVEL_GETTER: 185 case AccessKind.TOPLEVEL_GETTER:
243 return visitor.visitTopLevelGetterInvoke( 186 return visitor.visitTopLevelGetterInvoke(
244 node, 187 node, semantics.element, node.argumentsNode, callStructure, arg);
245 semantics.element,
246 node.argumentsNode,
247 callStructure,
248 arg);
249 case AccessKind.TOPLEVEL_SETTER: 188 case AccessKind.TOPLEVEL_SETTER:
250 return visitor.visitTopLevelSetterInvoke( 189 return visitor.visitTopLevelSetterInvoke(
251 node, 190 node, semantics.element, node.argumentsNode, callStructure, arg);
252 semantics.element,
253 node.argumentsNode,
254 callStructure,
255 arg);
256 case AccessKind.CLASS_TYPE_LITERAL: 191 case AccessKind.CLASS_TYPE_LITERAL:
257 return visitor.visitClassTypeLiteralInvoke( 192 return visitor.visitClassTypeLiteralInvoke(
258 node, 193 node, semantics.constant, node.argumentsNode, callStructure, arg);
259 semantics.constant,
260 node.argumentsNode,
261 callStructure,
262 arg);
263 case AccessKind.TYPEDEF_TYPE_LITERAL: 194 case AccessKind.TYPEDEF_TYPE_LITERAL:
264 return visitor.visitTypedefTypeLiteralInvoke( 195 return visitor.visitTypedefTypeLiteralInvoke(
265 node, 196 node, semantics.constant, node.argumentsNode, callStructure, arg);
266 semantics.constant,
267 node.argumentsNode,
268 callStructure,
269 arg);
270 case AccessKind.DYNAMIC_TYPE_LITERAL: 197 case AccessKind.DYNAMIC_TYPE_LITERAL:
271 return visitor.visitDynamicTypeLiteralInvoke( 198 return visitor.visitDynamicTypeLiteralInvoke(
272 node, 199 node, semantics.constant, node.argumentsNode, callStructure, arg);
273 semantics.constant,
274 node.argumentsNode,
275 callStructure,
276 arg);
277 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 200 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
278 return visitor.visitTypeVariableTypeLiteralInvoke( 201 return visitor.visitTypeVariableTypeLiteralInvoke(
279 node, 202 node, semantics.element, node.argumentsNode, callStructure, arg);
280 semantics.element,
281 node.argumentsNode,
282 callStructure,
283 arg);
284 case AccessKind.EXPRESSION: 203 case AccessKind.EXPRESSION:
285 return visitor.visitExpressionInvoke( 204 return visitor.visitExpressionInvoke(
286 node, 205 node, node.selector, node.argumentsNode, callStructure, arg);
287 node.selector,
288 node.argumentsNode,
289 callStructure,
290 arg);
291 case AccessKind.THIS: 206 case AccessKind.THIS:
292 return visitor.visitThisInvoke( 207 return visitor.visitThisInvoke(
293 node, 208 node, node.argumentsNode, callStructure, arg);
294 node.argumentsNode,
295 callStructure,
296 arg);
297 case AccessKind.THIS_PROPERTY: 209 case AccessKind.THIS_PROPERTY:
298 return visitor.visitThisPropertyInvoke( 210 return visitor.visitThisPropertyInvoke(
299 node, 211 node, node.argumentsNode, selector, arg);
300 node.argumentsNode,
301 selector,
302 arg);
303 case AccessKind.SUPER_FIELD: 212 case AccessKind.SUPER_FIELD:
304 case AccessKind.SUPER_FINAL_FIELD: 213 case AccessKind.SUPER_FINAL_FIELD:
305 return visitor.visitSuperFieldInvoke( 214 return visitor.visitSuperFieldInvoke(
306 node, 215 node, semantics.element, node.argumentsNode, callStructure, arg);
307 semantics.element,
308 node.argumentsNode,
309 callStructure,
310 arg);
311 case AccessKind.SUPER_METHOD: 216 case AccessKind.SUPER_METHOD:
312 return visitor.visitSuperMethodInvoke( 217 return visitor.visitSuperMethodInvoke(
313 node, 218 node, semantics.element, node.argumentsNode, callStructure, arg);
314 semantics.element,
315 node.argumentsNode,
316 callStructure,
317 arg);
318 case AccessKind.SUPER_GETTER: 219 case AccessKind.SUPER_GETTER:
319 return visitor.visitSuperGetterInvoke( 220 return visitor.visitSuperGetterInvoke(
320 node, 221 node, semantics.element, node.argumentsNode, callStructure, arg);
321 semantics.element,
322 node.argumentsNode,
323 callStructure,
324 arg);
325 case AccessKind.SUPER_SETTER: 222 case AccessKind.SUPER_SETTER:
326 return visitor.visitSuperSetterInvoke( 223 return visitor.visitSuperSetterInvoke(
327 node, 224 node, semantics.element, node.argumentsNode, callStructure, arg);
328 semantics.element,
329 node.argumentsNode,
330 callStructure,
331 arg);
332 case AccessKind.CONSTANT: 225 case AccessKind.CONSTANT:
333 return visitor.visitConstantInvoke( 226 return visitor.visitConstantInvoke(
334 node, 227 node, semantics.constant, node.argumentsNode, callStructure, arg);
335 semantics.constant,
336 node.argumentsNode,
337 callStructure,
338 arg);
339 case AccessKind.UNRESOLVED: 228 case AccessKind.UNRESOLVED:
340 return visitor.visitUnresolvedInvoke( 229 return visitor.visitUnresolvedInvoke(
341 node, 230 node, semantics.element, node.argumentsNode, selector, arg);
342 semantics.element,
343 node.argumentsNode,
344 selector,
345 arg);
346 case AccessKind.UNRESOLVED_SUPER: 231 case AccessKind.UNRESOLVED_SUPER:
347 return visitor.visitUnresolvedSuperInvoke( 232 return visitor.visitUnresolvedSuperInvoke(
348 node, 233 node, semantics.element, node.argumentsNode, selector, arg);
349 semantics.element,
350 node.argumentsNode,
351 selector,
352 arg);
353 case AccessKind.INVALID: 234 case AccessKind.INVALID:
354 return visitor.errorInvalidInvoke( 235 return visitor.errorInvalidInvoke(
355 node, 236 node, semantics.element, node.argumentsNode, selector, arg);
356 semantics.element,
357 node.argumentsNode,
358 selector,
359 arg);
360 case AccessKind.COMPOUND: 237 case AccessKind.COMPOUND:
361 // This is not a valid case. 238 // This is not a valid case.
362 break; 239 break;
363 } 240 }
364 throw new SpannableAssertionFailure(node, "Invalid invoke: ${semantics}"); 241 throw new SpannableAssertionFailure(node, "Invalid invoke: ${semantics}");
365 } 242 }
366 243
367 String toString() => 'invoke($selector, $semantics)'; 244 String toString() => 'invoke($selector, $semantics)';
368 } 245 }
369 246
(...skipping 10 matching lines...) Expand all
380 /// The [CallStructure] of the invocation. 257 /// The [CallStructure] of the invocation.
381 // TODO(johnniwinther): Store this directly for static invocations. 258 // TODO(johnniwinther): Store this directly for static invocations.
382 CallStructure get callStructure => selector.callStructure; 259 CallStructure get callStructure => selector.callStructure;
383 260
384 IncompatibleInvokeStructure(this.semantics, this.selector); 261 IncompatibleInvokeStructure(this.semantics, this.selector);
385 262
386 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 263 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
387 switch (semantics.kind) { 264 switch (semantics.kind) {
388 case AccessKind.STATIC_METHOD: 265 case AccessKind.STATIC_METHOD:
389 return visitor.visitStaticFunctionIncompatibleInvoke( 266 return visitor.visitStaticFunctionIncompatibleInvoke(
390 node, 267 node, semantics.element, node.argumentsNode, callStructure, arg);
391 semantics.element,
392 node.argumentsNode,
393 callStructure,
394 arg);
395 case AccessKind.SUPER_METHOD: 268 case AccessKind.SUPER_METHOD:
396 return visitor.visitSuperMethodIncompatibleInvoke( 269 return visitor.visitSuperMethodIncompatibleInvoke(
397 node, 270 node, semantics.element, node.argumentsNode, callStructure, arg);
398 semantics.element,
399 node.argumentsNode,
400 callStructure,
401 arg);
402 case AccessKind.TOPLEVEL_METHOD: 271 case AccessKind.TOPLEVEL_METHOD:
403 return visitor.visitTopLevelFunctionIncompatibleInvoke( 272 return visitor.visitTopLevelFunctionIncompatibleInvoke(
404 node, 273 node, semantics.element, node.argumentsNode, callStructure, arg);
405 semantics.element,
406 node.argumentsNode,
407 callStructure,
408 arg);
409 case AccessKind.LOCAL_FUNCTION: 274 case AccessKind.LOCAL_FUNCTION:
410 return visitor.visitLocalFunctionIncompatibleInvoke( 275 return visitor.visitLocalFunctionIncompatibleInvoke(
411 node, 276 node, semantics.element, node.argumentsNode, callStructure, arg);
412 semantics.element, 277 default:
413 node.argumentsNode,
414 callStructure,
415 arg);
416 default:
417 // TODO(johnniwinther): Support more variants of this invoke structure. 278 // TODO(johnniwinther): Support more variants of this invoke structure.
418 break; 279 break;
419 } 280 }
420 throw new SpannableAssertionFailure( 281 throw new SpannableAssertionFailure(
421 node, "Invalid incompatible invoke: ${semantics}"); 282 node, "Invalid incompatible invoke: ${semantics}");
422 } 283 }
423 284
424 String toString() => 'incompatible-invoke($selector, $semantics)'; 285 String toString() => 'incompatible-invoke($selector, $semantics)';
425 } 286 }
426 287
427 /// The structure for a [Send] that is a read access. 288 /// The structure for a [Send] that is a read access.
428 class GetStructure<R, A> implements SendStructure<R, A> { 289 class GetStructure<R, A> implements SendStructure<R, A> {
429 /// The target of the read access. 290 /// The target of the read access.
430 final AccessSemantics semantics; 291 final AccessSemantics semantics;
431 292
432 GetStructure(this.semantics); 293 GetStructure(this.semantics);
433 294
434 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 295 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
435 switch (semantics.kind) { 296 switch (semantics.kind) {
436 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 297 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
437 return visitor.visitIfNotNullDynamicPropertyGet( 298 return visitor.visitIfNotNullDynamicPropertyGet(
438 node, 299 node, node.receiver, semantics.name, arg);
439 node.receiver,
440 semantics.name,
441 arg);
442 case AccessKind.DYNAMIC_PROPERTY: 300 case AccessKind.DYNAMIC_PROPERTY:
443 return visitor.visitDynamicPropertyGet( 301 return visitor.visitDynamicPropertyGet(
444 node, 302 node, node.receiver, semantics.name, arg);
445 node.receiver,
446 semantics.name,
447 arg);
448 case AccessKind.LOCAL_FUNCTION: 303 case AccessKind.LOCAL_FUNCTION:
449 return visitor.visitLocalFunctionGet( 304 return visitor.visitLocalFunctionGet(node, semantics.element, arg);
450 node,
451 semantics.element,
452 arg);
453 case AccessKind.LOCAL_VARIABLE: 305 case AccessKind.LOCAL_VARIABLE:
454 case AccessKind.FINAL_LOCAL_VARIABLE: 306 case AccessKind.FINAL_LOCAL_VARIABLE:
455 return visitor.visitLocalVariableGet( 307 return visitor.visitLocalVariableGet(node, semantics.element, arg);
456 node,
457 semantics.element,
458 arg);
459 case AccessKind.PARAMETER: 308 case AccessKind.PARAMETER:
460 case AccessKind.FINAL_PARAMETER: 309 case AccessKind.FINAL_PARAMETER:
461 return visitor.visitParameterGet( 310 return visitor.visitParameterGet(node, semantics.element, arg);
462 node,
463 semantics.element,
464 arg);
465 case AccessKind.STATIC_FIELD: 311 case AccessKind.STATIC_FIELD:
466 case AccessKind.FINAL_STATIC_FIELD: 312 case AccessKind.FINAL_STATIC_FIELD:
467 return visitor.visitStaticFieldGet( 313 return visitor.visitStaticFieldGet(node, semantics.element, arg);
468 node,
469 semantics.element,
470 arg);
471 case AccessKind.STATIC_METHOD: 314 case AccessKind.STATIC_METHOD:
472 return visitor.visitStaticFunctionGet( 315 return visitor.visitStaticFunctionGet(node, semantics.element, arg);
473 node,
474 semantics.element,
475 arg);
476 case AccessKind.STATIC_GETTER: 316 case AccessKind.STATIC_GETTER:
477 return visitor.visitStaticGetterGet( 317 return visitor.visitStaticGetterGet(node, semantics.element, arg);
478 node,
479 semantics.element,
480 arg);
481 case AccessKind.STATIC_SETTER: 318 case AccessKind.STATIC_SETTER:
482 return visitor.visitStaticSetterGet( 319 return visitor.visitStaticSetterGet(node, semantics.element, arg);
483 node,
484 semantics.element,
485 arg);
486 case AccessKind.TOPLEVEL_FIELD: 320 case AccessKind.TOPLEVEL_FIELD:
487 case AccessKind.FINAL_TOPLEVEL_FIELD: 321 case AccessKind.FINAL_TOPLEVEL_FIELD:
488 return visitor.visitTopLevelFieldGet( 322 return visitor.visitTopLevelFieldGet(node, semantics.element, arg);
489 node,
490 semantics.element,
491 arg);
492 case AccessKind.TOPLEVEL_METHOD: 323 case AccessKind.TOPLEVEL_METHOD:
493 return visitor.visitTopLevelFunctionGet( 324 return visitor.visitTopLevelFunctionGet(node, semantics.element, arg);
494 node,
495 semantics.element,
496 arg);
497 case AccessKind.TOPLEVEL_GETTER: 325 case AccessKind.TOPLEVEL_GETTER:
498 return visitor.visitTopLevelGetterGet( 326 return visitor.visitTopLevelGetterGet(node, semantics.element, arg);
499 node,
500 semantics.element,
501 arg);
502 case AccessKind.TOPLEVEL_SETTER: 327 case AccessKind.TOPLEVEL_SETTER:
503 return visitor.visitTopLevelSetterGet( 328 return visitor.visitTopLevelSetterGet(node, semantics.element, arg);
504 node,
505 semantics.element,
506 arg);
507 case AccessKind.CLASS_TYPE_LITERAL: 329 case AccessKind.CLASS_TYPE_LITERAL:
508 return visitor.visitClassTypeLiteralGet( 330 return visitor.visitClassTypeLiteralGet(node, semantics.constant, arg);
509 node,
510 semantics.constant,
511 arg);
512 case AccessKind.TYPEDEF_TYPE_LITERAL: 331 case AccessKind.TYPEDEF_TYPE_LITERAL:
513 return visitor.visitTypedefTypeLiteralGet( 332 return visitor.visitTypedefTypeLiteralGet(
514 node, 333 node, semantics.constant, arg);
515 semantics.constant,
516 arg);
517 case AccessKind.DYNAMIC_TYPE_LITERAL: 334 case AccessKind.DYNAMIC_TYPE_LITERAL:
518 return visitor.visitDynamicTypeLiteralGet( 335 return visitor.visitDynamicTypeLiteralGet(
519 node, 336 node, semantics.constant, arg);
520 semantics.constant,
521 arg);
522 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 337 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
523 return visitor.visitTypeVariableTypeLiteralGet( 338 return visitor.visitTypeVariableTypeLiteralGet(
524 node, 339 node, semantics.element, arg);
525 semantics.element,
526 arg);
527 case AccessKind.EXPRESSION: 340 case AccessKind.EXPRESSION:
528 // This is not a valid case. 341 // This is not a valid case.
529 break; 342 break;
530 case AccessKind.THIS: 343 case AccessKind.THIS:
531 // TODO(johnniwinther): Handle this when `this` is a [Send]. 344 // TODO(johnniwinther): Handle this when `this` is a [Send].
532 break; 345 break;
533 case AccessKind.THIS_PROPERTY: 346 case AccessKind.THIS_PROPERTY:
534 return visitor.visitThisPropertyGet( 347 return visitor.visitThisPropertyGet(node, semantics.name, arg);
535 node,
536 semantics.name,
537 arg);
538 case AccessKind.SUPER_FIELD: 348 case AccessKind.SUPER_FIELD:
539 case AccessKind.SUPER_FINAL_FIELD: 349 case AccessKind.SUPER_FINAL_FIELD:
540 return visitor.visitSuperFieldGet( 350 return visitor.visitSuperFieldGet(node, semantics.element, arg);
541 node,
542 semantics.element,
543 arg);
544 case AccessKind.SUPER_METHOD: 351 case AccessKind.SUPER_METHOD:
545 return visitor.visitSuperMethodGet( 352 return visitor.visitSuperMethodGet(node, semantics.element, arg);
546 node,
547 semantics.element,
548 arg);
549 case AccessKind.SUPER_GETTER: 353 case AccessKind.SUPER_GETTER:
550 return visitor.visitSuperGetterGet( 354 return visitor.visitSuperGetterGet(node, semantics.element, arg);
551 node,
552 semantics.element,
553 arg);
554 case AccessKind.SUPER_SETTER: 355 case AccessKind.SUPER_SETTER:
555 return visitor.visitSuperSetterGet( 356 return visitor.visitSuperSetterGet(node, semantics.element, arg);
556 node,
557 semantics.element,
558 arg);
559 case AccessKind.CONSTANT: 357 case AccessKind.CONSTANT:
560 return visitor.visitConstantGet( 358 return visitor.visitConstantGet(node, semantics.constant, arg);
561 node,
562 semantics.constant,
563 arg);
564 case AccessKind.UNRESOLVED: 359 case AccessKind.UNRESOLVED:
565 return visitor.visitUnresolvedGet( 360 return visitor.visitUnresolvedGet(node, semantics.element, arg);
566 node,
567 semantics.element,
568 arg);
569 case AccessKind.UNRESOLVED_SUPER: 361 case AccessKind.UNRESOLVED_SUPER:
570 return visitor.visitUnresolvedSuperGet( 362 return visitor.visitUnresolvedSuperGet(node, semantics.element, arg);
571 node,
572 semantics.element,
573 arg);
574 case AccessKind.INVALID: 363 case AccessKind.INVALID:
575 return visitor.errorInvalidGet( 364 return visitor.errorInvalidGet(node, semantics.element, arg);
576 node,
577 semantics.element,
578 arg);
579 case AccessKind.COMPOUND: 365 case AccessKind.COMPOUND:
580 // This is not a valid case. 366 // This is not a valid case.
581 break; 367 break;
582 } 368 }
583 throw new SpannableAssertionFailure(node, "Invalid getter: ${semantics}"); 369 throw new SpannableAssertionFailure(node, "Invalid getter: ${semantics}");
584 } 370 }
585 371
586 String toString() => 'get($semantics)'; 372 String toString() => 'get($semantics)';
587 } 373 }
588 374
589 /// The structure for a [Send] that is an assignment. 375 /// The structure for a [Send] that is an assignment.
590 class SetStructure<R, A> implements SendStructure<R, A> { 376 class SetStructure<R, A> implements SendStructure<R, A> {
591 /// The target of the assignment. 377 /// The target of the assignment.
592 final AccessSemantics semantics; 378 final AccessSemantics semantics;
593 379
594 SetStructure(this.semantics); 380 SetStructure(this.semantics);
595 381
596 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 382 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
597 switch (semantics.kind) { 383 switch (semantics.kind) {
598 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 384 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
599 return visitor.visitIfNotNullDynamicPropertySet( 385 return visitor.visitIfNotNullDynamicPropertySet(
600 node, 386 node, node.receiver, semantics.name, node.arguments.single, arg);
601 node.receiver,
602 semantics.name,
603 node.arguments.single,
604 arg);
605 case AccessKind.DYNAMIC_PROPERTY: 387 case AccessKind.DYNAMIC_PROPERTY:
606 return visitor.visitDynamicPropertySet( 388 return visitor.visitDynamicPropertySet(
607 node, 389 node, node.receiver, semantics.name, node.arguments.single, arg);
608 node.receiver,
609 semantics.name,
610 node.arguments.single,
611 arg);
612 case AccessKind.LOCAL_FUNCTION: 390 case AccessKind.LOCAL_FUNCTION:
613 return visitor.visitLocalFunctionSet( 391 return visitor.visitLocalFunctionSet(
614 node, 392 node, semantics.element, node.arguments.single, arg);
615 semantics.element,
616 node.arguments.single,
617 arg);
618 case AccessKind.LOCAL_VARIABLE: 393 case AccessKind.LOCAL_VARIABLE:
619 return visitor.visitLocalVariableSet( 394 return visitor.visitLocalVariableSet(
620 node, 395 node, semantics.element, node.arguments.single, arg);
621 semantics.element,
622 node.arguments.single,
623 arg);
624 case AccessKind.FINAL_LOCAL_VARIABLE: 396 case AccessKind.FINAL_LOCAL_VARIABLE:
625 return visitor.visitFinalLocalVariableSet( 397 return visitor.visitFinalLocalVariableSet(
626 node, 398 node, semantics.element, node.arguments.single, arg);
627 semantics.element,
628 node.arguments.single,
629 arg);
630 case AccessKind.PARAMETER: 399 case AccessKind.PARAMETER:
631 return visitor.visitParameterSet( 400 return visitor.visitParameterSet(
632 node, 401 node, semantics.element, node.arguments.single, arg);
633 semantics.element,
634 node.arguments.single,
635 arg);
636 case AccessKind.FINAL_PARAMETER: 402 case AccessKind.FINAL_PARAMETER:
637 return visitor.visitFinalParameterSet( 403 return visitor.visitFinalParameterSet(
638 node, 404 node, semantics.element, node.arguments.single, arg);
639 semantics.element,
640 node.arguments.single,
641 arg);
642 case AccessKind.STATIC_FIELD: 405 case AccessKind.STATIC_FIELD:
643 return visitor.visitStaticFieldSet( 406 return visitor.visitStaticFieldSet(
644 node, 407 node, semantics.element, node.arguments.single, arg);
645 semantics.element,
646 node.arguments.single,
647 arg);
648 case AccessKind.FINAL_STATIC_FIELD: 408 case AccessKind.FINAL_STATIC_FIELD:
649 return visitor.visitFinalStaticFieldSet( 409 return visitor.visitFinalStaticFieldSet(
650 node, 410 node, semantics.element, node.arguments.single, arg);
651 semantics.element,
652 node.arguments.single,
653 arg);
654 case AccessKind.STATIC_METHOD: 411 case AccessKind.STATIC_METHOD:
655 return visitor.visitStaticFunctionSet( 412 return visitor.visitStaticFunctionSet(
656 node, 413 node, semantics.element, node.arguments.single, arg);
657 semantics.element,
658 node.arguments.single,
659 arg);
660 case AccessKind.STATIC_GETTER: 414 case AccessKind.STATIC_GETTER:
661 return visitor.visitStaticGetterSet( 415 return visitor.visitStaticGetterSet(
662 node, 416 node, semantics.element, node.arguments.single, arg);
663 semantics.element,
664 node.arguments.single,
665 arg);
666 case AccessKind.STATIC_SETTER: 417 case AccessKind.STATIC_SETTER:
667 return visitor.visitStaticSetterSet( 418 return visitor.visitStaticSetterSet(
668 node, 419 node, semantics.element, node.arguments.single, arg);
669 semantics.element,
670 node.arguments.single,
671 arg);
672 case AccessKind.TOPLEVEL_FIELD: 420 case AccessKind.TOPLEVEL_FIELD:
673 return visitor.visitTopLevelFieldSet( 421 return visitor.visitTopLevelFieldSet(
674 node, 422 node, semantics.element, node.arguments.single, arg);
675 semantics.element,
676 node.arguments.single,
677 arg);
678 case AccessKind.FINAL_TOPLEVEL_FIELD: 423 case AccessKind.FINAL_TOPLEVEL_FIELD:
679 return visitor.visitFinalTopLevelFieldSet( 424 return visitor.visitFinalTopLevelFieldSet(
680 node, 425 node, semantics.element, node.arguments.single, arg);
681 semantics.element,
682 node.arguments.single,
683 arg);
684 case AccessKind.TOPLEVEL_METHOD: 426 case AccessKind.TOPLEVEL_METHOD:
685 return visitor.visitTopLevelFunctionSet( 427 return visitor.visitTopLevelFunctionSet(
686 node, 428 node, semantics.element, node.arguments.single, arg);
687 semantics.element,
688 node.arguments.single,
689 arg);
690 case AccessKind.TOPLEVEL_GETTER: 429 case AccessKind.TOPLEVEL_GETTER:
691 return visitor.visitTopLevelGetterSet( 430 return visitor.visitTopLevelGetterSet(
692 node, 431 node, semantics.element, node.arguments.single, arg);
693 semantics.element,
694 node.arguments.single,
695 arg);
696 case AccessKind.TOPLEVEL_SETTER: 432 case AccessKind.TOPLEVEL_SETTER:
697 return visitor.visitTopLevelSetterSet( 433 return visitor.visitTopLevelSetterSet(
698 node, 434 node, semantics.element, node.arguments.single, arg);
699 semantics.element,
700 node.arguments.single,
701 arg);
702 case AccessKind.CLASS_TYPE_LITERAL: 435 case AccessKind.CLASS_TYPE_LITERAL:
703 return visitor.visitClassTypeLiteralSet( 436 return visitor.visitClassTypeLiteralSet(
704 node, 437 node, semantics.constant, node.arguments.single, arg);
705 semantics.constant,
706 node.arguments.single,
707 arg);
708 case AccessKind.TYPEDEF_TYPE_LITERAL: 438 case AccessKind.TYPEDEF_TYPE_LITERAL:
709 return visitor.visitTypedefTypeLiteralSet( 439 return visitor.visitTypedefTypeLiteralSet(
710 node, 440 node, semantics.constant, node.arguments.single, arg);
711 semantics.constant,
712 node.arguments.single,
713 arg);
714 case AccessKind.DYNAMIC_TYPE_LITERAL: 441 case AccessKind.DYNAMIC_TYPE_LITERAL:
715 return visitor.visitDynamicTypeLiteralSet( 442 return visitor.visitDynamicTypeLiteralSet(
716 node, 443 node, semantics.constant, node.arguments.single, arg);
717 semantics.constant,
718 node.arguments.single,
719 arg);
720 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 444 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
721 return visitor.visitTypeVariableTypeLiteralSet( 445 return visitor.visitTypeVariableTypeLiteralSet(
722 node, 446 node, semantics.element, node.arguments.single, arg);
723 semantics.element,
724 node.arguments.single,
725 arg);
726 case AccessKind.EXPRESSION: 447 case AccessKind.EXPRESSION:
727 // This is not a valid case. 448 // This is not a valid case.
728 break; 449 break;
729 case AccessKind.THIS: 450 case AccessKind.THIS:
730 // This is not a valid case. 451 // This is not a valid case.
731 break; 452 break;
732 case AccessKind.THIS_PROPERTY: 453 case AccessKind.THIS_PROPERTY:
733 return visitor.visitThisPropertySet( 454 return visitor.visitThisPropertySet(
734 node, 455 node, semantics.name, node.arguments.single, arg);
735 semantics.name,
736 node.arguments.single,
737 arg);
738 case AccessKind.SUPER_FIELD: 456 case AccessKind.SUPER_FIELD:
739 return visitor.visitSuperFieldSet( 457 return visitor.visitSuperFieldSet(
740 node, 458 node, semantics.element, node.arguments.single, arg);
741 semantics.element,
742 node.arguments.single,
743 arg);
744 case AccessKind.SUPER_FINAL_FIELD: 459 case AccessKind.SUPER_FINAL_FIELD:
745 return visitor.visitFinalSuperFieldSet( 460 return visitor.visitFinalSuperFieldSet(
746 node, 461 node, semantics.element, node.arguments.single, arg);
747 semantics.element,
748 node.arguments.single,
749 arg);
750 case AccessKind.SUPER_METHOD: 462 case AccessKind.SUPER_METHOD:
751 return visitor.visitSuperMethodSet( 463 return visitor.visitSuperMethodSet(
752 node, 464 node, semantics.element, node.arguments.single, arg);
753 semantics.element,
754 node.arguments.single,
755 arg);
756 case AccessKind.SUPER_GETTER: 465 case AccessKind.SUPER_GETTER:
757 return visitor.visitSuperGetterSet( 466 return visitor.visitSuperGetterSet(
758 node, 467 node, semantics.element, node.arguments.single, arg);
759 semantics.element,
760 node.arguments.single,
761 arg);
762 case AccessKind.SUPER_SETTER: 468 case AccessKind.SUPER_SETTER:
763 return visitor.visitSuperSetterSet( 469 return visitor.visitSuperSetterSet(
764 node, 470 node, semantics.element, node.arguments.single, arg);
765 semantics.element,
766 node.arguments.single,
767 arg);
768 case AccessKind.CONSTANT: 471 case AccessKind.CONSTANT:
769 // TODO(johnniwinther): Should this be a valid case? 472 // TODO(johnniwinther): Should this be a valid case?
770 break; 473 break;
771 case AccessKind.UNRESOLVED_SUPER: 474 case AccessKind.UNRESOLVED_SUPER:
772 return visitor.visitUnresolvedSuperSet( 475 return visitor.visitUnresolvedSuperSet(
773 node, 476 node, semantics.element, node.arguments.single, arg);
774 semantics.element,
775 node.arguments.single,
776 arg);
777 case AccessKind.UNRESOLVED: 477 case AccessKind.UNRESOLVED:
778 return visitor.visitUnresolvedSet( 478 return visitor.visitUnresolvedSet(
779 node, 479 node, semantics.element, node.arguments.single, arg);
780 semantics.element,
781 node.arguments.single,
782 arg);
783 case AccessKind.INVALID: 480 case AccessKind.INVALID:
784 return visitor.errorInvalidSet( 481 return visitor.errorInvalidSet(
785 node, 482 node, semantics.element, node.arguments.single, arg);
786 semantics.element,
787 node.arguments.single,
788 arg);
789 case AccessKind.COMPOUND: 483 case AccessKind.COMPOUND:
790 // This is not a valid case. 484 // This is not a valid case.
791 break; 485 break;
792 } 486 }
793 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}"); 487 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}");
794 } 488 }
795 489
796 String toString() => 'set($semantics)'; 490 String toString() => 'set($semantics)';
797 } 491 }
798 492
799 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. 493 /// The structure for a [Send] that is a negation, i.e. of the form `!e`.
800 class NotStructure<R, A> implements SendStructure<R, A> { 494 class NotStructure<R, A> implements SendStructure<R, A> {
801 const NotStructure(); 495 const NotStructure();
802 496
803 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 497 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
804 return visitor.visitNot( 498 return visitor.visitNot(node, node.receiver, arg);
805 node,
806 node.receiver,
807 arg);
808 } 499 }
809 500
810 String toString() => 'not()'; 501 String toString() => 'not()';
811 } 502 }
812 503
813 /// The structure for a [Send] that is an invocation of a user definable unary 504 /// The structure for a [Send] that is an invocation of a user definable unary
814 /// operator. 505 /// operator.
815 class UnaryStructure<R, A> implements SendStructure<R, A> { 506 class UnaryStructure<R, A> implements SendStructure<R, A> {
816 /// The target of the unary operation. 507 /// The target of the unary operation.
817 final AccessSemantics semantics; 508 final AccessSemantics semantics;
818 509
819 /// The user definable unary operator. 510 /// The user definable unary operator.
820 final UnaryOperator operator; 511 final UnaryOperator operator;
821 512
822 UnaryStructure(this.semantics, this.operator); 513 UnaryStructure(this.semantics, this.operator);
823 514
824 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 515 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
825 switch (semantics.kind) { 516 switch (semantics.kind) {
826 case AccessKind.EXPRESSION: 517 case AccessKind.EXPRESSION:
827 return visitor.visitUnary( 518 return visitor.visitUnary(node, operator, node.receiver, arg);
828 node,
829 operator,
830 node.receiver,
831 arg);
832 case AccessKind.SUPER_METHOD: 519 case AccessKind.SUPER_METHOD:
833 return visitor.visitSuperUnary( 520 return visitor.visitSuperUnary(node, operator, semantics.element, arg);
834 node,
835 operator,
836 semantics.element,
837 arg);
838 case AccessKind.UNRESOLVED_SUPER: 521 case AccessKind.UNRESOLVED_SUPER:
839 return visitor.visitUnresolvedSuperUnary( 522 return visitor.visitUnresolvedSuperUnary(
840 node, 523 node, operator, semantics.element, arg);
841 operator,
842 semantics.element,
843 arg);
844 case AccessKind.INVALID: 524 case AccessKind.INVALID:
845 return visitor.errorInvalidUnary( 525 return visitor.errorInvalidUnary(
846 node, 526 node, operator, semantics.element, arg);
847 operator,
848 semantics.element,
849 arg);
850 default: 527 default:
851 // This is not a valid case. 528 // This is not a valid case.
852 break; 529 break;
853 } 530 }
854 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}"); 531 throw new SpannableAssertionFailure(node, "Invalid setter: ${semantics}");
855 } 532 }
856 533
857 String toString() => 'unary($operator,$semantics)'; 534 String toString() => 'unary($operator,$semantics)';
858 } 535 }
859 536
860 /// The structure for a [Send] that is an invocation of a undefined unary 537 /// The structure for a [Send] that is an invocation of a undefined unary
861 /// operator. 538 /// operator.
862 class InvalidUnaryStructure<R, A> implements SendStructure<R, A> { 539 class InvalidUnaryStructure<R, A> implements SendStructure<R, A> {
863 const InvalidUnaryStructure(); 540 const InvalidUnaryStructure();
864 541
865 @override 542 @override
866 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 543 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
867 return visitor.errorUndefinedUnaryExpression( 544 return visitor.errorUndefinedUnaryExpression(
868 node, 545 node, node.selector, node.receiver, arg);
869 node.selector,
870 node.receiver,
871 arg);
872 } 546 }
873 547
874 String toString() => 'invalid unary'; 548 String toString() => 'invalid unary';
875 } 549 }
876 550
877 /// The structure for a [Send] that is an index expression, i.e. of the form 551 /// The structure for a [Send] that is an index expression, i.e. of the form
878 /// `a[b]`. 552 /// `a[b]`.
879 class IndexStructure<R, A> implements SendStructure<R, A> { 553 class IndexStructure<R, A> implements SendStructure<R, A> {
880 /// The target of the left operand. 554 /// The target of the left operand.
881 final AccessSemantics semantics; 555 final AccessSemantics semantics;
882 556
883 IndexStructure(this.semantics); 557 IndexStructure(this.semantics);
884 558
885 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 559 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
886 switch (semantics.kind) { 560 switch (semantics.kind) {
887 case AccessKind.EXPRESSION: 561 case AccessKind.EXPRESSION:
888 return visitor.visitIndex( 562 return visitor.visitIndex(
889 node, 563 node, node.receiver, node.arguments.single, arg);
890 node.receiver,
891 node.arguments.single,
892 arg);
893 case AccessKind.SUPER_METHOD: 564 case AccessKind.SUPER_METHOD:
894 return visitor.visitSuperIndex( 565 return visitor.visitSuperIndex(
895 node, 566 node, semantics.element, node.arguments.single, arg);
896 semantics.element,
897 node.arguments.single,
898 arg);
899 case AccessKind.UNRESOLVED_SUPER: 567 case AccessKind.UNRESOLVED_SUPER:
900 return visitor.visitUnresolvedSuperIndex( 568 return visitor.visitUnresolvedSuperIndex(
901 node, 569 node, semantics.element, node.arguments.single, arg);
902 semantics.element,
903 node.arguments.single,
904 arg);
905 case AccessKind.INVALID: 570 case AccessKind.INVALID:
906 return visitor.errorInvalidIndex( 571 return visitor.errorInvalidIndex(
907 node, 572 node, semantics.element, node.arguments.single, arg);
908 semantics.element,
909 node.arguments.single,
910 arg);
911 default: 573 default:
912 // This is not a valid case. 574 // This is not a valid case.
913 break; 575 break;
914 } 576 }
915 throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}"); 577 throw new SpannableAssertionFailure(node, "Invalid index: ${semantics}");
916 } 578 }
917 } 579 }
918 580
919 /// The structure for a [Send] that is an equals test, i.e. of the form 581 /// The structure for a [Send] that is an equals test, i.e. of the form
920 /// `a == b`. 582 /// `a == b`.
921 class EqualsStructure<R, A> implements SendStructure<R, A> { 583 class EqualsStructure<R, A> implements SendStructure<R, A> {
922 /// The target of the left operand. 584 /// The target of the left operand.
923 final AccessSemantics semantics; 585 final AccessSemantics semantics;
924 586
925 EqualsStructure(this.semantics); 587 EqualsStructure(this.semantics);
926 588
927 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 589 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
928 switch (semantics.kind) { 590 switch (semantics.kind) {
929 case AccessKind.EXPRESSION: 591 case AccessKind.EXPRESSION:
930 return visitor.visitEquals( 592 return visitor.visitEquals(
931 node, 593 node, node.receiver, node.arguments.single, arg);
932 node.receiver,
933 node.arguments.single,
934 arg);
935 case AccessKind.SUPER_METHOD: 594 case AccessKind.SUPER_METHOD:
936 return visitor.visitSuperEquals( 595 return visitor.visitSuperEquals(
937 node, 596 node, semantics.element, node.arguments.single, arg);
938 semantics.element,
939 node.arguments.single,
940 arg);
941 case AccessKind.INVALID: 597 case AccessKind.INVALID:
942 return visitor.errorInvalidEquals( 598 return visitor.errorInvalidEquals(
943 node, 599 node, semantics.element, node.arguments.single, arg);
944 semantics.element,
945 node.arguments.single,
946 arg);
947 default: 600 default:
948 // This is not a valid case. 601 // This is not a valid case.
949 break; 602 break;
950 } 603 }
951 throw new SpannableAssertionFailure(node, "Invalid equals: ${semantics}"); 604 throw new SpannableAssertionFailure(node, "Invalid equals: ${semantics}");
952 } 605 }
953 606
954 String toString() => '==($semantics)'; 607 String toString() => '==($semantics)';
955 } 608 }
956 609
957 /// The structure for a [Send] that is a not-equals test, i.e. of the form 610 /// The structure for a [Send] that is a not-equals test, i.e. of the form
958 /// `a != b`. 611 /// `a != b`.
959 class NotEqualsStructure<R, A> implements SendStructure<R, A> { 612 class NotEqualsStructure<R, A> implements SendStructure<R, A> {
960 /// The target of the left operand. 613 /// The target of the left operand.
961 final AccessSemantics semantics; 614 final AccessSemantics semantics;
962 615
963 NotEqualsStructure(this.semantics); 616 NotEqualsStructure(this.semantics);
964 617
965 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 618 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
966 switch (semantics.kind) { 619 switch (semantics.kind) {
967 case AccessKind.EXPRESSION: 620 case AccessKind.EXPRESSION:
968 return visitor.visitNotEquals( 621 return visitor.visitNotEquals(
969 node, 622 node, node.receiver, node.arguments.single, arg);
970 node.receiver,
971 node.arguments.single,
972 arg);
973 case AccessKind.SUPER_METHOD: 623 case AccessKind.SUPER_METHOD:
974 return visitor.visitSuperNotEquals( 624 return visitor.visitSuperNotEquals(
975 node, 625 node, semantics.element, node.arguments.single, arg);
976 semantics.element,
977 node.arguments.single,
978 arg);
979 case AccessKind.INVALID: 626 case AccessKind.INVALID:
980 return visitor.errorInvalidNotEquals( 627 return visitor.errorInvalidNotEquals(
981 node, 628 node, semantics.element, node.arguments.single, arg);
982 semantics.element,
983 node.arguments.single,
984 arg);
985 default: 629 default:
986 // This is not a valid case. 630 // This is not a valid case.
987 break; 631 break;
988 } 632 }
989 throw new SpannableAssertionFailure( 633 throw new SpannableAssertionFailure(
990 node, "Invalid not equals: ${semantics}"); 634 node, "Invalid not equals: ${semantics}");
991 } 635 }
992 636
993 String toString() => '!=($semantics)'; 637 String toString() => '!=($semantics)';
994 } 638 }
995 639
996 /// The structure for a [Send] that is an invocation of a user-definable binary 640 /// The structure for a [Send] that is an invocation of a user-definable binary
997 /// operator. 641 /// operator.
998 class BinaryStructure<R, A> implements SendStructure<R, A> { 642 class BinaryStructure<R, A> implements SendStructure<R, A> {
999 /// The target of the left operand. 643 /// The target of the left operand.
1000 final AccessSemantics semantics; 644 final AccessSemantics semantics;
1001 645
1002 /// The user definable binary operator. 646 /// The user definable binary operator.
1003 final BinaryOperator operator; 647 final BinaryOperator operator;
1004 648
1005 BinaryStructure(this.semantics, this.operator); 649 BinaryStructure(this.semantics, this.operator);
1006 650
1007 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 651 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1008 switch (semantics.kind) { 652 switch (semantics.kind) {
1009 case AccessKind.EXPRESSION: 653 case AccessKind.EXPRESSION:
1010 return visitor.visitBinary( 654 return visitor.visitBinary(
1011 node, 655 node, node.receiver, operator, node.arguments.single, arg);
1012 node.receiver,
1013 operator,
1014 node.arguments.single,
1015 arg);
1016 case AccessKind.SUPER_METHOD: 656 case AccessKind.SUPER_METHOD:
1017 return visitor.visitSuperBinary( 657 return visitor.visitSuperBinary(
1018 node, 658 node, semantics.element, operator, node.arguments.single, arg);
1019 semantics.element,
1020 operator,
1021 node.arguments.single,
1022 arg);
1023 case AccessKind.UNRESOLVED_SUPER: 659 case AccessKind.UNRESOLVED_SUPER:
1024 return visitor.visitUnresolvedSuperBinary( 660 return visitor.visitUnresolvedSuperBinary(
1025 node, 661 node, semantics.element, operator, node.arguments.single, arg);
1026 semantics.element,
1027 operator,
1028 node.arguments.single,
1029 arg);
1030 case AccessKind.INVALID: 662 case AccessKind.INVALID:
1031 return visitor.errorInvalidBinary( 663 return visitor.errorInvalidBinary(
1032 node, 664 node, semantics.element, operator, node.arguments.single, arg);
1033 semantics.element,
1034 operator,
1035 node.arguments.single,
1036 arg);
1037 default: 665 default:
1038 // This is not a valid case. 666 // This is not a valid case.
1039 break; 667 break;
1040 } 668 }
1041 throw new SpannableAssertionFailure( 669 throw new SpannableAssertionFailure(node, "Invalid binary: ${semantics}");
1042 node, "Invalid binary: ${semantics}");
1043 } 670 }
1044 671
1045 String toString() => 'binary($operator,$semantics)'; 672 String toString() => 'binary($operator,$semantics)';
1046 } 673 }
1047 674
1048 /// The structure for a [Send] that is an invocation of a undefined binary 675 /// The structure for a [Send] that is an invocation of a undefined binary
1049 /// operator. 676 /// operator.
1050 class InvalidBinaryStructure<R, A> implements SendStructure<R, A> { 677 class InvalidBinaryStructure<R, A> implements SendStructure<R, A> {
1051 const InvalidBinaryStructure(); 678 const InvalidBinaryStructure();
1052 679
1053 @override 680 @override
1054 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 681 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1055 return visitor.errorUndefinedBinaryExpression( 682 return visitor.errorUndefinedBinaryExpression(
1056 node, 683 node, node.receiver, node.selector, node.arguments.single, arg);
1057 node.receiver,
1058 node.selector,
1059 node.arguments.single,
1060 arg);
1061 } 684 }
1062 685
1063 String toString() => 'invalid binary'; 686 String toString() => 'invalid binary';
1064 } 687 }
1065 688
1066 /// The structure for a [Send] that is of the form `a[b] = c`. 689 /// The structure for a [Send] that is of the form `a[b] = c`.
1067 class IndexSetStructure<R, A> implements SendStructure<R, A> { 690 class IndexSetStructure<R, A> implements SendStructure<R, A> {
1068 /// The target of the index set operation. 691 /// The target of the index set operation.
1069 final AccessSemantics semantics; 692 final AccessSemantics semantics;
1070 693
1071 IndexSetStructure(this.semantics); 694 IndexSetStructure(this.semantics);
1072 695
1073 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 696 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1074 switch (semantics.kind) { 697 switch (semantics.kind) {
1075 case AccessKind.EXPRESSION: 698 case AccessKind.EXPRESSION:
1076 return visitor.visitIndexSet( 699 return visitor.visitIndexSet(node, node.receiver, node.arguments.first,
1077 node, 700 node.arguments.tail.head, arg);
1078 node.receiver,
1079 node.arguments.first,
1080 node.arguments.tail.head,
1081 arg);
1082 case AccessKind.SUPER_METHOD: 701 case AccessKind.SUPER_METHOD:
1083 return visitor.visitSuperIndexSet( 702 return visitor.visitSuperIndexSet(node, semantics.element,
1084 node, 703 node.arguments.first, node.arguments.tail.head, arg);
1085 semantics.element,
1086 node.arguments.first,
1087 node.arguments.tail.head,
1088 arg);
1089 case AccessKind.UNRESOLVED_SUPER: 704 case AccessKind.UNRESOLVED_SUPER:
1090 case AccessKind.UNRESOLVED: 705 case AccessKind.UNRESOLVED:
1091 return visitor.visitUnresolvedSuperIndexSet( 706 return visitor.visitUnresolvedSuperIndexSet(node, semantics.element,
1092 node, 707 node.arguments.first, node.arguments.tail.head, arg);
1093 semantics.element,
1094 node.arguments.first,
1095 node.arguments.tail.head,
1096 arg);
1097 case AccessKind.INVALID: 708 case AccessKind.INVALID:
1098 return visitor.errorInvalidIndexSet( 709 return visitor.errorInvalidIndexSet(node, semantics.element,
1099 node, 710 node.arguments.first, node.arguments.tail.head, arg);
1100 semantics.element,
1101 node.arguments.first,
1102 node.arguments.tail.head,
1103 arg);
1104 default: 711 default:
1105 // This is not a valid case. 712 // This is not a valid case.
1106 break; 713 break;
1107 } 714 }
1108 throw new SpannableAssertionFailure( 715 throw new SpannableAssertionFailure(
1109 node, "Invalid index set: ${semantics}"); 716 node, "Invalid index set: ${semantics}");
1110 } 717 }
1111 718
1112 String toString() => '[]=($semantics)'; 719 String toString() => '[]=($semantics)';
1113 } 720 }
1114 721
1115 /// The structure for a [Send] that is an prefix operation on an index 722 /// The structure for a [Send] that is an prefix operation on an index
1116 /// expression, i.e. of the form `--a[b]`. 723 /// expression, i.e. of the form `--a[b]`.
1117 class IndexPrefixStructure<R, A> implements SendStructure<R, A> { 724 class IndexPrefixStructure<R, A> implements SendStructure<R, A> {
1118 /// The target of the left operand. 725 /// The target of the left operand.
1119 final AccessSemantics semantics; 726 final AccessSemantics semantics;
1120 727
1121 /// The `++` or `--` operator used in the operation. 728 /// The `++` or `--` operator used in the operation.
1122 final IncDecOperator operator; 729 final IncDecOperator operator;
1123 730
1124 IndexPrefixStructure(this.semantics, this.operator); 731 IndexPrefixStructure(this.semantics, this.operator);
1125 732
1126 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 733 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1127 switch (semantics.kind) { 734 switch (semantics.kind) {
1128 case AccessKind.EXPRESSION: 735 case AccessKind.EXPRESSION:
1129 return visitor.visitIndexPrefix( 736 return visitor.visitIndexPrefix(
1130 node, 737 node, node.receiver, node.arguments.single, operator, arg);
1131 node.receiver,
1132 node.arguments.single,
1133 operator,
1134 arg);
1135 case AccessKind.UNRESOLVED_SUPER: 738 case AccessKind.UNRESOLVED_SUPER:
1136 return visitor.visitUnresolvedSuperIndexPrefix( 739 return visitor.visitUnresolvedSuperIndexPrefix(
1137 node, 740 node, semantics.element, node.arguments.single, operator, arg);
1138 semantics.element,
1139 node.arguments.single,
1140 operator,
1141 arg);
1142 case AccessKind.INVALID: 741 case AccessKind.INVALID:
1143 return visitor.errorInvalidIndexPrefix( 742 return visitor.errorInvalidIndexPrefix(
1144 node, 743 node, semantics.element, node.arguments.single, operator, arg);
1145 semantics.element,
1146 node.arguments.single,
1147 operator,
1148 arg);
1149 case AccessKind.COMPOUND: 744 case AccessKind.COMPOUND:
1150 CompoundAccessSemantics compoundSemantics = semantics; 745 CompoundAccessSemantics compoundSemantics = semantics;
1151 switch (compoundSemantics.compoundAccessKind) { 746 switch (compoundSemantics.compoundAccessKind) {
1152 case CompoundAccessKind.SUPER_GETTER_SETTER: 747 case CompoundAccessKind.SUPER_GETTER_SETTER:
1153 return visitor.visitSuperIndexPrefix( 748 return visitor.visitSuperIndexPrefix(node, compoundSemantics.getter,
1154 node, 749 compoundSemantics.setter, node.arguments.single, operator, arg);
1155 compoundSemantics.getter,
1156 compoundSemantics.setter,
1157 node.arguments.single,
1158 operator,
1159 arg);
1160 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER: 750 case CompoundAccessKind.UNRESOLVED_SUPER_GETTER:
1161 return visitor.visitUnresolvedSuperGetterIndexPrefix( 751 return visitor.visitUnresolvedSuperGetterIndexPrefix(
1162 node, 752 node,
1163 compoundSemantics.getter, 753 compoundSemantics.getter,
1164 compoundSemantics.setter, 754 compoundSemantics.setter,
1165 node.arguments.single, 755 node.arguments.single,
1166 operator, 756 operator,
1167 arg); 757 arg);
1168 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: 758 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
1169 return visitor.visitUnresolvedSuperSetterIndexPrefix( 759 return visitor.visitUnresolvedSuperSetterIndexPrefix(
(...skipping 25 matching lines...) Expand all
1195 785
1196 /// The `++` or `--` operator used in the operation. 786 /// The `++` or `--` operator used in the operation.
1197 final IncDecOperator operator; 787 final IncDecOperator operator;
1198 788
1199 IndexPostfixStructure(this.semantics, this.operator); 789 IndexPostfixStructure(this.semantics, this.operator);
1200 790
1201 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 791 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1202 switch (semantics.kind) { 792 switch (semantics.kind) {
1203 case AccessKind.EXPRESSION: 793 case AccessKind.EXPRESSION:
1204 return visitor.visitIndexPostfix( 794 return visitor.visitIndexPostfix(
1205 node, 795 node, node.receiver, node.arguments.single, operator, arg);
1206 node.receiver,
1207 node.arguments.single,
1208 operator,
1209 arg);
1210 case AccessKind.UNRESOLVED_SUPER: 796 case AccessKind.UNRESOLVED_SUPER:
1211 return visitor.visitUnresolvedSuperIndexPostfix( 797 return visitor.visitUnresolvedSuperIndexPostfix(
1212 node, 798 node, semantics.element, node.arguments.single, operator, arg);
1213 semantics.element,
1214 node.arguments.single,
1215 operator,
1216 arg);
1217 case AccessKind.INVALID: 799 case AccessKind.INVALID:
1218 return visitor.errorInvalidIndexPostfix( 800 return visitor.errorInvalidIndexPostfix(
1219 node, 801 node, semantics.element, node.arguments.single, operator, arg);
1220 semantics.element,
1221 node.arguments.single,
1222 operator,
1223 arg);
1224 case AccessKind.COMPOUND: 802 case AccessKind.COMPOUND:
1225 CompoundAccessSemantics compoundSemantics = semantics; 803 CompoundAccessSemantics compoundSemantics = semantics;
1226 switch (compoundSemantics.compoundAccessKind) { 804 switch (compoundSemantics.compoundAccessKind) {
1227 case CompoundAccessKind.SUPER_GETTER_SETTER: 805 case CompoundAccessKind.SUPER_GETTER_SETTER:
1228 return visitor.visitSuperIndexPostfix( 806 return visitor.visitSuperIndexPostfix(
1229 node, 807 node,
1230 compoundSemantics.getter, 808 compoundSemantics.getter,
1231 compoundSemantics.setter, 809 compoundSemantics.setter,
1232 node.arguments.single, 810 node.arguments.single,
1233 operator, 811 operator,
(...skipping 30 matching lines...) Expand all
1264 842
1265 /// The structure for a [Send] that is a compound assignment. For instance 843 /// The structure for a [Send] that is a compound assignment. For instance
1266 /// `a += b`. 844 /// `a += b`.
1267 class CompoundStructure<R, A> implements SendStructure<R, A> { 845 class CompoundStructure<R, A> implements SendStructure<R, A> {
1268 /// The target of the compound assignment, i.e. the left-hand side. 846 /// The target of the compound assignment, i.e. the left-hand side.
1269 final AccessSemantics semantics; 847 final AccessSemantics semantics;
1270 848
1271 /// The assignment operator used in the compound assignment. 849 /// The assignment operator used in the compound assignment.
1272 final AssignmentOperator operator; 850 final AssignmentOperator operator;
1273 851
1274 CompoundStructure(this.semantics, 852 CompoundStructure(this.semantics, this.operator);
1275 this.operator);
1276 853
1277 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 854 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1278 switch (semantics.kind) { 855 switch (semantics.kind) {
1279 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 856 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
1280 return visitor.visitIfNotNullDynamicPropertyCompound( 857 return visitor.visitIfNotNullDynamicPropertyCompound(
1281 node, 858 node,
1282 node.receiver, 859 node.receiver,
1283 semantics.name, 860 semantics.name,
1284 operator, 861 operator,
1285 node.arguments.single, 862 node.arguments.single,
1286 arg); 863 arg);
1287 case AccessKind.DYNAMIC_PROPERTY: 864 case AccessKind.DYNAMIC_PROPERTY:
1288 return visitor.visitDynamicPropertyCompound( 865 return visitor.visitDynamicPropertyCompound(node, node.receiver,
1289 node, 866 semantics.name, operator, node.arguments.single, arg);
1290 node.receiver,
1291 semantics.name,
1292 operator,
1293 node.arguments.single,
1294 arg);
1295 case AccessKind.LOCAL_FUNCTION: 867 case AccessKind.LOCAL_FUNCTION:
1296 return visitor.visitLocalFunctionCompound( 868 return visitor.visitLocalFunctionCompound(
1297 node, 869 node, semantics.element, operator, node.arguments.single, arg);
1298 semantics.element,
1299 operator,
1300 node.arguments.single,
1301 arg);
1302 case AccessKind.LOCAL_VARIABLE: 870 case AccessKind.LOCAL_VARIABLE:
1303 return visitor.visitLocalVariableCompound( 871 return visitor.visitLocalVariableCompound(
1304 node, 872 node, semantics.element, operator, node.arguments.single, arg);
1305 semantics.element,
1306 operator,
1307 node.arguments.single,
1308 arg);
1309 case AccessKind.FINAL_LOCAL_VARIABLE: 873 case AccessKind.FINAL_LOCAL_VARIABLE:
1310 return visitor.visitFinalLocalVariableCompound( 874 return visitor.visitFinalLocalVariableCompound(
1311 node, 875 node, semantics.element, operator, node.arguments.single, arg);
1312 semantics.element,
1313 operator,
1314 node.arguments.single,
1315 arg);
1316 case AccessKind.PARAMETER: 876 case AccessKind.PARAMETER:
1317 return visitor.visitParameterCompound( 877 return visitor.visitParameterCompound(
1318 node, 878 node, semantics.element, operator, node.arguments.single, arg);
1319 semantics.element,
1320 operator,
1321 node.arguments.single,
1322 arg);
1323 case AccessKind.FINAL_PARAMETER: 879 case AccessKind.FINAL_PARAMETER:
1324 return visitor.visitFinalParameterCompound( 880 return visitor.visitFinalParameterCompound(
1325 node, 881 node, semantics.element, operator, node.arguments.single, arg);
1326 semantics.element,
1327 operator,
1328 node.arguments.single,
1329 arg);
1330 case AccessKind.STATIC_FIELD: 882 case AccessKind.STATIC_FIELD:
1331 return visitor.visitStaticFieldCompound( 883 return visitor.visitStaticFieldCompound(
1332 node, 884 node, semantics.element, operator, node.arguments.single, arg);
1333 semantics.element,
1334 operator,
1335 node.arguments.single,
1336 arg);
1337 case AccessKind.FINAL_STATIC_FIELD: 885 case AccessKind.FINAL_STATIC_FIELD:
1338 return visitor.visitFinalStaticFieldCompound( 886 return visitor.visitFinalStaticFieldCompound(
1339 node, 887 node, semantics.element, operator, node.arguments.single, arg);
1340 semantics.element,
1341 operator,
1342 node.arguments.single,
1343 arg);
1344 case AccessKind.STATIC_METHOD: 888 case AccessKind.STATIC_METHOD:
1345 return visitor.visitStaticMethodCompound( 889 return visitor.visitStaticMethodCompound(
1346 node, 890 node, semantics.element, operator, node.arguments.single, arg);
1347 semantics.element,
1348 operator,
1349 node.arguments.single,
1350 arg);
1351 case AccessKind.STATIC_GETTER: 891 case AccessKind.STATIC_GETTER:
1352 // This is not a valid case. 892 // This is not a valid case.
1353 break; 893 break;
1354 case AccessKind.STATIC_SETTER: 894 case AccessKind.STATIC_SETTER:
1355 // This is not a valid case. 895 // This is not a valid case.
1356 break; 896 break;
1357 case AccessKind.TOPLEVEL_FIELD: 897 case AccessKind.TOPLEVEL_FIELD:
1358 return visitor.visitTopLevelFieldCompound( 898 return visitor.visitTopLevelFieldCompound(
1359 node, 899 node, semantics.element, operator, node.arguments.single, arg);
1360 semantics.element,
1361 operator,
1362 node.arguments.single,
1363 arg);
1364 case AccessKind.FINAL_TOPLEVEL_FIELD: 900 case AccessKind.FINAL_TOPLEVEL_FIELD:
1365 return visitor.visitFinalTopLevelFieldCompound( 901 return visitor.visitFinalTopLevelFieldCompound(
1366 node, 902 node, semantics.element, operator, node.arguments.single, arg);
1367 semantics.element,
1368 operator,
1369 node.arguments.single,
1370 arg);
1371 case AccessKind.TOPLEVEL_METHOD: 903 case AccessKind.TOPLEVEL_METHOD:
1372 return visitor.visitTopLevelMethodCompound( 904 return visitor.visitTopLevelMethodCompound(
1373 node, 905 node, semantics.element, operator, node.arguments.single, arg);
1374 semantics.element,
1375 operator,
1376 node.arguments.single,
1377 arg);
1378 case AccessKind.TOPLEVEL_GETTER: 906 case AccessKind.TOPLEVEL_GETTER:
1379 // This is not a valid case. 907 // This is not a valid case.
1380 break; 908 break;
1381 case AccessKind.TOPLEVEL_SETTER: 909 case AccessKind.TOPLEVEL_SETTER:
1382 // This is not a valid case. 910 // This is not a valid case.
1383 break; 911 break;
1384 case AccessKind.CLASS_TYPE_LITERAL: 912 case AccessKind.CLASS_TYPE_LITERAL:
1385 return visitor.visitClassTypeLiteralCompound( 913 return visitor.visitClassTypeLiteralCompound(
1386 node, 914 node, semantics.constant, operator, node.arguments.single, arg);
1387 semantics.constant,
1388 operator,
1389 node.arguments.single,
1390 arg);
1391 case AccessKind.TYPEDEF_TYPE_LITERAL: 915 case AccessKind.TYPEDEF_TYPE_LITERAL:
1392 return visitor.visitTypedefTypeLiteralCompound( 916 return visitor.visitTypedefTypeLiteralCompound(
1393 node, 917 node, semantics.constant, operator, node.arguments.single, arg);
1394 semantics.constant,
1395 operator,
1396 node.arguments.single,
1397 arg);
1398 case AccessKind.DYNAMIC_TYPE_LITERAL: 918 case AccessKind.DYNAMIC_TYPE_LITERAL:
1399 return visitor.visitDynamicTypeLiteralCompound( 919 return visitor.visitDynamicTypeLiteralCompound(
1400 node, 920 node, semantics.constant, operator, node.arguments.single, arg);
1401 semantics.constant,
1402 operator,
1403 node.arguments.single,
1404 arg);
1405 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 921 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
1406 return visitor.visitTypeVariableTypeLiteralCompound( 922 return visitor.visitTypeVariableTypeLiteralCompound(
1407 node, 923 node, semantics.element, operator, node.arguments.single, arg);
1408 semantics.element,
1409 operator,
1410 node.arguments.single,
1411 arg);
1412 case AccessKind.EXPRESSION: 924 case AccessKind.EXPRESSION:
1413 // This is not a valid case. 925 // This is not a valid case.
1414 break; 926 break;
1415 case AccessKind.THIS: 927 case AccessKind.THIS:
1416 // This is not a valid case. 928 // This is not a valid case.
1417 break; 929 break;
1418 case AccessKind.THIS_PROPERTY: 930 case AccessKind.THIS_PROPERTY:
1419 return visitor.visitThisPropertyCompound( 931 return visitor.visitThisPropertyCompound(
1420 node, 932 node, semantics.name, operator, node.arguments.single, arg);
1421 semantics.name,
1422 operator,
1423 node.arguments.single,
1424 arg);
1425 case AccessKind.SUPER_FIELD: 933 case AccessKind.SUPER_FIELD:
1426 return visitor.visitSuperFieldCompound( 934 return visitor.visitSuperFieldCompound(
1427 node, 935 node, semantics.element, operator, node.arguments.single, arg);
1428 semantics.element,
1429 operator,
1430 node.arguments.single,
1431 arg);
1432 case AccessKind.SUPER_FINAL_FIELD: 936 case AccessKind.SUPER_FINAL_FIELD:
1433 return visitor.visitFinalSuperFieldCompound( 937 return visitor.visitFinalSuperFieldCompound(
1434 node, 938 node, semantics.element, operator, node.arguments.single, arg);
1435 semantics.element,
1436 operator,
1437 node.arguments.single,
1438 arg);
1439 case AccessKind.SUPER_METHOD: 939 case AccessKind.SUPER_METHOD:
1440 return visitor.visitSuperMethodCompound( 940 return visitor.visitSuperMethodCompound(
1441 node, 941 node, semantics.element, operator, node.arguments.single, arg);
1442 semantics.element,
1443 operator,
1444 node.arguments.single,
1445 arg);
1446 case AccessKind.SUPER_GETTER: 942 case AccessKind.SUPER_GETTER:
1447 // This is not a valid case. 943 // This is not a valid case.
1448 break; 944 break;
1449 case AccessKind.SUPER_SETTER: 945 case AccessKind.SUPER_SETTER:
1450 // This is not a valid case. 946 // This is not a valid case.
1451 break; 947 break;
1452 case AccessKind.CONSTANT: 948 case AccessKind.CONSTANT:
1453 // TODO(johnniwinther): Should this be a valid case? 949 // TODO(johnniwinther): Should this be a valid case?
1454 break; 950 break;
1455 case AccessKind.UNRESOLVED_SUPER: 951 case AccessKind.UNRESOLVED_SUPER:
1456 return visitor.visitUnresolvedSuperCompound( 952 return visitor.visitUnresolvedSuperCompound(
1457 node, 953 node, semantics.element, operator, node.arguments.single, arg);
1458 semantics.element,
1459 operator,
1460 node.arguments.single,
1461 arg);
1462 case AccessKind.UNRESOLVED: 954 case AccessKind.UNRESOLVED:
1463 return visitor.visitUnresolvedCompound( 955 return visitor.visitUnresolvedCompound(
1464 node, 956 node, semantics.element, operator, node.arguments.single, arg);
1465 semantics.element,
1466 operator,
1467 node.arguments.single,
1468 arg);
1469 case AccessKind.INVALID: 957 case AccessKind.INVALID:
1470 return visitor.errorInvalidCompound( 958 return visitor.errorInvalidCompound(
1471 node, 959 node, semantics.element, operator, node.arguments.single, arg);
1472 semantics.element,
1473 operator,
1474 node.arguments.single,
1475 arg);
1476 case AccessKind.COMPOUND: 960 case AccessKind.COMPOUND:
1477 CompoundAccessSemantics compoundSemantics = semantics; 961 CompoundAccessSemantics compoundSemantics = semantics;
1478 switch (compoundSemantics.compoundAccessKind) { 962 switch (compoundSemantics.compoundAccessKind) {
1479 case CompoundAccessKind.STATIC_GETTER_SETTER: 963 case CompoundAccessKind.STATIC_GETTER_SETTER:
1480 return visitor.visitStaticGetterSetterCompound( 964 return visitor.visitStaticGetterSetterCompound(
1481 node, 965 node,
1482 compoundSemantics.getter, 966 compoundSemantics.getter,
1483 compoundSemantics.setter, 967 compoundSemantics.setter,
1484 operator, 968 operator,
1485 node.arguments.single, 969 node.arguments.single,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 return visitor.visitUnresolvedSuperSetterCompound( 1076 return visitor.visitUnresolvedSuperSetterCompound(
1593 node, 1077 node,
1594 compoundSemantics.getter, 1078 compoundSemantics.getter,
1595 compoundSemantics.setter, 1079 compoundSemantics.setter,
1596 operator, 1080 operator,
1597 node.arguments.single, 1081 node.arguments.single,
1598 arg); 1082 arg);
1599 } 1083 }
1600 break; 1084 break;
1601 } 1085 }
1602 throw new SpannableAssertionFailure(node, 1086 throw new SpannableAssertionFailure(
1603 "Invalid compound assigment: ${semantics}"); 1087 node, "Invalid compound assigment: ${semantics}");
1604 } 1088 }
1605 1089
1606 String toString() => 'compound($operator,$semantics)'; 1090 String toString() => 'compound($operator,$semantics)';
1607 } 1091 }
1608 1092
1609 /// The structure for a [Send] that is an if-null assignment. For instance 1093 /// The structure for a [Send] that is an if-null assignment. For instance
1610 /// `a ??= b`. 1094 /// `a ??= b`.
1611 class SetIfNullStructure<R, A> implements SendStructure<R, A> { 1095 class SetIfNullStructure<R, A> implements SendStructure<R, A> {
1612 /// The target of the if-null assignment, i.e. the left-hand side. 1096 /// The target of the if-null assignment, i.e. the left-hand side.
1613 final AccessSemantics semantics; 1097 final AccessSemantics semantics;
1614 1098
1615 SetIfNullStructure(this.semantics); 1099 SetIfNullStructure(this.semantics);
1616 1100
1617 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1101 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1618 switch (semantics.kind) { 1102 switch (semantics.kind) {
1619 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 1103 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
1620 return visitor.visitIfNotNullDynamicPropertySetIfNull( 1104 return visitor.visitIfNotNullDynamicPropertySetIfNull(
1621 node, 1105 node, node.receiver, semantics.name, node.arguments.single, arg);
1622 node.receiver,
1623 semantics.name,
1624 node.arguments.single,
1625 arg);
1626 case AccessKind.DYNAMIC_PROPERTY: 1106 case AccessKind.DYNAMIC_PROPERTY:
1627 return visitor.visitDynamicPropertySetIfNull( 1107 return visitor.visitDynamicPropertySetIfNull(
1628 node, 1108 node, node.receiver, semantics.name, node.arguments.single, arg);
1629 node.receiver,
1630 semantics.name,
1631 node.arguments.single,
1632 arg);
1633 case AccessKind.LOCAL_FUNCTION: 1109 case AccessKind.LOCAL_FUNCTION:
1634 return visitor.visitLocalFunctionSetIfNull( 1110 return visitor.visitLocalFunctionSetIfNull(
1635 node, 1111 node, semantics.element, node.arguments.single, arg);
1636 semantics.element,
1637 node.arguments.single,
1638 arg);
1639 case AccessKind.LOCAL_VARIABLE: 1112 case AccessKind.LOCAL_VARIABLE:
1640 return visitor.visitLocalVariableSetIfNull( 1113 return visitor.visitLocalVariableSetIfNull(
1641 node, 1114 node, semantics.element, node.arguments.single, arg);
1642 semantics.element,
1643 node.arguments.single,
1644 arg);
1645 case AccessKind.FINAL_LOCAL_VARIABLE: 1115 case AccessKind.FINAL_LOCAL_VARIABLE:
1646 return visitor.visitFinalLocalVariableSetIfNull( 1116 return visitor.visitFinalLocalVariableSetIfNull(
1647 node, 1117 node, semantics.element, node.arguments.single, arg);
1648 semantics.element,
1649 node.arguments.single,
1650 arg);
1651 case AccessKind.PARAMETER: 1118 case AccessKind.PARAMETER:
1652 return visitor.visitParameterSetIfNull( 1119 return visitor.visitParameterSetIfNull(
1653 node, 1120 node, semantics.element, node.arguments.single, arg);
1654 semantics.element,
1655 node.arguments.single,
1656 arg);
1657 case AccessKind.FINAL_PARAMETER: 1121 case AccessKind.FINAL_PARAMETER:
1658 return visitor.visitFinalParameterSetIfNull( 1122 return visitor.visitFinalParameterSetIfNull(
1659 node, 1123 node, semantics.element, node.arguments.single, arg);
1660 semantics.element,
1661 node.arguments.single,
1662 arg);
1663 case AccessKind.STATIC_FIELD: 1124 case AccessKind.STATIC_FIELD:
1664 return visitor.visitStaticFieldSetIfNull( 1125 return visitor.visitStaticFieldSetIfNull(
1665 node, 1126 node, semantics.element, node.arguments.single, arg);
1666 semantics.element,
1667 node.arguments.single,
1668 arg);
1669 case AccessKind.FINAL_STATIC_FIELD: 1127 case AccessKind.FINAL_STATIC_FIELD:
1670 return visitor.visitFinalStaticFieldSetIfNull( 1128 return visitor.visitFinalStaticFieldSetIfNull(
1671 node, 1129 node, semantics.element, node.arguments.single, arg);
1672 semantics.element,
1673 node.arguments.single,
1674 arg);
1675 case AccessKind.STATIC_METHOD: 1130 case AccessKind.STATIC_METHOD:
1676 return visitor.visitStaticMethodSetIfNull( 1131 return visitor.visitStaticMethodSetIfNull(
1677 node, 1132 node, semantics.element, node.arguments.single, arg);
1678 semantics.element,
1679 node.arguments.single,
1680 arg);
1681 case AccessKind.STATIC_GETTER: 1133 case AccessKind.STATIC_GETTER:
1682 // This is not a valid case. 1134 // This is not a valid case.
1683 break; 1135 break;
1684 case AccessKind.STATIC_SETTER: 1136 case AccessKind.STATIC_SETTER:
1685 // This is not a valid case. 1137 // This is not a valid case.
1686 break; 1138 break;
1687 case AccessKind.TOPLEVEL_FIELD: 1139 case AccessKind.TOPLEVEL_FIELD:
1688 return visitor.visitTopLevelFieldSetIfNull( 1140 return visitor.visitTopLevelFieldSetIfNull(
1689 node, 1141 node, semantics.element, node.arguments.single, arg);
1690 semantics.element,
1691 node.arguments.single,
1692 arg);
1693 case AccessKind.FINAL_TOPLEVEL_FIELD: 1142 case AccessKind.FINAL_TOPLEVEL_FIELD:
1694 return visitor.visitFinalTopLevelFieldSetIfNull( 1143 return visitor.visitFinalTopLevelFieldSetIfNull(
1695 node, 1144 node, semantics.element, node.arguments.single, arg);
1696 semantics.element,
1697 node.arguments.single,
1698 arg);
1699 case AccessKind.TOPLEVEL_METHOD: 1145 case AccessKind.TOPLEVEL_METHOD:
1700 return visitor.visitTopLevelMethodSetIfNull( 1146 return visitor.visitTopLevelMethodSetIfNull(
1701 node, 1147 node, semantics.element, node.arguments.single, arg);
1702 semantics.element,
1703 node.arguments.single,
1704 arg);
1705 case AccessKind.TOPLEVEL_GETTER: 1148 case AccessKind.TOPLEVEL_GETTER:
1706 // This is not a valid case. 1149 // This is not a valid case.
1707 break; 1150 break;
1708 case AccessKind.TOPLEVEL_SETTER: 1151 case AccessKind.TOPLEVEL_SETTER:
1709 // This is not a valid case. 1152 // This is not a valid case.
1710 break; 1153 break;
1711 case AccessKind.CLASS_TYPE_LITERAL: 1154 case AccessKind.CLASS_TYPE_LITERAL:
1712 return visitor.visitClassTypeLiteralSetIfNull( 1155 return visitor.visitClassTypeLiteralSetIfNull(
1713 node, 1156 node, semantics.constant, node.arguments.single, arg);
1714 semantics.constant,
1715 node.arguments.single,
1716 arg);
1717 case AccessKind.TYPEDEF_TYPE_LITERAL: 1157 case AccessKind.TYPEDEF_TYPE_LITERAL:
1718 return visitor.visitTypedefTypeLiteralSetIfNull( 1158 return visitor.visitTypedefTypeLiteralSetIfNull(
1719 node, 1159 node, semantics.constant, node.arguments.single, arg);
1720 semantics.constant,
1721 node.arguments.single,
1722 arg);
1723 case AccessKind.DYNAMIC_TYPE_LITERAL: 1160 case AccessKind.DYNAMIC_TYPE_LITERAL:
1724 return visitor.visitDynamicTypeLiteralSetIfNull( 1161 return visitor.visitDynamicTypeLiteralSetIfNull(
1725 node, 1162 node, semantics.constant, node.arguments.single, arg);
1726 semantics.constant,
1727 node.arguments.single,
1728 arg);
1729 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 1163 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
1730 return visitor.visitTypeVariableTypeLiteralSetIfNull( 1164 return visitor.visitTypeVariableTypeLiteralSetIfNull(
1731 node, 1165 node, semantics.element, node.arguments.single, arg);
1732 semantics.element,
1733 node.arguments.single,
1734 arg);
1735 case AccessKind.EXPRESSION: 1166 case AccessKind.EXPRESSION:
1736 // This is not a valid case. 1167 // This is not a valid case.
1737 break; 1168 break;
1738 case AccessKind.THIS: 1169 case AccessKind.THIS:
1739 // This is not a valid case. 1170 // This is not a valid case.
1740 break; 1171 break;
1741 case AccessKind.THIS_PROPERTY: 1172 case AccessKind.THIS_PROPERTY:
1742 return visitor.visitThisPropertySetIfNull( 1173 return visitor.visitThisPropertySetIfNull(
1743 node, 1174 node, semantics.name, node.arguments.single, arg);
1744 semantics.name,
1745 node.arguments.single,
1746 arg);
1747 case AccessKind.SUPER_FIELD: 1175 case AccessKind.SUPER_FIELD:
1748 return visitor.visitSuperFieldSetIfNull( 1176 return visitor.visitSuperFieldSetIfNull(
1749 node, 1177 node, semantics.element, node.arguments.single, arg);
1750 semantics.element,
1751 node.arguments.single,
1752 arg);
1753 case AccessKind.SUPER_FINAL_FIELD: 1178 case AccessKind.SUPER_FINAL_FIELD:
1754 return visitor.visitFinalSuperFieldSetIfNull( 1179 return visitor.visitFinalSuperFieldSetIfNull(
1755 node, 1180 node, semantics.element, node.arguments.single, arg);
1756 semantics.element,
1757 node.arguments.single,
1758 arg);
1759 case AccessKind.SUPER_METHOD: 1181 case AccessKind.SUPER_METHOD:
1760 return visitor.visitSuperMethodSetIfNull( 1182 return visitor.visitSuperMethodSetIfNull(
1761 node, 1183 node, semantics.element, node.arguments.single, arg);
1762 semantics.element,
1763 node.arguments.single,
1764 arg);
1765 case AccessKind.SUPER_GETTER: 1184 case AccessKind.SUPER_GETTER:
1766 // This is not a valid case. 1185 // This is not a valid case.
1767 break; 1186 break;
1768 case AccessKind.SUPER_SETTER: 1187 case AccessKind.SUPER_SETTER:
1769 // This is not a valid case. 1188 // This is not a valid case.
1770 break; 1189 break;
1771 case AccessKind.CONSTANT: 1190 case AccessKind.CONSTANT:
1772 // TODO(johnniwinther): Should this be a valid case? 1191 // TODO(johnniwinther): Should this be a valid case?
1773 break; 1192 break;
1774 case AccessKind.UNRESOLVED_SUPER: 1193 case AccessKind.UNRESOLVED_SUPER:
1775 return visitor.visitUnresolvedSuperSetIfNull( 1194 return visitor.visitUnresolvedSuperSetIfNull(
1776 node, 1195 node, semantics.element, node.arguments.single, arg);
1777 semantics.element,
1778 node.arguments.single,
1779 arg);
1780 case AccessKind.UNRESOLVED: 1196 case AccessKind.UNRESOLVED:
1781 return visitor.visitUnresolvedSetIfNull( 1197 return visitor.visitUnresolvedSetIfNull(
1782 node, 1198 node, semantics.element, node.arguments.single, arg);
1783 semantics.element,
1784 node.arguments.single,
1785 arg);
1786 case AccessKind.INVALID: 1199 case AccessKind.INVALID:
1787 return visitor.errorInvalidSetIfNull( 1200 return visitor.errorInvalidSetIfNull(
1788 node, 1201 node, semantics.element, node.arguments.single, arg);
1789 semantics.element,
1790 node.arguments.single,
1791 arg);
1792 case AccessKind.COMPOUND: 1202 case AccessKind.COMPOUND:
1793 CompoundAccessSemantics compoundSemantics = semantics; 1203 CompoundAccessSemantics compoundSemantics = semantics;
1794 switch (compoundSemantics.compoundAccessKind) { 1204 switch (compoundSemantics.compoundAccessKind) {
1795 case CompoundAccessKind.STATIC_GETTER_SETTER: 1205 case CompoundAccessKind.STATIC_GETTER_SETTER:
1796 return visitor.visitStaticGetterSetterSetIfNull( 1206 return visitor.visitStaticGetterSetterSetIfNull(
1797 node, 1207 node,
1798 compoundSemantics.getter, 1208 compoundSemantics.getter,
1799 compoundSemantics.setter, 1209 compoundSemantics.setter,
1800 node.arguments.single, 1210 node.arguments.single,
1801 arg); 1211 arg);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: 1303 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
1894 return visitor.visitUnresolvedSuperSetterSetIfNull( 1304 return visitor.visitUnresolvedSuperSetterSetIfNull(
1895 node, 1305 node,
1896 compoundSemantics.getter, 1306 compoundSemantics.getter,
1897 compoundSemantics.setter, 1307 compoundSemantics.setter,
1898 node.arguments.single, 1308 node.arguments.single,
1899 arg); 1309 arg);
1900 } 1310 }
1901 break; 1311 break;
1902 } 1312 }
1903 throw new SpannableAssertionFailure(node, 1313 throw new SpannableAssertionFailure(
1904 "Invalid if-null assigment: ${semantics}"); 1314 node, "Invalid if-null assigment: ${semantics}");
1905 } 1315 }
1906 1316
1907 String toString() => 'ifNull($semantics)'; 1317 String toString() => 'ifNull($semantics)';
1908 } 1318 }
1909 1319
1910 /// The structure for a [Send] that is a compound assignment on the index 1320 /// The structure for a [Send] that is a compound assignment on the index
1911 /// operator. For instance `a[b] += c`. 1321 /// operator. For instance `a[b] += c`.
1912 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> { 1322 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> {
1913 /// The target of the index operations. 1323 /// The target of the index operations.
1914 final AccessSemantics semantics; 1324 final AccessSemantics semantics;
1915 1325
1916 /// The assignment operator used in the compound assignment. 1326 /// The assignment operator used in the compound assignment.
1917 final AssignmentOperator operator; 1327 final AssignmentOperator operator;
1918 1328
1919 CompoundIndexSetStructure(this.semantics, this.operator); 1329 CompoundIndexSetStructure(this.semantics, this.operator);
1920 1330
1921 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1331 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1922 switch (semantics.kind) { 1332 switch (semantics.kind) {
1923 case AccessKind.EXPRESSION: 1333 case AccessKind.EXPRESSION:
1924 return visitor.visitCompoundIndexSet( 1334 return visitor.visitCompoundIndexSet(node, node.receiver,
1925 node, 1335 node.arguments.first, operator, node.arguments.tail.head, arg);
1926 node.receiver,
1927 node.arguments.first,
1928 operator,
1929 node.arguments.tail.head,
1930 arg);
1931 case AccessKind.UNRESOLVED_SUPER: 1336 case AccessKind.UNRESOLVED_SUPER:
1932 return visitor.visitUnresolvedSuperCompoundIndexSet( 1337 return visitor.visitUnresolvedSuperCompoundIndexSet(
1933 node, 1338 node,
1934 semantics.element, 1339 semantics.element,
1935 node.arguments.first, 1340 node.arguments.first,
1936 operator, 1341 operator,
1937 node.arguments.tail.head, 1342 node.arguments.tail.head,
1938 arg); 1343 arg);
1939 case AccessKind.INVALID: 1344 case AccessKind.INVALID:
1940 return visitor.errorInvalidCompoundIndexSet( 1345 return visitor.errorInvalidCompoundIndexSet(node, semantics.element,
1941 node, 1346 node.arguments.first, operator, node.arguments.tail.head, arg);
1942 semantics.element,
1943 node.arguments.first,
1944 operator,
1945 node.arguments.tail.head,
1946 arg);
1947 case AccessKind.COMPOUND: 1347 case AccessKind.COMPOUND:
1948 CompoundAccessSemantics compoundSemantics = semantics; 1348 CompoundAccessSemantics compoundSemantics = semantics;
1949 switch (compoundSemantics.compoundAccessKind) { 1349 switch (compoundSemantics.compoundAccessKind) {
1950 case CompoundAccessKind.SUPER_GETTER_SETTER: 1350 case CompoundAccessKind.SUPER_GETTER_SETTER:
1951 return visitor.visitSuperCompoundIndexSet( 1351 return visitor.visitSuperCompoundIndexSet(
1952 node, 1352 node,
1953 compoundSemantics.getter, 1353 compoundSemantics.getter,
1954 compoundSemantics.setter, 1354 compoundSemantics.setter,
1955 node.arguments.first, 1355 node.arguments.first,
1956 operator, 1356 operator,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 /// operator. For instance `a[b] ??= c`. 1394 /// operator. For instance `a[b] ??= c`.
1995 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> { 1395 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> {
1996 /// The target of the index operations. 1396 /// The target of the index operations.
1997 final AccessSemantics semantics; 1397 final AccessSemantics semantics;
1998 1398
1999 IndexSetIfNullStructure(this.semantics); 1399 IndexSetIfNullStructure(this.semantics);
2000 1400
2001 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1401 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
2002 switch (semantics.kind) { 1402 switch (semantics.kind) {
2003 case AccessKind.EXPRESSION: 1403 case AccessKind.EXPRESSION:
2004 return visitor.visitIndexSetIfNull( 1404 return visitor.visitIndexSetIfNull(node, node.receiver,
2005 node, 1405 node.arguments.first, node.arguments.tail.head, arg);
2006 node.receiver,
2007 node.arguments.first,
2008 node.arguments.tail.head,
2009 arg);
2010 case AccessKind.UNRESOLVED_SUPER: 1406 case AccessKind.UNRESOLVED_SUPER:
2011 return visitor.visitUnresolvedSuperIndexSetIfNull( 1407 return visitor.visitUnresolvedSuperIndexSetIfNull(
2012 node, 1408 node,
2013 semantics.element, 1409 semantics.element,
2014 node.arguments.first, 1410 node.arguments.first,
2015 node.arguments.tail.head, 1411 node.arguments.tail.head,
2016 arg); 1412 arg);
2017 case AccessKind.INVALID: 1413 case AccessKind.INVALID:
2018 return visitor.errorInvalidIndexSetIfNull( 1414 return visitor.errorInvalidIndexSetIfNull(node, semantics.element,
2019 node, 1415 node.arguments.first, node.arguments.tail.head, arg);
2020 semantics.element,
2021 node.arguments.first,
2022 node.arguments.tail.head,
2023 arg);
2024 case AccessKind.COMPOUND: 1416 case AccessKind.COMPOUND:
2025 CompoundAccessSemantics compoundSemantics = semantics; 1417 CompoundAccessSemantics compoundSemantics = semantics;
2026 switch (compoundSemantics.compoundAccessKind) { 1418 switch (compoundSemantics.compoundAccessKind) {
2027 case CompoundAccessKind.SUPER_GETTER_SETTER: 1419 case CompoundAccessKind.SUPER_GETTER_SETTER:
2028 return visitor.visitSuperIndexSetIfNull( 1420 return visitor.visitSuperIndexSetIfNull(
2029 node, 1421 node,
2030 compoundSemantics.getter, 1422 compoundSemantics.getter,
2031 compoundSemantics.setter, 1423 compoundSemantics.setter,
2032 node.arguments.first, 1424 node.arguments.first,
2033 node.arguments.tail.head, 1425 node.arguments.tail.head,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 1458
2067 /// The structure for a [Send] that is a prefix operations. For instance 1459 /// The structure for a [Send] that is a prefix operations. For instance
2068 /// `++a`. 1460 /// `++a`.
2069 class PrefixStructure<R, A> implements SendStructure<R, A> { 1461 class PrefixStructure<R, A> implements SendStructure<R, A> {
2070 /// The target of the prefix operation. 1462 /// The target of the prefix operation.
2071 final AccessSemantics semantics; 1463 final AccessSemantics semantics;
2072 1464
2073 /// The `++` or `--` operator used in the operation. 1465 /// The `++` or `--` operator used in the operation.
2074 final IncDecOperator operator; 1466 final IncDecOperator operator;
2075 1467
2076 PrefixStructure(this.semantics, 1468 PrefixStructure(this.semantics, this.operator);
2077 this.operator);
2078 1469
2079 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1470 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
2080 switch (semantics.kind) { 1471 switch (semantics.kind) {
2081 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 1472 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
2082 return visitor.visitIfNotNullDynamicPropertyPrefix( 1473 return visitor.visitIfNotNullDynamicPropertyPrefix(
2083 node, 1474 node, node.receiver, semantics.name, operator, arg);
2084 node.receiver,
2085 semantics.name,
2086 operator,
2087 arg);
2088 case AccessKind.DYNAMIC_PROPERTY: 1475 case AccessKind.DYNAMIC_PROPERTY:
2089 return visitor.visitDynamicPropertyPrefix( 1476 return visitor.visitDynamicPropertyPrefix(
2090 node, 1477 node, node.receiver, semantics.name, operator, arg);
2091 node.receiver,
2092 semantics.name,
2093 operator,
2094 arg);
2095 case AccessKind.LOCAL_FUNCTION: 1478 case AccessKind.LOCAL_FUNCTION:
2096 return visitor.visitLocalFunctionPrefix( 1479 return visitor.visitLocalFunctionPrefix(
2097 node, 1480 node, semantics.element, operator, arg);
2098 semantics.element,
2099 operator,
2100 arg);
2101 case AccessKind.LOCAL_VARIABLE: 1481 case AccessKind.LOCAL_VARIABLE:
2102 return visitor.visitLocalVariablePrefix( 1482 return visitor.visitLocalVariablePrefix(
2103 node, 1483 node, semantics.element, operator, arg);
2104 semantics.element,
2105 operator,
2106 arg);
2107 case AccessKind.FINAL_LOCAL_VARIABLE: 1484 case AccessKind.FINAL_LOCAL_VARIABLE:
2108 return visitor.visitFinalLocalVariablePrefix( 1485 return visitor.visitFinalLocalVariablePrefix(
2109 node, 1486 node, semantics.element, operator, arg);
2110 semantics.element,
2111 operator,
2112 arg);
2113 case AccessKind.PARAMETER: 1487 case AccessKind.PARAMETER:
2114 return visitor.visitParameterPrefix( 1488 return visitor.visitParameterPrefix(
2115 node, 1489 node, semantics.element, operator, arg);
2116 semantics.element,
2117 operator,
2118 arg);
2119 case AccessKind.FINAL_PARAMETER: 1490 case AccessKind.FINAL_PARAMETER:
2120 return visitor.visitFinalParameterPrefix( 1491 return visitor.visitFinalParameterPrefix(
2121 node, 1492 node, semantics.element, operator, arg);
2122 semantics.element,
2123 operator,
2124 arg);
2125 case AccessKind.STATIC_FIELD: 1493 case AccessKind.STATIC_FIELD:
2126 return visitor.visitStaticFieldPrefix( 1494 return visitor.visitStaticFieldPrefix(
2127 node, 1495 node, semantics.element, operator, arg);
2128 semantics.element,
2129 operator,
2130 arg);
2131 case AccessKind.FINAL_STATIC_FIELD: 1496 case AccessKind.FINAL_STATIC_FIELD:
2132 return visitor.visitFinalStaticFieldPrefix( 1497 return visitor.visitFinalStaticFieldPrefix(
2133 node, 1498 node, semantics.element, operator, arg);
2134 semantics.element,
2135 operator,
2136 arg);
2137 case AccessKind.STATIC_METHOD: 1499 case AccessKind.STATIC_METHOD:
2138 return visitor.visitStaticMethodPrefix( 1500 return visitor.visitStaticMethodPrefix(
2139 node, 1501 node, semantics.element, operator, arg);
2140 semantics.element,
2141 operator,
2142 arg);
2143 case AccessKind.STATIC_GETTER: 1502 case AccessKind.STATIC_GETTER:
2144 // This is not a valid case. 1503 // This is not a valid case.
2145 break; 1504 break;
2146 case AccessKind.STATIC_SETTER: 1505 case AccessKind.STATIC_SETTER:
2147 // This is not a valid case. 1506 // This is not a valid case.
2148 break; 1507 break;
2149 case AccessKind.TOPLEVEL_FIELD: 1508 case AccessKind.TOPLEVEL_FIELD:
2150 return visitor.visitTopLevelFieldPrefix( 1509 return visitor.visitTopLevelFieldPrefix(
2151 node, 1510 node, semantics.element, operator, arg);
2152 semantics.element,
2153 operator,
2154 arg);
2155 case AccessKind.FINAL_TOPLEVEL_FIELD: 1511 case AccessKind.FINAL_TOPLEVEL_FIELD:
2156 return visitor.visitFinalTopLevelFieldPrefix( 1512 return visitor.visitFinalTopLevelFieldPrefix(
2157 node, 1513 node, semantics.element, operator, arg);
2158 semantics.element,
2159 operator,
2160 arg);
2161 case AccessKind.TOPLEVEL_METHOD: 1514 case AccessKind.TOPLEVEL_METHOD:
2162 return visitor.visitTopLevelMethodPrefix( 1515 return visitor.visitTopLevelMethodPrefix(
2163 node, 1516 node, semantics.element, operator, arg);
2164 semantics.element,
2165 operator,
2166 arg);
2167 case AccessKind.TOPLEVEL_GETTER: 1517 case AccessKind.TOPLEVEL_GETTER:
2168 // This is not a valid case. 1518 // This is not a valid case.
2169 break; 1519 break;
2170 case AccessKind.TOPLEVEL_SETTER: 1520 case AccessKind.TOPLEVEL_SETTER:
2171 // This is not a valid case. 1521 // This is not a valid case.
2172 break; 1522 break;
2173 case AccessKind.CLASS_TYPE_LITERAL: 1523 case AccessKind.CLASS_TYPE_LITERAL:
2174 return visitor.visitClassTypeLiteralPrefix( 1524 return visitor.visitClassTypeLiteralPrefix(
2175 node, 1525 node, semantics.constant, operator, arg);
2176 semantics.constant,
2177 operator,
2178 arg);
2179 case AccessKind.TYPEDEF_TYPE_LITERAL: 1526 case AccessKind.TYPEDEF_TYPE_LITERAL:
2180 return visitor.visitTypedefTypeLiteralPrefix( 1527 return visitor.visitTypedefTypeLiteralPrefix(
2181 node, 1528 node, semantics.constant, operator, arg);
2182 semantics.constant,
2183 operator,
2184 arg);
2185 case AccessKind.DYNAMIC_TYPE_LITERAL: 1529 case AccessKind.DYNAMIC_TYPE_LITERAL:
2186 return visitor.visitDynamicTypeLiteralPrefix( 1530 return visitor.visitDynamicTypeLiteralPrefix(
2187 node, 1531 node, semantics.constant, operator, arg);
2188 semantics.constant,
2189 operator,
2190 arg);
2191 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 1532 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
2192 return visitor.visitTypeVariableTypeLiteralPrefix( 1533 return visitor.visitTypeVariableTypeLiteralPrefix(
2193 node, 1534 node, semantics.element, operator, arg);
2194 semantics.element,
2195 operator,
2196 arg);
2197 case AccessKind.EXPRESSION: 1535 case AccessKind.EXPRESSION:
2198 // This is not a valid case. 1536 // This is not a valid case.
2199 break; 1537 break;
2200 case AccessKind.THIS: 1538 case AccessKind.THIS:
2201 // This is not a valid case. 1539 // This is not a valid case.
2202 break; 1540 break;
2203 case AccessKind.THIS_PROPERTY: 1541 case AccessKind.THIS_PROPERTY:
2204 return visitor.visitThisPropertyPrefix( 1542 return visitor.visitThisPropertyPrefix(
2205 node, 1543 node, semantics.name, operator, arg);
2206 semantics.name,
2207 operator,
2208 arg);
2209 case AccessKind.SUPER_FIELD: 1544 case AccessKind.SUPER_FIELD:
2210 return visitor.visitSuperFieldPrefix( 1545 return visitor.visitSuperFieldPrefix(
2211 node, 1546 node, semantics.element, operator, arg);
2212 semantics.element,
2213 operator,
2214 arg);
2215 case AccessKind.SUPER_FINAL_FIELD: 1547 case AccessKind.SUPER_FINAL_FIELD:
2216 return visitor.visitFinalSuperFieldPrefix( 1548 return visitor.visitFinalSuperFieldPrefix(
2217 node, 1549 node, semantics.element, operator, arg);
2218 semantics.element,
2219 operator,
2220 arg);
2221 case AccessKind.SUPER_METHOD: 1550 case AccessKind.SUPER_METHOD:
2222 return visitor.visitSuperMethodPrefix( 1551 return visitor.visitSuperMethodPrefix(
2223 node, 1552 node, semantics.element, operator, arg);
2224 semantics.element,
2225 operator,
2226 arg);
2227 case AccessKind.SUPER_GETTER: 1553 case AccessKind.SUPER_GETTER:
2228 // This is not a valid case. 1554 // This is not a valid case.
2229 break; 1555 break;
2230 case AccessKind.SUPER_SETTER: 1556 case AccessKind.SUPER_SETTER:
2231 // This is not a valid case. 1557 // This is not a valid case.
2232 break; 1558 break;
2233 case AccessKind.CONSTANT: 1559 case AccessKind.CONSTANT:
2234 // TODO(johnniwinther): Should this be a valid case? 1560 // TODO(johnniwinther): Should this be a valid case?
2235 break; 1561 break;
2236 case AccessKind.UNRESOLVED_SUPER: 1562 case AccessKind.UNRESOLVED_SUPER:
2237 return visitor.visitUnresolvedSuperPrefix( 1563 return visitor.visitUnresolvedSuperPrefix(
2238 node, 1564 node, semantics.element, operator, arg);
2239 semantics.element,
2240 operator,
2241 arg);
2242 case AccessKind.UNRESOLVED: 1565 case AccessKind.UNRESOLVED:
2243 return visitor.visitUnresolvedPrefix( 1566 return visitor.visitUnresolvedPrefix(
2244 node, 1567 node, semantics.element, operator, arg);
2245 semantics.element,
2246 operator,
2247 arg);
2248 case AccessKind.INVALID: 1568 case AccessKind.INVALID:
2249 return visitor.errorInvalidPrefix( 1569 return visitor.errorInvalidPrefix(
2250 node, 1570 node, semantics.element, operator, arg);
2251 semantics.element,
2252 operator,
2253 arg);
2254 case AccessKind.COMPOUND: 1571 case AccessKind.COMPOUND:
2255 CompoundAccessSemantics compoundSemantics = semantics; 1572 CompoundAccessSemantics compoundSemantics = semantics;
2256 switch (compoundSemantics.compoundAccessKind) { 1573 switch (compoundSemantics.compoundAccessKind) {
2257 case CompoundAccessKind.STATIC_GETTER_SETTER: 1574 case CompoundAccessKind.STATIC_GETTER_SETTER:
2258 return visitor.visitStaticGetterSetterPrefix( 1575 return visitor.visitStaticGetterSetterPrefix(
2259 node, 1576 node,
2260 compoundSemantics.getter, 1577 compoundSemantics.getter,
2261 compoundSemantics.setter, 1578 compoundSemantics.setter,
2262 operator, 1579 operator,
2263 arg); 1580 arg);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2361 arg); 1678 arg);
2362 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: 1679 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
2363 return visitor.visitUnresolvedSuperSetterPrefix( 1680 return visitor.visitUnresolvedSuperSetterPrefix(
2364 node, 1681 node,
2365 compoundSemantics.getter, 1682 compoundSemantics.getter,
2366 compoundSemantics.setter, 1683 compoundSemantics.setter,
2367 operator, 1684 operator,
2368 arg); 1685 arg);
2369 } 1686 }
2370 } 1687 }
2371 throw new SpannableAssertionFailure(node, 1688 throw new SpannableAssertionFailure(
2372 "Invalid compound assigment: ${semantics}"); 1689 node, "Invalid compound assigment: ${semantics}");
2373 } 1690 }
2374 1691
2375 String toString() => 'prefix($operator,$semantics)'; 1692 String toString() => 'prefix($operator,$semantics)';
2376 } 1693 }
2377 1694
2378 /// The structure for a [Send] that is a postfix operations. For instance 1695 /// The structure for a [Send] that is a postfix operations. For instance
2379 /// `a++`. 1696 /// `a++`.
2380 class PostfixStructure<R, A> implements SendStructure<R, A> { 1697 class PostfixStructure<R, A> implements SendStructure<R, A> {
2381 /// The target of the postfix operation. 1698 /// The target of the postfix operation.
2382 final AccessSemantics semantics; 1699 final AccessSemantics semantics;
2383 1700
2384 /// The `++` or `--` operator used in the operation. 1701 /// The `++` or `--` operator used in the operation.
2385 final IncDecOperator operator; 1702 final IncDecOperator operator;
2386 1703
2387 PostfixStructure(this.semantics, 1704 PostfixStructure(this.semantics, this.operator);
2388 this.operator);
2389 1705
2390 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1706 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
2391 switch (semantics.kind) { 1707 switch (semantics.kind) {
2392 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: 1708 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY:
2393 return visitor.visitIfNotNullDynamicPropertyPostfix( 1709 return visitor.visitIfNotNullDynamicPropertyPostfix(
2394 node, 1710 node, node.receiver, semantics.name, operator, arg);
2395 node.receiver,
2396 semantics.name,
2397 operator,
2398 arg);
2399 case AccessKind.DYNAMIC_PROPERTY: 1711 case AccessKind.DYNAMIC_PROPERTY:
2400 return visitor.visitDynamicPropertyPostfix( 1712 return visitor.visitDynamicPropertyPostfix(
2401 node, 1713 node, node.receiver, semantics.name, operator, arg);
2402 node.receiver,
2403 semantics.name,
2404 operator,
2405 arg);
2406 case AccessKind.LOCAL_FUNCTION: 1714 case AccessKind.LOCAL_FUNCTION:
2407 return visitor.visitLocalFunctionPostfix( 1715 return visitor.visitLocalFunctionPostfix(
2408 node, 1716 node, semantics.element, operator, arg);
2409 semantics.element,
2410 operator,
2411 arg);
2412 case AccessKind.LOCAL_VARIABLE: 1717 case AccessKind.LOCAL_VARIABLE:
2413 return visitor.visitLocalVariablePostfix( 1718 return visitor.visitLocalVariablePostfix(
2414 node, 1719 node, semantics.element, operator, arg);
2415 semantics.element,
2416 operator,
2417 arg);
2418 case AccessKind.FINAL_LOCAL_VARIABLE: 1720 case AccessKind.FINAL_LOCAL_VARIABLE:
2419 return visitor.visitFinalLocalVariablePostfix( 1721 return visitor.visitFinalLocalVariablePostfix(
2420 node, 1722 node, semantics.element, operator, arg);
2421 semantics.element,
2422 operator,
2423 arg);
2424 case AccessKind.PARAMETER: 1723 case AccessKind.PARAMETER:
2425 return visitor.visitParameterPostfix( 1724 return visitor.visitParameterPostfix(
2426 node, 1725 node, semantics.element, operator, arg);
2427 semantics.element,
2428 operator,
2429 arg);
2430 case AccessKind.FINAL_PARAMETER: 1726 case AccessKind.FINAL_PARAMETER:
2431 return visitor.visitFinalParameterPostfix( 1727 return visitor.visitFinalParameterPostfix(
2432 node, 1728 node, semantics.element, operator, arg);
2433 semantics.element,
2434 operator,
2435 arg);
2436 case AccessKind.STATIC_FIELD: 1729 case AccessKind.STATIC_FIELD:
2437 return visitor.visitStaticFieldPostfix( 1730 return visitor.visitStaticFieldPostfix(
2438 node, 1731 node, semantics.element, operator, arg);
2439 semantics.element,
2440 operator,
2441 arg);
2442 case AccessKind.FINAL_STATIC_FIELD: 1732 case AccessKind.FINAL_STATIC_FIELD:
2443 return visitor.visitFinalStaticFieldPostfix( 1733 return visitor.visitFinalStaticFieldPostfix(
2444 node, 1734 node, semantics.element, operator, arg);
2445 semantics.element,
2446 operator,
2447 arg);
2448 case AccessKind.STATIC_METHOD: 1735 case AccessKind.STATIC_METHOD:
2449 return visitor.visitStaticMethodPostfix( 1736 return visitor.visitStaticMethodPostfix(
2450 node, 1737 node, semantics.element, operator, arg);
2451 semantics.element,
2452 operator,
2453 arg);
2454 case AccessKind.STATIC_GETTER: 1738 case AccessKind.STATIC_GETTER:
2455 // This is not a valid case. 1739 // This is not a valid case.
2456 break; 1740 break;
2457 case AccessKind.STATIC_SETTER: 1741 case AccessKind.STATIC_SETTER:
2458 // This is not a valid case. 1742 // This is not a valid case.
2459 break; 1743 break;
2460 case AccessKind.TOPLEVEL_FIELD: 1744 case AccessKind.TOPLEVEL_FIELD:
2461 return visitor.visitTopLevelFieldPostfix( 1745 return visitor.visitTopLevelFieldPostfix(
2462 node, 1746 node, semantics.element, operator, arg);
2463 semantics.element,
2464 operator,
2465 arg);
2466 case AccessKind.FINAL_TOPLEVEL_FIELD: 1747 case AccessKind.FINAL_TOPLEVEL_FIELD:
2467 return visitor.visitFinalTopLevelFieldPostfix( 1748 return visitor.visitFinalTopLevelFieldPostfix(
2468 node, 1749 node, semantics.element, operator, arg);
2469 semantics.element,
2470 operator,
2471 arg);
2472 case AccessKind.TOPLEVEL_METHOD: 1750 case AccessKind.TOPLEVEL_METHOD:
2473 return visitor.visitTopLevelMethodPostfix( 1751 return visitor.visitTopLevelMethodPostfix(
2474 node, 1752 node, semantics.element, operator, arg);
2475 semantics.element,
2476 operator,
2477 arg);
2478 case AccessKind.TOPLEVEL_GETTER: 1753 case AccessKind.TOPLEVEL_GETTER:
2479 // This is not a valid case. 1754 // This is not a valid case.
2480 break; 1755 break;
2481 case AccessKind.TOPLEVEL_SETTER: 1756 case AccessKind.TOPLEVEL_SETTER:
2482 // This is not a valid case. 1757 // This is not a valid case.
2483 break; 1758 break;
2484 case AccessKind.CLASS_TYPE_LITERAL: 1759 case AccessKind.CLASS_TYPE_LITERAL:
2485 return visitor.visitClassTypeLiteralPostfix( 1760 return visitor.visitClassTypeLiteralPostfix(
2486 node, 1761 node, semantics.constant, operator, arg);
2487 semantics.constant,
2488 operator,
2489 arg);
2490 case AccessKind.TYPEDEF_TYPE_LITERAL: 1762 case AccessKind.TYPEDEF_TYPE_LITERAL:
2491 return visitor.visitTypedefTypeLiteralPostfix( 1763 return visitor.visitTypedefTypeLiteralPostfix(
2492 node, 1764 node, semantics.constant, operator, arg);
2493 semantics.constant,
2494 operator,
2495 arg);
2496 case AccessKind.DYNAMIC_TYPE_LITERAL: 1765 case AccessKind.DYNAMIC_TYPE_LITERAL:
2497 return visitor.visitDynamicTypeLiteralPostfix( 1766 return visitor.visitDynamicTypeLiteralPostfix(
2498 node, 1767 node, semantics.constant, operator, arg);
2499 semantics.constant,
2500 operator,
2501 arg);
2502 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: 1768 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL:
2503 return visitor.visitTypeVariableTypeLiteralPostfix( 1769 return visitor.visitTypeVariableTypeLiteralPostfix(
2504 node, 1770 node, semantics.element, operator, arg);
2505 semantics.element,
2506 operator,
2507 arg);
2508 case AccessKind.EXPRESSION: 1771 case AccessKind.EXPRESSION:
2509 // This is not a valid case. 1772 // This is not a valid case.
2510 break; 1773 break;
2511 case AccessKind.THIS: 1774 case AccessKind.THIS:
2512 // This is not a valid case. 1775 // This is not a valid case.
2513 break; 1776 break;
2514 case AccessKind.THIS_PROPERTY: 1777 case AccessKind.THIS_PROPERTY:
2515 return visitor.visitThisPropertyPostfix( 1778 return visitor.visitThisPropertyPostfix(
2516 node, 1779 node, semantics.name, operator, arg);
2517 semantics.name,
2518 operator,
2519 arg);
2520 case AccessKind.SUPER_FIELD: 1780 case AccessKind.SUPER_FIELD:
2521 return visitor.visitSuperFieldPostfix( 1781 return visitor.visitSuperFieldPostfix(
2522 node, 1782 node, semantics.element, operator, arg);
2523 semantics.element,
2524 operator,
2525 arg);
2526 case AccessKind.SUPER_FINAL_FIELD: 1783 case AccessKind.SUPER_FINAL_FIELD:
2527 return visitor.visitFinalSuperFieldPostfix( 1784 return visitor.visitFinalSuperFieldPostfix(
2528 node, 1785 node, semantics.element, operator, arg);
2529 semantics.element,
2530 operator,
2531 arg);
2532 case AccessKind.SUPER_METHOD: 1786 case AccessKind.SUPER_METHOD:
2533 return visitor.visitSuperMethodPostfix( 1787 return visitor.visitSuperMethodPostfix(
2534 node, 1788 node, semantics.element, operator, arg);
2535 semantics.element,
2536 operator,
2537 arg);
2538 case AccessKind.SUPER_GETTER: 1789 case AccessKind.SUPER_GETTER:
2539 // This is not a valid case. 1790 // This is not a valid case.
2540 break; 1791 break;
2541 case AccessKind.SUPER_SETTER: 1792 case AccessKind.SUPER_SETTER:
2542 // This is not a valid case. 1793 // This is not a valid case.
2543 break; 1794 break;
2544 case AccessKind.CONSTANT: 1795 case AccessKind.CONSTANT:
2545 // TODO(johnniwinther): Should this be a valid case? 1796 // TODO(johnniwinther): Should this be a valid case?
2546 break; 1797 break;
2547 case AccessKind.UNRESOLVED_SUPER: 1798 case AccessKind.UNRESOLVED_SUPER:
2548 return visitor.visitUnresolvedSuperPostfix( 1799 return visitor.visitUnresolvedSuperPostfix(
2549 node, 1800 node, semantics.element, operator, arg);
2550 semantics.element,
2551 operator,
2552 arg);
2553 case AccessKind.UNRESOLVED: 1801 case AccessKind.UNRESOLVED:
2554 return visitor.visitUnresolvedPostfix( 1802 return visitor.visitUnresolvedPostfix(
2555 node, 1803 node, semantics.element, operator, arg);
2556 semantics.element,
2557 operator,
2558 arg);
2559 case AccessKind.INVALID: 1804 case AccessKind.INVALID:
2560 return visitor.errorInvalidPostfix( 1805 return visitor.errorInvalidPostfix(
2561 node, 1806 node, semantics.element, operator, arg);
2562 semantics.element,
2563 operator,
2564 arg);
2565 case AccessKind.COMPOUND: 1807 case AccessKind.COMPOUND:
2566 CompoundAccessSemantics compoundSemantics = semantics; 1808 CompoundAccessSemantics compoundSemantics = semantics;
2567 switch (compoundSemantics.compoundAccessKind) { 1809 switch (compoundSemantics.compoundAccessKind) {
2568 case CompoundAccessKind.STATIC_GETTER_SETTER: 1810 case CompoundAccessKind.STATIC_GETTER_SETTER:
2569 return visitor.visitStaticGetterSetterPostfix( 1811 return visitor.visitStaticGetterSetterPostfix(
2570 node, 1812 node,
2571 compoundSemantics.getter, 1813 compoundSemantics.getter,
2572 compoundSemantics.setter, 1814 compoundSemantics.setter,
2573 operator, 1815 operator,
2574 arg); 1816 arg);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 arg); 1907 arg);
2666 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER: 1908 case CompoundAccessKind.UNRESOLVED_SUPER_SETTER:
2667 return visitor.visitUnresolvedSuperSetterPostfix( 1909 return visitor.visitUnresolvedSuperSetterPostfix(
2668 node, 1910 node,
2669 compoundSemantics.getter, 1911 compoundSemantics.getter,
2670 compoundSemantics.setter, 1912 compoundSemantics.setter,
2671 operator, 1913 operator,
2672 arg); 1914 arg);
2673 } 1915 }
2674 } 1916 }
2675 throw new SpannableAssertionFailure(node, 1917 throw new SpannableAssertionFailure(
2676 "Invalid compound assigment: ${semantics}"); 1918 node, "Invalid compound assigment: ${semantics}");
2677 } 1919 }
2678 1920
2679 String toString() => 'postfix($operator,$semantics)'; 1921 String toString() => 'postfix($operator,$semantics)';
2680 } 1922 }
2681 1923
2682
2683 /// The structure for a [Send] whose prefix is a prefix for a deferred library. 1924 /// The structure for a [Send] whose prefix is a prefix for a deferred library.
2684 /// For instance `deferred.a` where `deferred` is a deferred prefix. 1925 /// For instance `deferred.a` where `deferred` is a deferred prefix.
2685 class DeferredPrefixStructure<R, A> implements SendStructure<R, A> { 1926 class DeferredPrefixStructure<R, A> implements SendStructure<R, A> {
2686 /// The deferred prefix element. 1927 /// The deferred prefix element.
2687 final PrefixElement prefix; 1928 final PrefixElement prefix;
2688 1929
2689 /// The send structure for the whole [Send] node. For instance a 1930 /// The send structure for the whole [Send] node. For instance a
2690 /// [GetStructure] for `deferred.a` where `a` is a top level member of the 1931 /// [GetStructure] for `deferred.a` where `a` is a top level member of the
2691 /// deferred library. 1932 /// deferred library.
2692 final SendStructure sendStructure; 1933 final SendStructure sendStructure;
2693 1934
2694 DeferredPrefixStructure(this.prefix, this.sendStructure) { 1935 DeferredPrefixStructure(this.prefix, this.sendStructure) {
2695 assert(sendStructure != null); 1936 assert(sendStructure != null);
2696 } 1937 }
2697 1938
2698 @override 1939 @override
2699 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg) { 1940 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg) {
2700 visitor.previsitDeferredAccess(send, prefix, arg); 1941 visitor.previsitDeferredAccess(send, prefix, arg);
2701 return sendStructure.dispatch(visitor, send, arg); 1942 return sendStructure.dispatch(visitor, send, arg);
2702 } 1943 }
2703 } 1944 }
2704 1945
2705
2706 /// The structure for a [NewExpression] of a new invocation. 1946 /// The structure for a [NewExpression] of a new invocation.
2707 abstract class NewStructure<R, A> implements SemanticSendStructure<R, A> { 1947 abstract class NewStructure<R, A> implements SemanticSendStructure<R, A> {
2708 /// Calls the matching visit method on [visitor] with [node] and [arg]. 1948 /// Calls the matching visit method on [visitor] with [node] and [arg].
2709 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg); 1949 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg);
2710 } 1950 }
2711 1951
2712 /// The structure for a [NewExpression] of a new invocation. For instance 1952 /// The structure for a [NewExpression] of a new invocation. For instance
2713 /// `new C()`. 1953 /// `new C()`.
2714 class NewInvokeStructure<R, A> extends NewStructure<R, A> { 1954 class NewInvokeStructure<R, A> extends NewStructure<R, A> {
2715 final ConstructorAccessSemantics semantics; 1955 final ConstructorAccessSemantics semantics;
2716 final Selector selector; 1956 final Selector selector;
2717 1957
2718 NewInvokeStructure(this.semantics, this.selector); 1958 NewInvokeStructure(this.semantics, this.selector);
2719 1959
2720 CallStructure get callStructure => selector.callStructure; 1960 CallStructure get callStructure => selector.callStructure;
2721 1961
2722 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { 1962 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
2723 switch (semantics.kind) { 1963 switch (semantics.kind) {
2724 case ConstructorAccessKind.GENERATIVE: 1964 case ConstructorAccessKind.GENERATIVE:
2725 ConstructorElement constructor = semantics.element; 1965 ConstructorElement constructor = semantics.element;
2726 if (constructor.isRedirectingGenerative) { 1966 if (constructor.isRedirectingGenerative) {
2727 return visitor.visitRedirectingGenerativeConstructorInvoke( 1967 return visitor.visitRedirectingGenerativeConstructorInvoke(
2728 node, constructor, semantics.type, 1968 node,
2729 node.send.argumentsNode, callStructure, arg); 1969 constructor,
1970 semantics.type,
1971 node.send.argumentsNode,
1972 callStructure,
1973 arg);
2730 } 1974 }
2731 return visitor.visitGenerativeConstructorInvoke( 1975 return visitor.visitGenerativeConstructorInvoke(node, constructor,
2732 node, constructor, semantics.type, 1976 semantics.type, node.send.argumentsNode, callStructure, arg);
2733 node.send.argumentsNode, callStructure, arg);
2734 case ConstructorAccessKind.FACTORY: 1977 case ConstructorAccessKind.FACTORY:
2735 ConstructorElement constructor = semantics.element; 1978 ConstructorElement constructor = semantics.element;
2736 if (constructor.isRedirectingFactory) { 1979 if (constructor.isRedirectingFactory) {
2737 if (constructor.isEffectiveTargetMalformed) { 1980 if (constructor.isEffectiveTargetMalformed) {
2738 return visitor.visitUnresolvedRedirectingFactoryConstructorInvoke( 1981 return visitor.visitUnresolvedRedirectingFactoryConstructorInvoke(
2739 node, semantics.element, semantics.type, 1982 node,
2740 node.send.argumentsNode, callStructure, arg); 1983 semantics.element,
1984 semantics.type,
1985 node.send.argumentsNode,
1986 callStructure,
1987 arg);
2741 } 1988 }
2742 ConstructorElement effectiveTarget = constructor.effectiveTarget; 1989 ConstructorElement effectiveTarget = constructor.effectiveTarget;
2743 InterfaceType effectiveTargetType = 1990 InterfaceType effectiveTargetType =
2744 constructor.computeEffectiveTargetType(semantics.type); 1991 constructor.computeEffectiveTargetType(semantics.type);
2745 if (callStructure.signatureApplies( 1992 if (callStructure
2746 effectiveTarget.functionSignature)) { 1993 .signatureApplies(effectiveTarget.functionSignature)) {
2747 return visitor.visitRedirectingFactoryConstructorInvoke( 1994 return visitor.visitRedirectingFactoryConstructorInvoke(
2748 node, semantics.element, semantics.type, 1995 node,
2749 effectiveTarget, effectiveTargetType, 1996 semantics.element,
2750 node.send.argumentsNode, callStructure, arg); 1997 semantics.type,
1998 effectiveTarget,
1999 effectiveTargetType,
2000 node.send.argumentsNode,
2001 callStructure,
2002 arg);
2751 } else { 2003 } else {
2752 return visitor.visitUnresolvedRedirectingFactoryConstructorInvoke( 2004 return visitor.visitUnresolvedRedirectingFactoryConstructorInvoke(
2753 node, semantics.element, semantics.type, 2005 node,
2754 node.send.argumentsNode, callStructure, arg); 2006 semantics.element,
2007 semantics.type,
2008 node.send.argumentsNode,
2009 callStructure,
2010 arg);
2755 } 2011 }
2756 } 2012 }
2757 if (callStructure.signatureApplies(constructor.functionSignature)) { 2013 if (callStructure.signatureApplies(constructor.functionSignature)) {
2758 return visitor.visitFactoryConstructorInvoke( 2014 return visitor.visitFactoryConstructorInvoke(node, constructor,
2759 node, constructor, semantics.type, 2015 semantics.type, node.send.argumentsNode, callStructure, arg);
2760 node.send.argumentsNode, callStructure, arg);
2761 } 2016 }
2762 return visitor.visitConstructorIncompatibleInvoke( 2017 return visitor.visitConstructorIncompatibleInvoke(node, constructor,
2763 node, constructor, semantics.type, 2018 semantics.type, node.send.argumentsNode, callStructure, arg);
2764 node.send.argumentsNode, callStructure, arg);
2765 case ConstructorAccessKind.ABSTRACT: 2019 case ConstructorAccessKind.ABSTRACT:
2766 return visitor.visitAbstractClassConstructorInvoke( 2020 return visitor.visitAbstractClassConstructorInvoke(
2767 node, semantics.element, semantics.type, 2021 node,
2768 node.send.argumentsNode, callStructure, arg); 2022 semantics.element,
2023 semantics.type,
2024 node.send.argumentsNode,
2025 callStructure,
2026 arg);
2769 case ConstructorAccessKind.UNRESOLVED_CONSTRUCTOR: 2027 case ConstructorAccessKind.UNRESOLVED_CONSTRUCTOR:
2770 return visitor.visitUnresolvedConstructorInvoke( 2028 return visitor.visitUnresolvedConstructorInvoke(node, semantics.element,
2771 node, semantics.element, semantics.type, 2029 semantics.type, node.send.argumentsNode, selector, arg);
2772 node.send.argumentsNode, selector, arg);
2773 case ConstructorAccessKind.UNRESOLVED_TYPE: 2030 case ConstructorAccessKind.UNRESOLVED_TYPE:
2774 return visitor.visitUnresolvedClassConstructorInvoke( 2031 return visitor.visitUnresolvedClassConstructorInvoke(
2775 node, semantics.element, semantics.type, 2032 node,
2776 node.send.argumentsNode, selector, arg); 2033 semantics.element,
2034 semantics.type,
2035 node.send.argumentsNode,
2036 selector,
2037 arg);
2777 case ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR: 2038 case ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR:
2778 return visitor.errorNonConstantConstructorInvoke( 2039 return visitor.errorNonConstantConstructorInvoke(
2779 node, semantics.element, semantics.type, 2040 node,
2780 node.send.argumentsNode, callStructure, arg); 2041 semantics.element,
2042 semantics.type,
2043 node.send.argumentsNode,
2044 callStructure,
2045 arg);
2781 case ConstructorAccessKind.INCOMPATIBLE: 2046 case ConstructorAccessKind.INCOMPATIBLE:
2782 return visitor.visitConstructorIncompatibleInvoke( 2047 return visitor.visitConstructorIncompatibleInvoke(
2783 node, semantics.element, semantics.type, 2048 node,
2784 node.send.argumentsNode, callStructure, arg); 2049 semantics.element,
2050 semantics.type,
2051 node.send.argumentsNode,
2052 callStructure,
2053 arg);
2785 } 2054 }
2786 throw new SpannableAssertionFailure(node, 2055 throw new SpannableAssertionFailure(
2787 "Unhandled constructor invocation kind: ${semantics.kind}"); 2056 node, "Unhandled constructor invocation kind: ${semantics.kind}");
2788 } 2057 }
2789 2058
2790 String toString() => 'new($semantics,$selector)'; 2059 String toString() => 'new($semantics,$selector)';
2791 } 2060 }
2792 2061
2793 enum ConstantInvokeKind { 2062 enum ConstantInvokeKind {
2794 CONSTRUCTED, 2063 CONSTRUCTED,
2795 BOOL_FROM_ENVIRONMENT, 2064 BOOL_FROM_ENVIRONMENT,
2796 INT_FROM_ENVIRONMENT, 2065 INT_FROM_ENVIRONMENT,
2797 STRING_FROM_ENVIRONMENT, 2066 STRING_FROM_ENVIRONMENT,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { 2103 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
2835 Element element = elements[node.send]; 2104 Element element = elements[node.send];
2836 Selector selector = elements.getSelector(node.send); 2105 Selector selector = elements.getSelector(node.send);
2837 DartType type = elements.getType(node); 2106 DartType type = elements.getType(node);
2838 ConstantExpression constant = elements.getConstant(node); 2107 ConstantExpression constant = elements.getConstant(node);
2839 if (element.isMalformed || 2108 if (element.isMalformed ||
2840 constant == null || 2109 constant == null ||
2841 constant.kind == ConstantExpressionKind.ERRONEOUS) { 2110 constant.kind == ConstantExpressionKind.ERRONEOUS) {
2842 // This is a non-constant constant constructor invocation, like 2111 // This is a non-constant constant constructor invocation, like
2843 // `const Const(method())`. 2112 // `const Const(method())`.
2844 return visitor.errorNonConstantConstructorInvoke( 2113 return visitor.errorNonConstantConstructorInvoke(node, element, type,
2845 node, element, type,
2846 node.send.argumentsNode, selector.callStructure, arg); 2114 node.send.argumentsNode, selector.callStructure, arg);
2847 } else { 2115 } else {
2848 ConstantInvokeKind kind; 2116 ConstantInvokeKind kind;
2849 switch (constant.kind) { 2117 switch (constant.kind) {
2850 case ConstantExpressionKind.CONSTRUCTED: 2118 case ConstantExpressionKind.CONSTRUCTED:
2851 return visitor.visitConstConstructorInvoke(node, constant, arg); 2119 return visitor.visitConstConstructorInvoke(node, constant, arg);
2852 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT: 2120 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT:
2853 return visitor.visitBoolFromEnvironmentConstructorInvoke( 2121 return visitor.visitBoolFromEnvironmentConstructorInvoke(
2854 node, constant, arg); 2122 node, constant, arg);
2855 case ConstantExpressionKind.INT_FROM_ENVIRONMENT: 2123 case ConstantExpressionKind.INT_FROM_ENVIRONMENT:
(...skipping 19 matching lines...) Expand all
2875 ParameterStructure(this.definitions, this.node, this.parameter); 2143 ParameterStructure(this.definitions, this.node, this.parameter);
2876 2144
2877 /// Calls the matching visit method on [visitor] with [definitions] and [arg]. 2145 /// Calls the matching visit method on [visitor] with [definitions] and [arg].
2878 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg); 2146 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg);
2879 } 2147 }
2880 2148
2881 /// The structure of a required parameter declaration. 2149 /// The structure of a required parameter declaration.
2882 class RequiredParameterStructure<R, A> extends ParameterStructure<R, A> { 2150 class RequiredParameterStructure<R, A> extends ParameterStructure<R, A> {
2883 final int index; 2151 final int index;
2884 2152
2885 RequiredParameterStructure( 2153 RequiredParameterStructure(VariableDefinitions definitions, Node node,
2886 VariableDefinitions definitions, 2154 ParameterElement parameter, this.index)
2887 Node node,
2888 ParameterElement parameter,
2889 this.index)
2890 : super(definitions, node, parameter); 2155 : super(definitions, node, parameter);
2891 2156
2892 @override 2157 @override
2893 R dispatch(SemanticDeclarationVisitor<R, A> visitor, 2158 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
2894 A arg) {
2895 if (parameter.isInitializingFormal) { 2159 if (parameter.isInitializingFormal) {
2896 return visitor.visitInitializingFormalDeclaration( 2160 return visitor.visitInitializingFormalDeclaration(
2897 definitions, node, parameter, index, arg); 2161 definitions, node, parameter, index, arg);
2898 } else { 2162 } else {
2899 return visitor.visitParameterDeclaration( 2163 return visitor.visitParameterDeclaration(
2900 definitions, node, parameter, index, arg); 2164 definitions, node, parameter, index, arg);
2901 } 2165 }
2902 } 2166 }
2903 } 2167 }
2904 2168
2905 /// The structure of a optional positional parameter declaration. 2169 /// The structure of a optional positional parameter declaration.
2906 class OptionalParameterStructure<R, A> extends ParameterStructure<R, A> { 2170 class OptionalParameterStructure<R, A> extends ParameterStructure<R, A> {
2907 final ConstantExpression defaultValue; 2171 final ConstantExpression defaultValue;
2908 final int index; 2172 final int index;
2909 2173
2910 OptionalParameterStructure( 2174 OptionalParameterStructure(VariableDefinitions definitions, Node node,
2911 VariableDefinitions definitions, 2175 ParameterElement parameter, this.defaultValue, this.index)
2912 Node node, 2176 : super(definitions, node, parameter);
2913 ParameterElement parameter,
2914 this.defaultValue,
2915 this.index)
2916 : super(definitions, node, parameter);
2917 2177
2918 @override 2178 @override
2919 R dispatch(SemanticDeclarationVisitor<R, A> visitor, 2179 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
2920 A arg) {
2921 if (parameter.isInitializingFormal) { 2180 if (parameter.isInitializingFormal) {
2922 return visitor.visitOptionalInitializingFormalDeclaration( 2181 return visitor.visitOptionalInitializingFormalDeclaration(
2923 definitions, node, parameter, defaultValue, index, arg); 2182 definitions, node, parameter, defaultValue, index, arg);
2924 } else { 2183 } else {
2925 return visitor.visitOptionalParameterDeclaration( 2184 return visitor.visitOptionalParameterDeclaration(
2926 definitions, node, parameter, defaultValue, index, arg); 2185 definitions, node, parameter, defaultValue, index, arg);
2927 } 2186 }
2928 } 2187 }
2929 } 2188 }
2930 2189
2931 /// The structure of a optional named parameter declaration. 2190 /// The structure of a optional named parameter declaration.
2932 class NamedParameterStructure<R, A> extends ParameterStructure<R, A> { 2191 class NamedParameterStructure<R, A> extends ParameterStructure<R, A> {
2933 final ConstantExpression defaultValue; 2192 final ConstantExpression defaultValue;
2934 2193
2935 NamedParameterStructure( 2194 NamedParameterStructure(VariableDefinitions definitions, Node node,
2936 VariableDefinitions definitions, 2195 ParameterElement parameter, this.defaultValue)
2937 Node node,
2938 ParameterElement parameter,
2939 this.defaultValue)
2940 : super(definitions, node, parameter); 2196 : super(definitions, node, parameter);
2941 2197
2942 @override 2198 @override
2943 R dispatch(SemanticDeclarationVisitor<R, A> visitor, 2199 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
2944 A arg) {
2945 if (parameter.isInitializingFormal) { 2200 if (parameter.isInitializingFormal) {
2946 return visitor.visitNamedInitializingFormalDeclaration( 2201 return visitor.visitNamedInitializingFormalDeclaration(
2947 definitions, node, parameter, defaultValue, arg); 2202 definitions, node, parameter, defaultValue, arg);
2948 } else { 2203 } else {
2949 return visitor.visitNamedParameterDeclaration( 2204 return visitor.visitNamedParameterDeclaration(
2950 definitions, node, parameter, defaultValue, arg); 2205 definitions, node, parameter, defaultValue, arg);
2951 } 2206 }
2952 } 2207 }
2953 } 2208 }
2954 2209
2955
2956 enum VariableKind { 2210 enum VariableKind {
2957 TOP_LEVEL_FIELD, 2211 TOP_LEVEL_FIELD,
2958 STATIC_FIELD, 2212 STATIC_FIELD,
2959 INSTANCE_FIELD, 2213 INSTANCE_FIELD,
2960 LOCAL_VARIABLE, 2214 LOCAL_VARIABLE,
2961 } 2215 }
2962 2216
2963 abstract class VariableStructure<R, A> { 2217 abstract class VariableStructure<R, A> {
2964 final VariableKind kind; 2218 final VariableKind kind;
2965 final Node node; 2219 final Node node;
2966 final VariableElement variable; 2220 final VariableElement variable;
2967 2221
2968 VariableStructure(this.kind, this.node, this.variable); 2222 VariableStructure(this.kind, this.node, this.variable);
2969 2223
2970 R dispatch(SemanticDeclarationVisitor<R, A> visitor, 2224 R dispatch(SemanticDeclarationVisitor<R, A> visitor,
2971 VariableDefinitions definitions, 2225 VariableDefinitions definitions, A arg);
2972 A arg);
2973 } 2226 }
2974 2227
2975 class NonConstantVariableStructure<R, A> 2228 class NonConstantVariableStructure<R, A> extends VariableStructure<R, A> {
2976 extends VariableStructure<R, A> {
2977 NonConstantVariableStructure( 2229 NonConstantVariableStructure(
2978 VariableKind kind, Node node, VariableElement variable) 2230 VariableKind kind, Node node, VariableElement variable)
2979 : super(kind, node, variable); 2231 : super(kind, node, variable);
2980 2232
2981 R dispatch(SemanticDeclarationVisitor<R, A> visitor, 2233 R dispatch(SemanticDeclarationVisitor<R, A> visitor,
2982 VariableDefinitions definitions, 2234 VariableDefinitions definitions, A arg) {
2983 A arg) {
2984 switch (kind) { 2235 switch (kind) {
2985 case VariableKind.TOP_LEVEL_FIELD: 2236 case VariableKind.TOP_LEVEL_FIELD:
2986 return visitor.visitTopLevelFieldDeclaration( 2237 return visitor.visitTopLevelFieldDeclaration(
2987 definitions, node, variable, variable.initializer, arg); 2238 definitions, node, variable, variable.initializer, arg);
2988 case VariableKind.STATIC_FIELD: 2239 case VariableKind.STATIC_FIELD:
2989 return visitor.visitStaticFieldDeclaration( 2240 return visitor.visitStaticFieldDeclaration(
2990 definitions, node, variable, variable.initializer, arg); 2241 definitions, node, variable, variable.initializer, arg);
2991 case VariableKind.INSTANCE_FIELD: 2242 case VariableKind.INSTANCE_FIELD:
2992 return visitor.visitInstanceFieldDeclaration( 2243 return visitor.visitInstanceFieldDeclaration(
2993 definitions, node, variable, variable.initializer, arg); 2244 definitions, node, variable, variable.initializer, arg);
2994 case VariableKind.LOCAL_VARIABLE: 2245 case VariableKind.LOCAL_VARIABLE:
2995 return visitor.visitLocalVariableDeclaration( 2246 return visitor.visitLocalVariableDeclaration(
2996 definitions, node, variable, variable.initializer, arg); 2247 definitions, node, variable, variable.initializer, arg);
2997 } 2248 }
2998 } 2249 }
2999 } 2250 }
3000 2251
3001 class ConstantVariableStructure<R, A> 2252 class ConstantVariableStructure<R, A> extends VariableStructure<R, A> {
3002 extends VariableStructure<R, A> {
3003 final ConstantExpression constant; 2253 final ConstantExpression constant;
3004 2254
3005 ConstantVariableStructure( 2255 ConstantVariableStructure(
3006 VariableKind kind, Node node, VariableElement variable, this.constant) 2256 VariableKind kind, Node node, VariableElement variable, this.constant)
3007 : super(kind, node, variable); 2257 : super(kind, node, variable);
3008 2258
3009 R dispatch(SemanticDeclarationVisitor<R, A> visitor, 2259 R dispatch(SemanticDeclarationVisitor<R, A> visitor,
3010 VariableDefinitions definitions, 2260 VariableDefinitions definitions, A arg) {
3011 A arg) {
3012 switch (kind) { 2261 switch (kind) {
3013 case VariableKind.TOP_LEVEL_FIELD: 2262 case VariableKind.TOP_LEVEL_FIELD:
3014 return visitor.visitTopLevelConstantDeclaration( 2263 return visitor.visitTopLevelConstantDeclaration(
3015 definitions, node, variable, constant, arg); 2264 definitions, node, variable, constant, arg);
3016 case VariableKind.STATIC_FIELD: 2265 case VariableKind.STATIC_FIELD:
3017 return visitor.visitStaticConstantDeclaration( 2266 return visitor.visitStaticConstantDeclaration(
3018 definitions, node, variable, constant, arg); 2267 definitions, node, variable, constant, arg);
3019 case VariableKind.LOCAL_VARIABLE: 2268 case VariableKind.LOCAL_VARIABLE:
3020 return visitor.visitLocalConstantDeclaration( 2269 return visitor.visitLocalConstantDeclaration(
3021 definitions, node, variable, constant, arg); 2270 definitions, node, variable, constant, arg);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 ThisConstructorInvokeStructure( 2341 ThisConstructorInvokeStructure(
3093 this.node, this.constructor, this.callStructure); 2342 this.node, this.constructor, this.callStructure);
3094 2343
3095 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { 2344 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
3096 return visitor.visitThisConstructorInvoke( 2345 return visitor.visitThisConstructorInvoke(
3097 node, constructor, node.argumentsNode, callStructure, arg); 2346 node, constructor, node.argumentsNode, callStructure, arg);
3098 } 2347 }
3099 2348
3100 bool get isConstructorInvoke => true; 2349 bool get isConstructorInvoke => true;
3101 } 2350 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | pkg/compiler/lib/src/resolution/signatures.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698