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

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

Issue 1047673002: Add SemanticDeclVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More renaming Created 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js.semantics_visitor; 5 part of dart2js.semantics_visitor;
6 6
7 /// Mixin that implements all `errorX` methods of [SemanticSendVisitor] by 7 /// Mixin that implements all `errorX` methods of [SemanticSendVisitor] by
8 /// delegating to a bulk handler. 8 /// delegating to a bulk handler.
9 /// 9 ///
10 /// Use this mixin to provide a trivial implementation for all `errorX` methods. 10 /// Use this mixin to provide a trivial implementation for all `errorX` methods.
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 A arg) { 2264 A arg) {
2265 return bulkHandleNew(node, arg); 2265 return bulkHandleNew(node, arg);
2266 } 2266 }
2267 } 2267 }
2268 2268
2269 /// Visitor that implements [SemanticSendVisitor] by the use of `BulkX` mixins. 2269 /// Visitor that implements [SemanticSendVisitor] by the use of `BulkX` mixins.
2270 /// 2270 ///
2271 /// This class is useful in itself, but shows how to use the `BulkX` mixins and 2271 /// This class is useful in itself, but shows how to use the `BulkX` mixins and
2272 /// tests that the union of the `BulkX` mixins implement all `visit` and `error` 2272 /// tests that the union of the `BulkX` mixins implement all `visit` and `error`
2273 /// methods of [SemanticSendVisitor]. 2273 /// methods of [SemanticSendVisitor].
2274 class BulkVisitor<R, A> extends SemanticSendVisitor<R, A> 2274 class BulkSendVisitor<R, A> extends SemanticSendVisitor<R, A>
2275 with GetBulkMixin<R, A>, 2275 with GetBulkMixin<R, A>,
2276 SetBulkMixin<R, A>, 2276 SetBulkMixin<R, A>,
2277 ErrorBulkMixin<R, A>, 2277 ErrorBulkMixin<R, A>,
2278 InvokeBulkMixin<R, A>, 2278 InvokeBulkMixin<R, A>,
2279 IndexSetBulkMixin<R, A>, 2279 IndexSetBulkMixin<R, A>,
2280 CompoundBulkMixin<R, A>, 2280 CompoundBulkMixin<R, A>,
2281 UnaryBulkMixin<R, A>, 2281 UnaryBulkMixin<R, A>,
2282 BaseBulkMixin<R, A>, 2282 BaseBulkMixin<R, A>,
2283 BinaryBulkMixin<R, A>, 2283 BinaryBulkMixin<R, A>,
2284 PrefixBulkMixin<R, A>, 2284 PrefixBulkMixin<R, A>,
2285 PostfixBulkMixin<R, A>, 2285 PostfixBulkMixin<R, A>,
2286 NewBulkMixin<R, A> { 2286 NewBulkMixin<R, A> {
2287 @override 2287 @override
2288 R apply(Node node, A arg) { 2288 R apply(Node node, A arg) {
2289 throw new UnimplementedError("BulkVisitor.apply unimplemented"); 2289 throw new UnimplementedError("BulkSendVisitor.apply unimplemented");
2290 } 2290 }
2291 2291
2292 @override 2292 @override
2293 R bulkHandleNode(Node node, String message, A arg) { 2293 R bulkHandleNode(Node node, String message, A arg) {
2294 throw new UnimplementedError("BulkVisitor.bulkHandleNode unimplemented"); 2294 throw new UnimplementedError(
2295 } 2295 "BulkSendVisitor.bulkHandleNode unimplemented");
2296 } 2296 }
2297 }
2298
2299 /// Mixin that implements all `visitXParameterDecl` and
2300 /// `visitXInitializingFormalDecl` methods of [SemanticDeclarationVisitor]
2301 /// by delegating to a bulk handler.
2302 ///
2303 /// Use this mixin to provide a trivial implementation for these methods.
2304 abstract class ParameterBulkMixin<R, A>
2305 implements SemanticDeclarationVisitor<R, A> {
2306 R bulkHandleNode(Node node, String message, A arg);
2307
2308 R bulkHandleParameterDeclaration(VariableDefinitions node, A arg) {
2309 return bulkHandleNode(
2310 node, "Parameter declaration `$node` unhandled.", arg);
2311 }
2312
2313 @override
2314 R visitInitializingFormalDeclaration(
2315 VariableDefinitions node,
2316 Node definition,
2317 InitializingFormalElement parameter,
2318 int index,
2319 A arg) {
2320 return bulkHandleParameterDeclaration(node, arg);
2321 }
2322
2323 @override
2324 R visitNamedInitializingFormalDeclaration(
2325 VariableDefinitions node,
2326 Node definition,
2327 InitializingFormalElement parameter,
2328 ConstantExpression defaultValue,
2329 A arg) {
2330 return bulkHandleParameterDeclaration(node, arg);
2331 }
2332
2333 @override
2334 R visitNamedParameterDeclaration(
2335 VariableDefinitions node,
2336 Node definition,
2337 ParameterElement parameter,
2338 ConstantExpression defaultValue,
2339 A arg) {
2340 return bulkHandleParameterDeclaration(node, arg);
2341 }
2342
2343 @override
2344 R visitOptionalInitializingFormalDeclaration(
2345 VariableDefinitions node,
2346 Node definition,
2347 InitializingFormalElement parameter,
2348 ConstantExpression defaultValue,
2349 int index,
2350 A arg) {
2351 return bulkHandleParameterDeclaration(node, arg);
2352 }
2353
2354 @override
2355 R visitOptionalParameterDeclaration(
2356 VariableDefinitions node,
2357 Node definition,
2358 ParameterElement parameter,
2359 ConstantExpression defaultValue,
2360 int index,
2361 A arg) {
2362 return bulkHandleParameterDeclaration(node, arg);
2363 }
2364
2365 @override
2366 R visitParameterDeclaration(
2367 VariableDefinitions node,
2368 Node definition,
2369 ParameterElement parameter,
2370 int index,
2371 A arg) {
2372 return bulkHandleParameterDeclaration(node, arg);
2373 }
2374 }
2375
2376 /// Mixin that implements all `visitXConstructorDecl` methods of
2377 /// [SemanticDeclarationVisitor] by delegating to a bulk handler.
2378 ///
2379 /// Use this mixin to provide a trivial implementation for these methods.
2380 abstract class ConstructorBulkMixin<R, A>
2381 implements SemanticDeclarationVisitor<R, A> {
2382 R bulkHandleNode(Node node, String message, A arg);
2383
2384 R bulkHandleConstructorDeclaration(FunctionExpression node, A arg) {
2385 return bulkHandleNode(
2386 node, "Constructor declaration `$node` unhandled.", arg);
2387 }
2388
2389 @override
2390 R visitFactoryConstructorDeclaration(
2391 FunctionExpression node,
2392 ConstructorElement constructor,
2393 NodeList parameters,
2394 Node body,
2395 A arg) {
2396 return bulkHandleConstructorDeclaration(node, arg);
2397 }
2398
2399 @override
2400 R visitGenerativeConstructorDeclaration(
2401 FunctionExpression node,
2402 ConstructorElement constructor,
2403 NodeList parameters,
2404 NodeList initializers,
2405 Node body,
2406 A arg) {
2407 return bulkHandleConstructorDeclaration(node, arg);
2408 }
2409
2410 @override
2411 R visitRedirectingFactoryConstructorDeclaration(
2412 FunctionExpression node,
2413 ConstructorElement constructor,
2414 NodeList parameters,
2415 InterfaceType redirectionType,
2416 ConstructorElement redirectionTarget,
2417 A arg) {
2418 return bulkHandleConstructorDeclaration(node, arg);
2419 }
2420
2421 @override
2422 R visitRedirectingGenerativeConstructorDeclaration(
2423 FunctionExpression node,
2424 ConstructorElement constructor,
2425 NodeList parameters,
2426 NodeList initializers,
2427 A arg) {
2428 return bulkHandleConstructorDeclaration(node, arg);
2429 }
2430 }
2431
2432 /// Mixin that implements all constructor initializer visitor methods of
2433 /// [SemanticDeclarationVisitor] by delegating to a bulk handler.
2434 ///
2435 /// Use this mixin to provide a trivial implementation for these methods.
2436 abstract class InitializerBulkMixin<R, A>
2437 implements SemanticDeclarationVisitor<R, A> {
2438 R bulkHandleNode(Node node, String message, A arg);
2439
2440 R bulkHandleInitializer(Send node, A arg) {
2441 return bulkHandleNode(
2442 node, "Initializer `$node` unhandled.", arg);
2443 }
2444
2445 @override
2446 R errorUnresolvedFieldInitializer(
2447 SendSet node,
2448 Element element,
2449 Node initializer,
2450 A arg) {
2451 return bulkHandleInitializer(node, arg);
2452 }
2453
2454 @override
2455 R errorUnresolvedSuperConstructorInvoke(
2456 Send node,
2457 Element element,
2458 NodeList arguments,
2459 Selector selector,
2460 A arg) {
2461 return bulkHandleInitializer(node, arg);
2462 }
2463
2464 @override
2465 R errorUnresolvedThisConstructorInvoke(
2466 Send node,
2467 Element element,
2468 NodeList arguments,
2469 Selector selector,
2470 A arg) {
2471 return bulkHandleInitializer(node, arg);
2472 }
2473
2474 @override
2475 R visitFieldInitializer(
2476 SendSet node,
2477 FieldElement field,
2478 Node initializer,
2479 A arg) {
2480 return bulkHandleInitializer(node, arg);
2481 }
2482
2483 @override
2484 R visitSuperConstructorInvoke(
2485 Send node,
2486 ConstructorElement superConstructor,
2487 InterfaceType type,
2488 NodeList arguments,
2489 Selector selector,
2490 A arg) {
2491 return bulkHandleInitializer(node, arg);
2492 }
2493
2494 @override
2495 R visitThisConstructorInvoke(
2496 Send node,
2497 ConstructorElement thisConstructor,
2498 NodeList arguments,
2499 Selector selector,
2500 A arg) {
2501 return bulkHandleInitializer(node, arg);
2502 }
2503 }
2504
2505 /// Mixin that implements all function declaration visitor methods of
2506 /// [SemanticDeclarationVisitor] by delegating to a bulk handler.
2507 ///
2508 /// Use this mixin to provide a trivial implementation for these methods.
2509 abstract class FunctionBulkMixin<R, A>
2510 implements SemanticDeclarationVisitor<R, A> {
2511 R bulkHandleNode(Node node, String message, A arg);
2512
2513 R bulkHandleFunctionDeclaration(FunctionExpression node, A arg) {
2514 return bulkHandleNode(
2515 node, "Function declaration `$node` unhandled.", arg);
2516 }
2517
2518 @override
2519 R visitAbstractGetterDeclaration(
2520 FunctionExpression node,
2521 MethodElement getter,
2522 A arg) {
2523 return bulkHandleFunctionDeclaration(node, arg);
2524 }
2525
2526 @override
2527 R visitAbstractMethodDeclaration(
2528 FunctionExpression node,
2529 MethodElement method,
2530 NodeList parameters,
2531 A arg) {
2532 return bulkHandleFunctionDeclaration(node, arg);
2533 }
2534
2535 @override
2536 R visitAbstractSetterDeclaration(
2537 FunctionExpression node,
2538 MethodElement setter,
2539 NodeList parameters,
2540 A arg) {
2541 return bulkHandleFunctionDeclaration(node, arg);
2542 }
2543
2544 @override
2545 R visitClosureDeclaration(
2546 FunctionExpression node,
2547 LocalFunctionElement closure,
2548 NodeList parameters,
2549 Node body,
2550 A arg) {
2551 return bulkHandleFunctionDeclaration(node, arg);
2552 }
2553
2554 @override
2555 R visitInstanceGetterDeclaration(
2556 FunctionExpression node,
2557 MethodElement getter,
2558 Node body,
2559 A arg) {
2560 return bulkHandleFunctionDeclaration(node, arg);
2561 }
2562
2563 @override
2564 R visitInstanceMethodDeclaration(
2565 FunctionExpression node,
2566 MethodElement method,
2567 NodeList parameters,
2568 Node body,
2569 A arg) {
2570 return bulkHandleFunctionDeclaration(node, arg);
2571 }
2572
2573 @override
2574 R visitInstanceSetterDeclaration(
2575 FunctionExpression node,
2576 MethodElement setter,
2577 NodeList parameters,
2578 Node body,
2579 A arg) {
2580 return bulkHandleFunctionDeclaration(node, arg);
2581 }
2582
2583 @override
2584 R visitLocalFunctionDeclaration(
2585 FunctionExpression node,
2586 LocalFunctionElement function,
2587 NodeList parameters,
2588 Node body,
2589 A arg) {
2590 return bulkHandleFunctionDeclaration(node, arg);
2591 }
2592
2593 @override
2594 R visitStaticFunctionDeclaration(
2595 FunctionExpression node,
2596 MethodElement function,
2597 NodeList parameters,
2598 Node body,
2599 A arg) {
2600 return bulkHandleFunctionDeclaration(node, arg);
2601 }
2602
2603 @override
2604 R visitStaticGetterDeclaration(
2605 FunctionExpression node,
2606 MethodElement getter,
2607 Node body,
2608 A arg) {
2609 return bulkHandleFunctionDeclaration(node, arg);
2610 }
2611
2612 @override
2613 R visitStaticSetterDeclaration(
2614 FunctionExpression node,
2615 MethodElement setter,
2616 NodeList parameters,
2617 Node body,
2618 A arg) {
2619 return bulkHandleFunctionDeclaration(node, arg);
2620 }
2621
2622 @override
2623 R visitTopLevelFunctionDeclaration(
2624 FunctionExpression node,
2625 MethodElement function,
2626 NodeList parameters,
2627 Node body,
2628 A arg) {
2629 return bulkHandleFunctionDeclaration(node, arg);
2630 }
2631
2632 @override
2633 R visitTopLevelGetterDeclaration(
2634 FunctionExpression node,
2635 MethodElement getter,
2636 Node body,
2637 A arg) {
2638 return bulkHandleFunctionDeclaration(node, arg);
2639 }
2640
2641 @override
2642 R visitTopLevelSetterDeclaration(
2643 FunctionExpression node,
2644 MethodElement setter,
2645 NodeList parameters,
2646 Node body,
2647 A arg) {
2648 return bulkHandleFunctionDeclaration(node, arg);
2649 }
2650 }
2651
2652 /// Mixin that implements all variable/field declaration visitor methods of
2653 /// [SemanticDeclarationVisitor] by delegating to a bulk handler.
2654 ///
2655 /// Use this mixin to provide a trivial implementation for these methods.
2656 abstract class VariableBulkMixin<R, A>
2657 implements SemanticDeclarationVisitor<R, A> {
2658 R bulkHandleNode(Node node, String message, A arg);
2659
2660 R bulkHandleVariableDeclaration(VariableDefinitions node, A arg) {
2661 return bulkHandleNode(
2662 node, "Variable declaration `$node` unhandled.", arg);
2663 }
2664
2665 @override
2666 R visitInstanceFieldDeclaration(
2667 VariableDefinitions node,
2668 Node definition,
2669 FieldElement field,
2670 Node initializer,
2671 A arg) {
2672 return bulkHandleVariableDeclaration(node, arg);
2673 }
2674
2675 @override
2676 R visitLocalConstantDeclaration(
2677 VariableDefinitions node,
2678 Node definition,
2679 LocalVariableElement variable,
2680 ConstantExpression constant,
2681 A arg) {
2682 return bulkHandleVariableDeclaration(node, arg);
2683 }
2684
2685 @override
2686 R visitLocalVariableDeclaration(
2687 VariableDefinitions node,
2688 Node definition,
2689 LocalVariableElement variable,
2690 Node initializer,
2691 A arg) {
2692 return bulkHandleVariableDeclaration(node, arg);
2693 }
2694
2695 @override
2696 R visitStaticConstantDeclaration(
2697 VariableDefinitions node,
2698 Node definition,
2699 FieldElement field,
2700 ConstantExpression constant,
2701 A arg) {
2702 return bulkHandleVariableDeclaration(node, arg);
2703 }
2704
2705 @override
2706 R visitStaticFieldDeclaration(
2707 VariableDefinitions node,
2708 Node definition,
2709 FieldElement field,
2710 Node initializer,
2711 A arg) {
2712 return bulkHandleVariableDeclaration(node, arg);
2713 }
2714
2715 @override
2716 R visitTopLevelConstantDeclaration(
2717 VariableDefinitions node,
2718 Node definition,
2719 FieldElement field,
2720 ConstantExpression constant,
2721 A arg) {
2722 return bulkHandleVariableDeclaration(node, arg);
2723 }
2724
2725 @override
2726 R visitTopLevelFieldDeclaration(
2727 VariableDefinitions node,
2728 Node definition,
2729 FieldElement field,
2730 Node initializer,
2731 A arg) {
2732 return bulkHandleVariableDeclaration(node, arg);
2733 }
2734 }
2735
2736 /// Visitor that implements [SemanticDeclarationVisitor] by the use of `BulkX`
2737 /// mixins.
2738 ///
2739 /// This class is useful in itself, but shows how to use the `BulkX` mixins and
2740 /// tests that the union of the `BulkX` mixins implement all `visit` and `error`
2741 /// methods of [SemanticDeclarationVisitor].
2742 class BulkDeclarationVisitor<R, A> extends SemanticDeclarationVisitor<R, A>
2743 with ConstructorBulkMixin<R, A>,
2744 FunctionBulkMixin<R, A>,
2745 VariableBulkMixin<R, A>,
2746 ParameterBulkMixin<R, A>,
2747 InitializerBulkMixin<R, A> {
2748 @override
2749 R apply(Node node, A arg) {
2750 throw new UnimplementedError("BulkDeclVisitor.apply unimplemented");
2751 }
2752
2753 @override
2754 R bulkHandleNode(Node node, String message, A arg) {
2755 throw new UnimplementedError(
2756 "BulkDeclVisitor.bulkHandleNode unimplemented");
2757 }
2758
2759 @override
2760 applyInitializers(NodeList initializers, A arg) {
2761 throw new UnimplementedError(
2762 "BulkDeclVisitor.applyInitializers unimplemented");
2763 }
2764
2765 @override
2766 applyParameters(NodeList parameters, A arg) {
2767 throw new UnimplementedError(
2768 "BulkDeclVisitor.applyParameters unimplemented");
2769 }
2770 }
2771
2297 2772
2298 /// [SemanticSendVisitor] that visits subnodes. 2773 /// [SemanticSendVisitor] that visits subnodes.
2299 class TraversalMixin<R, A> implements SemanticSendVisitor<R, A> { 2774 class TraversalSendMixin<R, A> implements SemanticSendVisitor<R, A> {
2300 @override 2775 @override
2301 R apply(Node node, A arg) { 2776 R apply(Node node, A arg) {
2302 throw new UnimplementedError("TraversalMixin.apply unimplemented"); 2777 throw new UnimplementedError("TraversalMixin.apply unimplemented");
2303 } 2778 }
2304 2779
2305 @override 2780 @override
2306 R errorInvalidAssert( 2781 R errorInvalidAssert(
2307 Send node, 2782 Send node,
2308 NodeList arguments, 2783 NodeList arguments,
2309 A arg) { 2784 A arg) {
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 Send node, 4610 Send node,
4136 FunctionElement indexFunction, 4611 FunctionElement indexFunction,
4137 FunctionElement indexSetFunction, 4612 FunctionElement indexSetFunction,
4138 Node index, 4613 Node index,
4139 IncDecOperator operator, 4614 IncDecOperator operator,
4140 A arg) { 4615 A arg) {
4141 apply(index, arg); 4616 apply(index, arg);
4142 return null; 4617 return null;
4143 } 4618 }
4144 4619
4145 @override
4146 R visitConstConstructorInvoke( 4620 R visitConstConstructorInvoke(
4147 NewExpression node, 4621 NewExpression node,
4148 ConstructedConstantExpression constant, 4622 ConstructedConstantExpression constant,
4149 A arg) { 4623 A arg) {
4150 return null; 4624 return null;
4151 } 4625 }
4152 4626
4153 @override 4627 @override
4154 R errorUnresolvedClassConstructorInvoke( 4628 R errorUnresolvedClassConstructorInvoke(
4155 NewExpression node, 4629 NewExpression node,
(...skipping 10 matching lines...) Expand all
4166 R errorUnresolvedConstructorInvoke( 4640 R errorUnresolvedConstructorInvoke(
4167 NewExpression node, 4641 NewExpression node,
4168 Element constructor, 4642 Element constructor,
4169 DartType type, 4643 DartType type,
4170 NodeList arguments, 4644 NodeList arguments,
4171 Selector selector, 4645 Selector selector,
4172 A arg) { 4646 A arg) {
4173 apply(arguments, arg); 4647 apply(arguments, arg);
4174 return null; 4648 return null;
4175 } 4649 }
4650
4651 @override
4176 R visitFactoryConstructorInvoke( 4652 R visitFactoryConstructorInvoke(
4177 NewExpression node, 4653 NewExpression node,
4178 ConstructorElement constructor, 4654 ConstructorElement constructor,
4179 InterfaceType type, 4655 InterfaceType type,
4180 NodeList arguments, 4656 NodeList arguments,
4181 Selector selector, 4657 Selector selector,
4182 A arg) { 4658 A arg) {
4183 apply(arguments, arg); 4659 apply(arguments, arg);
4184 return null; 4660 return null;
4185 } 4661 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 ConstructorElement constructor, 4716 ConstructorElement constructor,
4241 InterfaceType type, 4717 InterfaceType type,
4242 NodeList arguments, 4718 NodeList arguments,
4243 Selector selector, 4719 Selector selector,
4244 A arg) { 4720 A arg) {
4245 apply(arguments, arg); 4721 apply(arguments, arg);
4246 return null; 4722 return null;
4247 } 4723 }
4248 } 4724 }
4249 4725
4726 /// [SemanticDeclarationVisitor] that visits subnodes.
4727 class TraversalDeclarationMixin<R, A>
4728 implements SemanticDeclarationVisitor<R, A> {
4729 @override
4730 R apply(Node node, A arg) {
4731 throw new UnimplementedError("TraversalMixin.apply unimplemented");
4732 }
4733
4734 @override
4735 applyInitializers(NodeList initializers, A arg) {
4736 throw new UnimplementedError(
4737 "TraversalMixin.applyInitializers unimplemented");
4738 }
4739
4740 @override
4741 applyParameters(NodeList parameters, A arg) {
4742 throw new UnimplementedError(
4743 "TraversalMixin.applyParameters unimplemented");
4744 }
4745
4746 @override
4747 R visitAbstractMethodDeclaration(
4748 FunctionExpression node,
4749 MethodElement method,
4750 NodeList parameters,
4751 A arg) {
4752 applyParameters(parameters, arg);
4753 return null;
4754 }
4755
4756 @override
4757 R visitClosureDeclaration(
4758 FunctionExpression node,
4759 LocalFunctionElement function,
4760 NodeList parameters,
4761 Node body,
4762 A arg) {
4763 applyParameters(parameters, arg);
4764 apply(body, arg);
4765 return null;
4766 }
4767
4768 @override
4769 R visitFactoryConstructorDeclaration(
4770 FunctionExpression node,
4771 ConstructorElement constructor,
4772 NodeList parameters,
4773 Node body,
4774 A arg) {
4775 applyParameters(parameters, arg);
4776 apply(body, arg);
4777 return null;
4778 }
4779
4780 @override
4781 R visitFieldInitializer(
4782 SendSet node,
4783 FieldElement field,
4784 Node initializer,
4785 A arg) {
4786 apply(initializer, arg);
4787 return null;
4788 }
4789
4790 @override
4791 R visitGenerativeConstructorDeclaration(
4792 FunctionExpression node,
4793 ConstructorElement constructor,
4794 NodeList parameters,
4795 NodeList initializers,
4796 Node body,
4797 A arg) {
4798 applyParameters(parameters, arg);
4799 applyInitializers(initializers, arg);
4800 apply(body, arg);
4801 return null;
4802 }
4803
4804 @override
4805 R visitInstanceMethodDeclaration(
4806 FunctionExpression node,
4807 MethodElement method,
4808 NodeList parameters,
4809 Node body,
4810 A arg) {
4811 applyParameters(parameters, arg);
4812 apply(body, arg);
4813 return null;
4814 }
4815
4816 @override
4817 R visitLocalFunctionDeclaration(
4818 FunctionExpression node,
4819 LocalFunctionElement function,
4820 NodeList parameters,
4821 Node body,
4822 A arg) {
4823 applyParameters(parameters, arg);
4824 apply(body, arg);
4825 return null;
4826 }
4827
4828 @override
4829 R visitRedirectingFactoryConstructorDeclaration(
4830 FunctionExpression node,
4831 ConstructorElement constructor,
4832 NodeList parameters,
4833 InterfaceType redirectionType,
4834 ConstructorElement redirectionTarget,
4835 A arg) {
4836 applyParameters(parameters, arg);
4837 return null;
4838 }
4839
4840 @override
4841 R visitRedirectingGenerativeConstructorDeclaration(
4842 FunctionExpression node,
4843 ConstructorElement constructor,
4844 NodeList parameters,
4845 NodeList initializers,
4846 A arg) {
4847 applyParameters(parameters, arg);
4848 applyInitializers(initializers, arg);
4849 return null;
4850 }
4851
4852 @override
4853 R visitStaticFunctionDeclaration(
4854 FunctionExpression node,
4855 MethodElement function,
4856 NodeList parameters,
4857 Node body,
4858 A arg) {
4859 applyParameters(parameters, arg);
4860 apply(body, arg);
4861 return null;
4862 }
4863
4864 @override
4865 R visitSuperConstructorInvoke(
4866 Send node,
4867 ConstructorElement superConstructor,
4868 InterfaceType type,
4869 NodeList arguments,
4870 Selector selector,
4871 A arg) {
4872 apply(arguments, arg);
4873 return null;
4874 }
4875
4876 @override
4877 R visitThisConstructorInvoke(
4878 Send node,
4879 ConstructorElement thisConstructor,
4880 NodeList arguments,
4881 Selector selector,
4882 A arg) {
4883 apply(arguments, arg);
4884 return null;
4885 }
4886
4887 @override
4888 R visitTopLevelFunctionDeclaration(
4889 FunctionExpression node,
4890 MethodElement function,
4891 NodeList parameters,
4892 Node body,
4893 A arg) {
4894 applyParameters(parameters, arg);
4895 apply(body, arg);
4896 return null;
4897 }
4898
4899 @override
4900 R errorUnresolvedFieldInitializer(
4901 SendSet node,
4902 Element element,
4903 Node initializer,
4904 A arg) {
4905 apply(initializer, arg);
4906 return null;
4907 }
4908
4909 @override
4910 R errorUnresolvedSuperConstructorInvoke(
4911 Send node,
4912 Element element,
4913 NodeList arguments,
4914 Selector selector,
4915 A arg) {
4916 apply(arguments, arg);
4917 return null;
4918 }
4919
4920 @override
4921 R errorUnresolvedThisConstructorInvoke(
4922 Send node,
4923 Element element,
4924 NodeList arguments,
4925 Selector selector,
4926 A arg) {
4927 apply(arguments, arg);
4928 return null;
4929 }
4930
4931 @override
4932 R visitLocalVariableDeclaration(
4933 VariableDefinitions node,
4934 Node definition,
4935 LocalVariableElement variable,
4936 Node initializer,
4937 A arg) {
4938 if (initializer != null) {
4939 apply(initializer, arg);
4940 }
4941 return null;
4942 }
4943
4944 @override
4945 R visitOptionalParameterDeclaration(
4946 VariableDefinitions node,
4947 Node definition,
4948 ParameterElement parameter,
4949 ConstantExpression defaultValue,
4950 int index,
4951 A arg) {
4952 return null;
4953 }
4954
4955 @override
4956 R visitParameterDeclaration(
4957 VariableDefinitions node,
4958 Node definition,
4959 ParameterElement parameter,
4960 int index,
4961 A arg) {
4962 return null;
4963 }
4964
4965 @override
4966 R visitInitializingFormalDeclaration(
4967 VariableDefinitions node,
4968 Node definition,
4969 InitializingFormalElement initializingFormal,
4970 int index,
4971 A arg) {
4972 return null;
4973 }
4974
4975 @override
4976 R visitLocalConstantDeclaration(
4977 VariableDefinitions node,
4978 Node definition,
4979 LocalVariableElement variable,
4980 ConstantExpression constant,
4981 A arg) {
4982 return null;
4983 }
4984
4985 @override
4986 R visitNamedInitializingFormalDeclaration(
4987 VariableDefinitions node,
4988 Node definition,
4989 InitializingFormalElement initializingFormal,
4990 ConstantExpression defaultValue,
4991 A arg) {
4992 return null;
4993 }
4994
4995 @override
4996 R visitNamedParameterDeclaration(
4997 VariableDefinitions node,
4998 Node definition,
4999 ParameterElement parameter,
5000 ConstantExpression defaultValue,
5001 A arg) {
5002 return null;
5003 }
5004
5005 @override
5006 R visitOptionalInitializingFormalDeclaration(
5007 VariableDefinitions node,
5008 Node definition,
5009 InitializingFormalElement initializingFormal,
5010 ConstantExpression defaultValue,
5011 int index,
5012 A arg) {
5013 return null;
5014 }
5015
5016 @override
5017 R visitInstanceFieldDeclaration(
5018 VariableDefinitions node,
5019 Node definition,
5020 FieldElement field,
5021 Node initializer,
5022 A arg) {
5023 if (initializer != null) {
5024 apply(initializer, arg);
5025 }
5026 return null;
5027 }
5028
5029 @override
5030 R visitStaticConstantDeclaration(
5031 VariableDefinitions node,
5032 Node definition,
5033 FieldElement field,
5034 ConstantExpression constant,
5035 A arg) {
5036 return null;
5037 }
5038
5039 @override
5040 R visitStaticFieldDeclaration(
5041 VariableDefinitions node,
5042 Node definition,
5043 FieldElement field,
5044 Node initializer,
5045 A arg) {
5046 if (initializer != null) {
5047 apply(initializer, arg);
5048 }
5049 return null;
5050 }
5051
5052 @override
5053 R visitTopLevelConstantDeclaration(
5054 VariableDefinitions node,
5055 Node definition,
5056 FieldElement field,
5057 ConstantExpression constant,
5058 A arg) {
5059 return null;
5060 }
5061
5062 @override
5063 R visitTopLevelFieldDeclaration(
5064 VariableDefinitions node,
5065 Node definition,
5066 FieldElement field,
5067 Node initializer,
5068 A arg) {
5069 if (initializer != null) {
5070 apply(initializer, arg);
5071 }
5072 return null;
5073 }
5074
5075 @override
5076 R visitAbstractGetterDeclaration(
5077 FunctionExpression node,
5078 MethodElement getter,
5079 A arg) {
5080 return null;
5081 }
5082
5083 @override
5084 R visitAbstractSetterDeclaration(
5085 FunctionExpression node,
5086 MethodElement setter,
5087 NodeList parameters,
5088 A arg) {
5089 applyParameters(parameters, arg);
5090 return null;
5091 }
5092
5093 @override
5094 R visitInstanceGetterDeclaration(
5095 FunctionExpression node,
5096 MethodElement getter,
5097 Node body,
5098 A arg) {
5099 apply(body, arg);
5100 return null;
5101 }
5102
5103 @override
5104 R visitInstanceSetterDeclaration(
5105 FunctionExpression node,
5106 MethodElement setter,
5107 NodeList parameters,
5108 Node body,
5109 A arg) {
5110 applyParameters(parameters, arg);
5111 apply(body, arg);
5112 return null;
5113 }
5114
5115 @override
5116 R visitStaticGetterDeclaration(
5117 FunctionExpression node,
5118 MethodElement getter,
5119 Node body,
5120 A arg) {
5121 apply(body, arg);
5122 return null;
5123 }
5124
5125 @override
5126 R visitStaticSetterDeclaration(
5127 FunctionExpression node,
5128 MethodElement setter,
5129 NodeList parameters,
5130 Node body,
5131 A arg) {
5132 applyParameters(parameters, arg);
5133 apply(body, arg);
5134 return null;
5135 }
5136
5137 @override
5138 R visitTopLevelGetterDeclaration(
5139 FunctionExpression node,
5140 MethodElement getter,
5141 Node body,
5142 A arg) {
5143 apply(body, arg);
5144 return null;
5145 }
5146
5147 @override
5148 R visitTopLevelSetterDeclaration(
5149 FunctionExpression node,
5150 MethodElement setter,
5151 NodeList parameters,
5152 Node body,
5153 A arg) {
5154 applyParameters(parameters, arg);
5155 apply(body, arg);
5156 return null;
5157 }
5158
5159 @override
5160 R visitConstConstructorInvoke(
5161 NewExpression node,
5162 ConstructedConstantExpression constant,
5163 A arg) {
5164 return null;
5165 }
5166
5167 @override
5168 R errorUnresolvedClassConstructorInvoke(
5169 NewExpression node,
5170 Element constructor,
5171 MalformedType type,
5172 NodeList arguments,
5173 Selector selector,
5174 A arg) {
5175 apply(arguments, arg);
5176 return null;
5177 }
5178
5179 @override
5180 R errorUnresolvedConstructorInvoke(
5181 NewExpression node,
5182 Element constructor,
5183 DartType type,
5184 NodeList arguments,
5185 Selector selector,
5186 A arg) {
5187 apply(arguments, arg);
5188 return null;
5189 }
5190 R visitFactoryConstructorInvoke(
5191 NewExpression node,
5192 ConstructorElement constructor,
5193 InterfaceType type,
5194 NodeList arguments,
5195 Selector selector,
5196 A arg) {
5197 apply(arguments, arg);
5198 return null;
5199 }
5200
5201 @override
5202 R visitGenerativeConstructorInvoke(
5203 NewExpression node,
5204 ConstructorElement constructor,
5205 InterfaceType type,
5206 NodeList arguments,
5207 Selector selector,
5208 A arg) {
5209 apply(arguments, arg);
5210 return null;
5211 }
5212
5213 @override
5214 R visitRedirectingFactoryConstructorInvoke(
5215 NewExpression node,
5216 ConstructorElement constructor,
5217 InterfaceType type,
5218 ConstructorElement effectiveTarget,
5219 InterfaceType effectiveTargetType,
5220 NodeList arguments,
5221 Selector selector,
5222 A arg) {
5223 apply(arguments, arg);
5224 return null;
5225 }
5226
5227 @override
5228 R visitRedirectingGenerativeConstructorInvoke(
5229 NewExpression node,
5230 ConstructorElement constructor,
5231 InterfaceType type,
5232 NodeList arguments,
5233 Selector selector,
5234 A arg) {
5235 apply(arguments, arg);
5236 return null;
5237 }
5238
5239 @override
5240 R errorAbstractClassConstructorInvoke(
5241 NewExpression node,
5242 ConstructorElement element,
5243 InterfaceType type,
5244 NodeList arguments,
5245 Selector selector,
5246 A arg) {
5247 apply(arguments, arg);
5248 return null;
5249 }
5250
5251 @override
5252 R errorUnresolvedRedirectingFactoryConstructorInvoke(
5253 NewExpression node,
5254 ConstructorElement constructor,
5255 InterfaceType type,
5256 NodeList arguments,
5257 Selector selector,
5258 A arg) {
5259 apply(arguments, arg);
5260 return null;
5261 }
5262 }
5263
4250 /// AST visitor that visits all normal [Send] and [SendSet] nodes using the 5264 /// AST visitor that visits all normal [Send] and [SendSet] nodes using the
4251 /// [SemanticVisitor]. 5265 /// [SemanticVisitor].
4252 class TraversalVisitor<R, A> extends SemanticVisitor<R, A> 5266 class TraversalVisitor<R, A> extends SemanticVisitor<R, A>
4253 with TraversalMixin<R, A> { 5267 with TraversalSendMixin<R, A>,
5268 TraversalDeclarationMixin<R, A> {
4254 TraversalVisitor(TreeElements elements) : super(elements); 5269 TraversalVisitor(TreeElements elements) : super(elements);
4255 5270
4256 SemanticSendVisitor<R, A> get sendVisitor => this; 5271 SemanticSendVisitor<R, A> get sendVisitor => this;
4257 5272
5273 SemanticDeclarationVisitor<R, A> get declVisitor => this;
5274
4258 R apply(Node node, A arg) { 5275 R apply(Node node, A arg) {
4259 node.accept(this); 5276 node.accept(this);
4260 return null; 5277 return null;
4261 } 5278 }
4262 5279
4263 @override 5280 @override
5281 applyInitializers(NodeList initializers, A arg) {
5282 visitInitializers(initializers, arg);
5283 }
5284
5285 @override
5286 applyParameters(NodeList parameters, A arg) {
5287 visitParameters(parameters, arg);
5288 }
5289
5290 @override
4264 internalError(Spannable spannable, String message) { 5291 internalError(Spannable spannable, String message) {
4265 throw new SpannableAssertionFailure(spannable, message); 5292 throw new SpannableAssertionFailure(spannable, message);
4266 } 5293 }
4267 5294
4268 @override 5295 @override
4269 R visitNode(Node node) { 5296 R visitNode(Node node) {
4270 node.visitChildren(this); 5297 node.visitChildren(this);
4271 return null; 5298 return null;
4272 } 5299 }
4273
4274 void visitParameters(NodeList parameters) {
4275
4276 }
4277
4278 void visitInitializers(NodeList initializers) {
4279 // TODO(johnniwinther): Visit subnodes of initializers.
4280 }
4281
4282 @override
4283 R visitFunctionExpression(FunctionExpression node) {
4284 if (node.parameters != null) {
4285 visitParameters(node.parameters);
4286 }
4287 if (node.initializers != null) {
4288 visitInitializers(node.initializers);
4289 }
4290 if (node.body != null) {
4291 apply(node.body, null);
4292 }
4293 return null;
4294 }
4295 } 5300 }
4296 5301
4297 /// Mixin that groups all `visitStaticX` and `visitTopLevelX` method by 5302 /// Mixin that groups all `visitStaticX` and `visitTopLevelX` method by
4298 /// delegating calls to `handleStaticX` methods. 5303 /// delegating calls to `handleStaticX` methods.
4299 /// 5304 ///
4300 /// This mixin is useful for the cases where both top level members and static 5305 /// This mixin is useful for the cases where both top level members and static
4301 /// class members are handled uniformly. 5306 /// class members are handled uniformly.
4302 abstract class BaseImplementationOfStaticsMixin<R, A> 5307 abstract class BaseImplementationOfStaticsMixin<R, A>
4303 implements SemanticSendVisitor<R, A> { 5308 implements SemanticSendVisitor<R, A> {
4304 R handleStaticFieldCompound( 5309 R handleStaticFieldCompound(
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
5483 InterfaceType type, 6488 InterfaceType type,
5484 ConstructorElement effectiveTarget, 6489 ConstructorElement effectiveTarget,
5485 InterfaceType effectiveTargetType, 6490 InterfaceType effectiveTargetType,
5486 NodeList arguments, 6491 NodeList arguments,
5487 Selector selector, 6492 Selector selector,
5488 A arg) { 6493 A arg) {
5489 return handleConstructorInvoke( 6494 return handleConstructorInvoke(
5490 node, constructor, type, arguments, selector, arg); 6495 node, constructor, type, arguments, selector, arg);
5491 } 6496 }
5492 } 6497 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/semantic_visitor.dart ('k') | pkg/compiler/lib/src/resolution/send_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698