OLD | NEW |
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 part of dart2js.semantics_visitor; | 5 part of dart2js.semantics_visitor; |
6 | 6 |
7 /// Interface for bulk handling of a [Node] in a semantic visitor. | 7 /// Interface for bulk handling of a [Node] in a semantic visitor. |
8 abstract class BulkHandle<R, A> { | 8 abstract class BulkHandle<R, A> { |
9 /// Handle [node] either regardless of semantics or to report that [node] is | 9 /// Handle [node] either regardless of semantics or to report that [node] is |
10 /// unhandled. [message] contains a message template for the latter case: | 10 /// unhandled. [message] contains a message template for the latter case: |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 @override | 27 @override |
28 R errorInvalidAssert( | 28 R errorInvalidAssert( |
29 Send node, | 29 Send node, |
30 NodeList arguments, | 30 NodeList arguments, |
31 A arg) { | 31 A arg) { |
32 return bulkHandleError(node, arg); | 32 return bulkHandleError(node, arg); |
33 } | 33 } |
34 | 34 |
35 @override | 35 @override |
36 R errorAbstractClassConstructorInvoke( | |
37 NewExpression node, | |
38 ConstructorElement element, | |
39 InterfaceType type, | |
40 NodeList arguments, | |
41 CallStructure callStructure, | |
42 A arg) { | |
43 return bulkHandleError(node, arg); | |
44 } | |
45 | |
46 @override | |
47 R errorClassTypeLiteralCompound( | 36 R errorClassTypeLiteralCompound( |
48 Send node, | 37 Send node, |
49 ConstantExpression constant, | 38 ConstantExpression constant, |
50 AssignmentOperator operator, | 39 AssignmentOperator operator, |
51 Node rhs, | 40 Node rhs, |
52 A arg) { | 41 A arg) { |
53 return bulkHandleError(node, arg); | 42 return bulkHandleError(node, arg); |
54 } | 43 } |
55 | 44 |
56 @override | 45 @override |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 @override | 233 @override |
245 R errorLocalFunctionSet( | 234 R errorLocalFunctionSet( |
246 SendSet node, | 235 SendSet node, |
247 LocalFunctionElement function, | 236 LocalFunctionElement function, |
248 Node rhs, | 237 Node rhs, |
249 A arg) { | 238 A arg) { |
250 return bulkHandleError(node, arg); | 239 return bulkHandleError(node, arg); |
251 } | 240 } |
252 | 241 |
253 @override | 242 @override |
| 243 R errorNonConstantConstructorInvoke( |
| 244 NewExpression node, |
| 245 Element element, |
| 246 InterfaceType type, |
| 247 NodeList arguments, |
| 248 CallStructure callStructure, |
| 249 A arg) { |
| 250 return bulkHandleError(node, arg); |
| 251 } |
| 252 |
| 253 @override |
254 R errorStaticFunctionSet( | 254 R errorStaticFunctionSet( |
255 Send node, | 255 Send node, |
256 MethodElement function, | 256 MethodElement function, |
257 Node rhs, | 257 Node rhs, |
258 A arg) { | 258 A arg) { |
259 return bulkHandleError(node, arg); | 259 return bulkHandleError(node, arg); |
260 } | 260 } |
261 | 261 |
262 @override | 262 @override |
263 R errorStaticGetterSet( | 263 R errorStaticGetterSet( |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 R errorUnresolvedCompound( | 436 R errorUnresolvedCompound( |
437 Send node, | 437 Send node, |
438 Element element, | 438 Element element, |
439 AssignmentOperator operator, | 439 AssignmentOperator operator, |
440 Node rhs, | 440 Node rhs, |
441 A arg) { | 441 A arg) { |
442 return bulkHandleError(node, arg); | 442 return bulkHandleError(node, arg); |
443 } | 443 } |
444 | 444 |
445 @override | 445 @override |
446 R errorUnresolvedClassConstructorInvoke( | |
447 NewExpression node, | |
448 Element element, | |
449 MalformedType type, | |
450 NodeList arguments, | |
451 Selector selector, | |
452 A arg) { | |
453 return bulkHandleError(node, arg); | |
454 } | |
455 | |
456 @override | |
457 R errorUnresolvedConstructorInvoke( | |
458 NewExpression node, | |
459 Element constructor, | |
460 DartType type, | |
461 NodeList arguments, | |
462 Selector selector, | |
463 A arg) { | |
464 return bulkHandleError(node, arg); | |
465 } | |
466 | |
467 @override | |
468 R errorUnresolvedPostfix( | 446 R errorUnresolvedPostfix( |
469 Send node, | 447 Send node, |
470 Element element, | 448 Element element, |
471 IncDecOperator operator, | 449 IncDecOperator operator, |
472 A arg) { | 450 A arg) { |
473 return bulkHandleError(node, arg); | 451 return bulkHandleError(node, arg); |
474 } | 452 } |
475 | 453 |
476 @override | 454 @override |
477 R errorUnresolvedPrefix( | 455 R errorUnresolvedPrefix( |
478 Send node, | 456 Send node, |
479 Element element, | 457 Element element, |
480 IncDecOperator operator, | 458 IncDecOperator operator, |
481 A arg) { | 459 A arg) { |
482 return bulkHandleError(node, arg); | 460 return bulkHandleError(node, arg); |
483 } | 461 } |
484 | 462 |
485 @override | 463 @override |
486 R errorUnresolvedRedirectingFactoryConstructorInvoke( | |
487 NewExpression node, | |
488 ConstructorElement constructor, | |
489 InterfaceType type, | |
490 NodeList arguments, | |
491 Selector selector, | |
492 A arg) { | |
493 return bulkHandleError(node, arg); | |
494 } | |
495 | |
496 @override | |
497 R errorUnresolvedSet( | 464 R errorUnresolvedSet( |
498 Send node, | 465 Send node, |
499 Element element, | 466 Element element, |
500 Node rhs, | 467 Node rhs, |
501 A arg) { | 468 A arg) { |
502 return bulkHandleError(node, arg); | 469 return bulkHandleError(node, arg); |
503 } | 470 } |
504 | 471 |
505 @override | 472 @override |
506 R errorUnresolvedSuperCompoundIndexSet( | 473 R errorUnresolvedSuperCompoundIndexSet( |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 | 2302 |
2336 abstract class NewBulkMixin<R, A> | 2303 abstract class NewBulkMixin<R, A> |
2337 implements SemanticSendVisitor<R, A>, BulkHandle<R, A> { | 2304 implements SemanticSendVisitor<R, A>, BulkHandle<R, A> { |
2338 | 2305 |
2339 R bulkHandleNew(NewExpression node, A arg) { | 2306 R bulkHandleNew(NewExpression node, A arg) { |
2340 return bulkHandleNode( | 2307 return bulkHandleNode( |
2341 node, "Constructor invocation `#` unhandled.", arg); | 2308 node, "Constructor invocation `#` unhandled.", arg); |
2342 } | 2309 } |
2343 | 2310 |
2344 @override | 2311 @override |
| 2312 R visitAbstractClassConstructorInvoke( |
| 2313 NewExpression node, |
| 2314 ConstructorElement element, |
| 2315 InterfaceType type, |
| 2316 NodeList arguments, |
| 2317 CallStructure callStructure, |
| 2318 A arg) { |
| 2319 return bulkHandleNew(node, arg); |
| 2320 } |
| 2321 |
| 2322 @override |
2345 R visitConstConstructorInvoke( | 2323 R visitConstConstructorInvoke( |
2346 NewExpression node, | 2324 NewExpression node, |
2347 ConstructedConstantExpression constant, | 2325 ConstructedConstantExpression constant, |
2348 A arg) { | 2326 A arg) { |
2349 return bulkHandleNew(node, arg); | 2327 return bulkHandleNew(node, arg); |
2350 } | 2328 } |
2351 | 2329 |
2352 R visitGenerativeConstructorInvoke( | 2330 R visitGenerativeConstructorInvoke( |
2353 NewExpression node, | 2331 NewExpression node, |
2354 ConstructorElement constructor, | 2332 ConstructorElement constructor, |
(...skipping 28 matching lines...) Expand all Loading... |
2383 NewExpression node, | 2361 NewExpression node, |
2384 ConstructorElement constructor, | 2362 ConstructorElement constructor, |
2385 InterfaceType type, | 2363 InterfaceType type, |
2386 ConstructorElement effectiveTarget, | 2364 ConstructorElement effectiveTarget, |
2387 InterfaceType effectiveTargetType, | 2365 InterfaceType effectiveTargetType, |
2388 NodeList arguments, | 2366 NodeList arguments, |
2389 CallStructure callStructure, | 2367 CallStructure callStructure, |
2390 A arg) { | 2368 A arg) { |
2391 return bulkHandleNew(node, arg); | 2369 return bulkHandleNew(node, arg); |
2392 } | 2370 } |
| 2371 |
| 2372 @override |
| 2373 R visitUnresolvedClassConstructorInvoke( |
| 2374 NewExpression node, |
| 2375 Element element, |
| 2376 DartType type, |
| 2377 NodeList arguments, |
| 2378 Selector selector, |
| 2379 A arg) { |
| 2380 return bulkHandleNew(node, arg); |
| 2381 } |
| 2382 |
| 2383 @override |
| 2384 R visitUnresolvedConstructorInvoke( |
| 2385 NewExpression node, |
| 2386 Element constructor, |
| 2387 DartType type, |
| 2388 NodeList arguments, |
| 2389 Selector selector, |
| 2390 A arg) { |
| 2391 return bulkHandleNew(node, arg); |
| 2392 } |
| 2393 |
| 2394 @override |
| 2395 R visitUnresolvedRedirectingFactoryConstructorInvoke( |
| 2396 NewExpression node, |
| 2397 ConstructorElement constructor, |
| 2398 InterfaceType type, |
| 2399 NodeList arguments, |
| 2400 CallStructure callStructure, |
| 2401 A arg) { |
| 2402 return bulkHandleNew(node, arg); |
| 2403 } |
2393 } | 2404 } |
2394 | 2405 |
2395 /// Visitor that implements [SemanticSendVisitor] by the use of `BulkX` mixins. | 2406 /// Visitor that implements [SemanticSendVisitor] by the use of `BulkX` mixins. |
2396 /// | 2407 /// |
2397 /// This class is useful in itself, but shows how to use the `BulkX` mixins and | 2408 /// This class is useful in itself, but shows how to use the `BulkX` mixins and |
2398 /// tests that the union of the `BulkX` mixins implement all `visit` and `error` | 2409 /// tests that the union of the `BulkX` mixins implement all `visit` and `error` |
2399 /// methods of [SemanticSendVisitor]. | 2410 /// methods of [SemanticSendVisitor]. |
2400 class BulkSendVisitor<R, A> extends SemanticSendVisitor<R, A> | 2411 class BulkSendVisitor<R, A> extends SemanticSendVisitor<R, A> |
2401 with GetBulkMixin<R, A>, | 2412 with GetBulkMixin<R, A>, |
2402 SetBulkMixin<R, A>, | 2413 SetBulkMixin<R, A>, |
(...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4791 } | 4802 } |
4792 | 4803 |
4793 R visitConstConstructorInvoke( | 4804 R visitConstConstructorInvoke( |
4794 NewExpression node, | 4805 NewExpression node, |
4795 ConstructedConstantExpression constant, | 4806 ConstructedConstantExpression constant, |
4796 A arg) { | 4807 A arg) { |
4797 return null; | 4808 return null; |
4798 } | 4809 } |
4799 | 4810 |
4800 @override | 4811 @override |
4801 R errorUnresolvedClassConstructorInvoke( | 4812 R visitUnresolvedClassConstructorInvoke( |
4802 NewExpression node, | 4813 NewExpression node, |
4803 Element constructor, | 4814 Element constructor, |
4804 MalformedType type, | 4815 DartType type, |
4805 NodeList arguments, | 4816 NodeList arguments, |
4806 Selector selector, | 4817 Selector selector, |
4807 A arg) { | 4818 A arg) { |
4808 apply(arguments, arg); | 4819 apply(arguments, arg); |
4809 return null; | 4820 return null; |
4810 } | 4821 } |
4811 | 4822 |
4812 @override | 4823 @override |
4813 R errorUnresolvedConstructorInvoke( | 4824 R visitUnresolvedConstructorInvoke( |
4814 NewExpression node, | 4825 NewExpression node, |
4815 Element constructor, | 4826 Element constructor, |
4816 DartType type, | 4827 DartType type, |
4817 NodeList arguments, | 4828 NodeList arguments, |
4818 Selector selector, | 4829 Selector selector, |
4819 A arg) { | 4830 A arg) { |
4820 apply(arguments, arg); | 4831 apply(arguments, arg); |
4821 return null; | 4832 return null; |
4822 } | 4833 } |
4823 | 4834 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4865 ConstructorElement constructor, | 4876 ConstructorElement constructor, |
4866 InterfaceType type, | 4877 InterfaceType type, |
4867 NodeList arguments, | 4878 NodeList arguments, |
4868 CallStructure callStructure, | 4879 CallStructure callStructure, |
4869 A arg) { | 4880 A arg) { |
4870 apply(arguments, arg); | 4881 apply(arguments, arg); |
4871 return null; | 4882 return null; |
4872 } | 4883 } |
4873 | 4884 |
4874 @override | 4885 @override |
4875 R errorAbstractClassConstructorInvoke( | 4886 R visitAbstractClassConstructorInvoke( |
4876 NewExpression node, | 4887 NewExpression node, |
4877 ConstructorElement element, | 4888 ConstructorElement element, |
4878 InterfaceType type, | 4889 InterfaceType type, |
4879 NodeList arguments, | 4890 NodeList arguments, |
4880 CallStructure callStructure, | 4891 CallStructure callStructure, |
4881 A arg) { | 4892 A arg) { |
4882 apply(arguments, arg); | 4893 apply(arguments, arg); |
4883 return null; | 4894 return null; |
4884 } | 4895 } |
4885 | 4896 |
4886 @override | 4897 @override |
4887 R errorUnresolvedRedirectingFactoryConstructorInvoke( | 4898 R visitUnresolvedRedirectingFactoryConstructorInvoke( |
4888 NewExpression node, | 4899 NewExpression node, |
4889 ConstructorElement constructor, | 4900 ConstructorElement constructor, |
4890 InterfaceType type, | 4901 InterfaceType type, |
4891 NodeList arguments, | 4902 NodeList arguments, |
4892 Selector selector, | 4903 CallStructure callStructure, |
4893 A arg) { | 4904 A arg) { |
4894 apply(arguments, arg); | 4905 apply(arguments, arg); |
4895 return null; | 4906 return null; |
| 4907 } |
| 4908 |
| 4909 @override |
| 4910 R errorNonConstantConstructorInvoke( |
| 4911 NewExpression node, |
| 4912 Element element, |
| 4913 InterfaceType type, |
| 4914 NodeList arguments, |
| 4915 CallStructure callStructure, |
| 4916 A arg) { |
| 4917 apply(arguments, arg); |
| 4918 return null; |
4896 } | 4919 } |
4897 } | 4920 } |
4898 | 4921 |
4899 /// [SemanticDeclarationVisitor] that visits subnodes. | 4922 /// [SemanticDeclarationVisitor] that visits subnodes. |
4900 class TraversalDeclarationMixin<R, A> | 4923 class TraversalDeclarationMixin<R, A> |
4901 implements SemanticDeclarationVisitor<R, A> { | 4924 implements SemanticDeclarationVisitor<R, A> { |
4902 @override | 4925 @override |
4903 R apply(Node node, A arg) { | 4926 R apply(Node node, A arg) { |
4904 throw new UnimplementedError("TraversalMixin.apply unimplemented"); | 4927 throw new UnimplementedError("TraversalMixin.apply unimplemented"); |
4905 } | 4928 } |
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6589 ConstructorElement constructor, | 6612 ConstructorElement constructor, |
6590 InterfaceType type, | 6613 InterfaceType type, |
6591 ConstructorElement effectiveTarget, | 6614 ConstructorElement effectiveTarget, |
6592 InterfaceType effectiveTargetType, | 6615 InterfaceType effectiveTargetType, |
6593 NodeList arguments, | 6616 NodeList arguments, |
6594 CallStructure callStructure, | 6617 CallStructure callStructure, |
6595 A arg) { | 6618 A arg) { |
6596 return handleConstructorInvoke( | 6619 return handleConstructorInvoke( |
6597 node, constructor, type, arguments, callStructure, arg); | 6620 node, constructor, type, arguments, callStructure, arg); |
6598 } | 6621 } |
| 6622 |
| 6623 R visitUnresolvedConstructorInvoke( |
| 6624 NewExpression node, |
| 6625 Element constructor, |
| 6626 DartType type, |
| 6627 NodeList arguments, |
| 6628 Selector selector, |
| 6629 A arg) { |
| 6630 return handleConstructorInvoke( |
| 6631 node, constructor, type, arguments, selector.callStructure, arg); |
| 6632 } |
| 6633 |
| 6634 R visitUnresolvedClassConstructorInvoke( |
| 6635 NewExpression node, |
| 6636 Element element, |
| 6637 DartType type, |
| 6638 NodeList arguments, |
| 6639 Selector selector, |
| 6640 A arg) { |
| 6641 return handleConstructorInvoke( |
| 6642 node, element, type, arguments, selector.callStructure, arg); |
| 6643 } |
| 6644 |
| 6645 R visitAbstractClassConstructorInvoke( |
| 6646 NewExpression node, |
| 6647 ConstructorElement constructor, |
| 6648 InterfaceType type, |
| 6649 NodeList arguments, |
| 6650 CallStructure callStructure, |
| 6651 A arg) { |
| 6652 return handleConstructorInvoke( |
| 6653 node, constructor, type, arguments, callStructure, arg); |
| 6654 } |
| 6655 R visitUnresolvedRedirectingFactoryConstructorInvoke( |
| 6656 NewExpression node, |
| 6657 ConstructorElement constructor, |
| 6658 InterfaceType type, |
| 6659 NodeList arguments, |
| 6660 CallStructure callStructure, |
| 6661 A arg) { |
| 6662 return handleConstructorInvoke( |
| 6663 node, constructor, type, arguments, callStructure, arg); |
| 6664 } |
6599 } | 6665 } |
OLD | NEW |