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

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

Issue 1047673002: Add SemanticDeclVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Correct long lines 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 library dart2js.semantics_visitor_test; 5 library dart2js.semantics_visitor_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/constants/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 ''', 2244 ''',
2245 const Visit( 2245 const Visit(
2246 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 2246 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
2247 element: 'function(Class#)', 2247 element: 'function(Class#)',
2248 arguments: '(true,42)', 2248 arguments: '(true,42)',
2249 type: 'Class', 2249 type: 'Class',
2250 selector: 'Selector(call, , arity=2)')), 2250 selector: 'Selector(call, , arity=2)')),
2251 ], 2251 ],
2252 }; 2252 };
2253 2253
2254 const Map<String, List<Test>> DECL_TESTS = const {
2255 'Function declarations': const [
2256 const Test(
2257 '''
2258 m(a, b) {}
2259 ''',
2260 const [
2261 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2262 element: 'function(m)',
2263 parameters: '(a,b)',
2264 body: '{}'),
2265 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2266 element: 'parameter(m#a)',
2267 index: 0),
2268 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2269 element: 'parameter(m#b)',
2270 index: 1),
2271 ]),
2272 const Test(
2273 '''
2274 m(a, [b]) {}
2275 ''',
2276 const [
2277 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2278 element: 'function(m)',
2279 parameters: '(a,[b])',
2280 body: '{}'),
2281 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2282 element: 'parameter(m#a)',
2283 index: 0),
2284 const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
2285 element: 'parameter(m#b)',
2286 index: 1),
2287 ]),
2288 const Test(
2289 '''
2290 m(a, [b = null]) {}
2291 ''',
2292 const [
2293 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2294 element: 'function(m)',
2295 parameters: '(a,[b=null])',
2296 body: '{}'),
2297 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2298 element: 'parameter(m#a)',
2299 index: 0),
2300 const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
2301 element: 'parameter(m#b)',
2302 constant: 'null',
2303 index: 1),
2304 ]),
2305 const Test(
2306 '''
2307 m(a, [b = 42]) {}
2308 ''',
2309 const [
2310 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2311 element: 'function(m)',
2312 parameters: '(a,[b=42])',
2313 body: '{}'),
2314 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2315 element: 'parameter(m#a)',
2316 index: 0),
2317 const Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
2318 element: 'parameter(m#b)',
2319 constant: 42,
2320 index: 1),
2321 ]),
2322 const Test(
2323 '''
2324 m(a, {b}) {}
2325 ''',
2326 const [
2327 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2328 element: 'function(m)',
2329 parameters: '(a,{b})',
2330 body: '{}'),
2331 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2332 element: 'parameter(m#a)',
2333 index: 0),
2334 const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
2335 element: 'parameter(m#b)'),
2336 ]),
2337 const Test(
2338 '''
2339 m(a, {b: null}) {}
2340 ''',
2341 const [
2342 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2343 element: 'function(m)',
2344 parameters: '(a,{b: null})',
2345 body: '{}'),
2346 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2347 element: 'parameter(m#a)',
2348 index: 0),
2349 const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
2350 element: 'parameter(m#b)',
2351 constant: 'null'),
2352 ]),
2353 const Test(
2354 '''
2355 m(a, {b:42}) {}
2356 ''',
2357 const [
2358 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2359 element: 'function(m)',
2360 parameters: '(a,{b: 42})',
2361 body: '{}'),
2362 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2363 element: 'parameter(m#a)',
2364 index: 0),
2365 const Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
2366 element: 'parameter(m#b)',
2367 constant: 42),
2368 ]),
2369 const Test(
2370 '''
2371 get m => null;
2372 ''',
2373 const [
2374 const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_DECL,
2375 element: 'getter(m)',
2376 body: '=>null;'),
2377 ]),
2378 const Test(
2379 '''
2380 set m(a) {}
2381 ''',
2382 const [
2383 const Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_DECL,
2384 element: 'setter(m)',
2385 parameters: '(a)',
2386 body: '{}'),
2387 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2388 element: 'parameter(m#a)',
2389 index: 0),
2390 ]),
2391 const Test.clazz(
2392 '''
2393 class C {
2394 static m(a, b) {}
2395 }
2396 ''',
2397 const [
2398 const Visit(VisitKind.VISIT_STATIC_FUNCTION_DECL,
2399 element: 'function(C#m)',
2400 parameters: '(a,b)',
2401 body: '{}'),
2402 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2403 element: 'parameter(m#a)',
2404 index: 0),
2405 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2406 element: 'parameter(m#b)',
2407 index: 1),
2408 ]),
2409 const Test.clazz(
2410 '''
2411 class C {
2412 static get m => null;
2413 }
2414 ''',
2415 const [
2416 const Visit(VisitKind.VISIT_STATIC_GETTER_DECL,
2417 element: 'getter(C#m)',
2418 body: '=>null;'),
2419 ]),
2420 const Test.clazz(
2421 '''
2422 class C {
2423 static set m(a) {}
2424 }
2425 ''',
2426 const [
2427 const Visit(VisitKind.VISIT_STATIC_SETTER_DECL,
2428 element: 'setter(C#m)',
2429 parameters: '(a)',
2430 body: '{}'),
2431 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2432 element: 'parameter(m#a)',
2433 index: 0),
2434 ]),
2435 const Test.clazz(
2436 '''
2437 class C {
2438 m(a, b) {}
2439 }
2440 ''',
2441 const [
2442 const Visit(VisitKind.VISIT_INSTANCE_METHOD_DECL,
2443 element: 'function(C#m)',
2444 parameters: '(a,b)',
2445 body: '{}'),
2446 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2447 element: 'parameter(m#a)',
2448 index: 0),
2449 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2450 element: 'parameter(m#b)',
2451 index: 1),
2452 ]),
2453 const Test.clazz(
2454 '''
2455 class C {
2456 get m => null;
2457 }
2458 ''',
2459 const [
2460 const Visit(VisitKind.VISIT_INSTANCE_GETTER_DECL,
2461 element: 'getter(C#m)',
2462 body: '=>null;'),
2463 ]),
2464 const Test.clazz(
2465 '''
2466 class C {
2467 set m(a) {}
2468 }
2469 ''',
2470 const [
2471 const Visit(VisitKind.VISIT_INSTANCE_SETTER_DECL,
2472 element: 'setter(C#m)',
2473 parameters: '(a)',
2474 body: '{}'),
2475 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2476 element: 'parameter(m#a)',
2477 index: 0),
2478 ]),
2479 const Test.clazz(
2480 '''
2481 abstract class C {
2482 m(a, b);
2483 }
2484 ''',
2485 const [
2486 const Visit(VisitKind.VISIT_ABSTRACT_METHOD_DECL,
2487 element: 'function(C#m)',
2488 parameters: '(a,b)'),
2489 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2490 element: 'parameter(m#a)',
2491 index: 0),
2492 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2493 element: 'parameter(m#b)',
2494 index: 1),
2495 ]),
2496 const Test.clazz(
2497 '''
2498 abstract class C {
2499 get m;
2500 }
2501 ''',
2502 const [
2503 const Visit(VisitKind.VISIT_ABSTRACT_GETTER_DECL,
2504 element: 'getter(C#m)'),
2505 ]),
2506 const Test.clazz(
2507 '''
2508 abstract class C {
2509 set m(a);
2510 }
2511 ''',
2512 const [
2513 const Visit(VisitKind.VISIT_ABSTRACT_SETTER_DECL,
2514 element: 'setter(C#m)',
2515 parameters: '(a)'),
2516 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2517 element: 'parameter(m#a)',
2518 index: 0),
2519 ]),
2520 const Test(
2521 '''
2522 m(a, b) {}
2523 ''',
2524 const [
2525 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2526 element: 'function(m)',
2527 parameters: '(a,b)',
2528 body: '{}'),
2529 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2530 element: 'parameter(m#a)',
2531 index: 0),
2532 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2533 element: 'parameter(m#b)',
2534 index: 1),
2535 ]),
2536 const Test(
2537 '''
2538 m() {
2539 local(a, b) {}
2540 }
2541 ''',
2542 const [
2543 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2544 element: 'function(m)',
2545 parameters: '()',
2546 body: '{local(a,b){}}'),
2547 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_DECL,
2548 element: 'function(m#local)',
2549 parameters: '(a,b)',
2550 body: '{}'),
2551 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2552 element: 'parameter(local#a)',
2553 index: 0),
2554 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2555 element: 'parameter(local#b)',
2556 index: 1),
2557 ]),
2558 const Test(
2559 '''
2560 m() => (a, b) {};
2561 ''',
2562 const [
2563 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2564 element: 'function(m)',
2565 parameters: '()',
2566 body: '=>(a,b){};'),
2567 const Visit(VisitKind.VISIT_CLOSURE_DECL,
2568 element: 'function(m#)',
2569 parameters: '(a,b)',
2570 body: '{}'),
2571 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2572 element: 'parameter(#a)',
2573 index: 0),
2574 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2575 element: 'parameter(#b)',
2576 index: 1),
2577 ]),
2578 ],
2579 'Constructor declarations': const [
2580 const Test.clazz(
2581 '''
2582 class C {
2583 C(a, b);
2584 }
2585 ''',
2586 const [
2587 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2588 element: 'generative_constructor(C#)',
2589 parameters: '(a,b)',
2590 body: ';'),
2591 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2592 element: 'parameter(#a)',
2593 index: 0),
2594 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2595 element: 'parameter(#b)',
2596 index: 1),
2597 ],
2598 method: ''),
2599 const Test.clazz(
2600 '''
2601 class C {
2602 var b;
2603 C(a, this.b);
2604 }
2605 ''',
2606 const [
2607 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2608 element: 'generative_constructor(C#)',
2609 parameters: '(a,this.b)',
2610 body: ';'),
2611 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2612 element: 'parameter(#a)',
2613 index: 0),
2614 const Visit(VisitKind.VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
2615 element: 'initializing_formal(#b)',
2616 index: 1),
2617 ],
2618 method: ''),
2619 const Test.clazz(
2620 '''
2621 class C {
2622 var b;
2623 C(a, [this.b = 42]);
2624 }
2625 ''',
2626 const [
2627 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2628 element: 'generative_constructor(C#)',
2629 parameters: '(a,[this.b=42])',
2630 body: ';'),
2631 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2632 element: 'parameter(#a)',
2633 index: 0),
2634 const Visit(VisitKind.VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
2635 element: 'initializing_formal(#b)',
2636 constant: 42,
2637 index: 1),
2638 ],
2639 method: ''),
2640 const Test.clazz(
2641 '''
2642 class C {
2643 var b;
2644 C(a, {this.b: 42});
2645 }
2646 ''',
2647 const [
2648 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2649 element: 'generative_constructor(C#)',
2650 parameters: '(a,{this.b: 42})',
2651 body: ';'),
2652 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2653 element: 'parameter(#a)',
2654 index: 0),
2655 const Visit(VisitKind.VISIT_NAMED_INITIALIZING_FORMAL_DECL,
2656 element: 'initializing_formal(#b)',
2657 constant: 42),
2658 ],
2659 method: ''),
2660 const Test.clazz(
2661 '''
2662 class C {
2663 C(a, b) : super();
2664 }
2665 ''',
2666 const [
2667 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2668 element: 'generative_constructor(C#)',
2669 parameters: '(a,b)',
2670 body: ';'),
2671 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2672 element: 'parameter(#a)',
2673 index: 0),
2674 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2675 element: 'parameter(#b)',
2676 index: 1),
2677 const Visit(VisitKind.VISIT_SUPER_CONSTRUCTOR_INVOKE,
2678 element: 'generative_constructor(Object#)',
2679 type: 'Object',
2680 arguments: '()',
2681 selector: 'Selector(call, super, arity=0)'),
2682 ],
2683 method: ''),
2684 const Test.clazz(
2685 '''
2686 class C {
2687 var field;
2688 C(a, b) : this.field = a;
2689 }
2690 ''',
2691 const [
2692 const Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
2693 element: 'generative_constructor(C#)',
2694 parameters: '(a,b)',
2695 body: ';'),
2696 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2697 element: 'parameter(#a)',
2698 index: 0),
2699 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2700 element: 'parameter(#b)',
2701 index: 1),
2702 const Visit(VisitKind.VISIT_FIELD_INITIALIZER,
2703 element: 'field(C#field)',
2704 rhs: 'a'),
2705 ],
2706 method: ''),
2707 const Test.clazz(
2708 '''
2709 class C {
2710 C(a, b) : this._(a, b);
2711 C._(a, b);
2712 }
2713 ''',
2714 const [
2715 const Visit(VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
2716 element: 'generative_constructor(C#)',
2717 parameters: '(a,b)',
2718 initializers: ':this._(a,b)'),
2719 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2720 element: 'parameter(#a)',
2721 index: 0),
2722 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2723 element: 'parameter(#b)',
2724 index: 1),
2725 const Visit(VisitKind.VISIT_THIS_CONSTRUCTOR_INVOKE,
2726 element: 'generative_constructor(C#_)',
2727 arguments: '(a,b)',
2728 selector: 'Selector(call, _, arity=2)'),
2729 ],
2730 method: ''),
2731 const Test.clazz(
2732 '''
2733 class C {
2734 factory C(a, b) => null;
2735 }
2736 ''',
2737 const [
2738 const Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_DECL,
2739 element: 'function(C#)',
2740 parameters: '(a,b)',
2741 body: '=>null;'),
2742 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2743 element: 'parameter(#a)',
2744 index: 0),
2745 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2746 element: 'parameter(#b)',
2747 index: 1),
2748 ],
2749 method: ''),
2750 const Test.clazz(
2751 '''
2752 class C {
2753 factory C(a, b) = C._;
2754 C._(a, b);
2755 }
2756 ''',
2757 const [
2758 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2759 element: 'function(C#)',
2760 parameters: '(a,b)',
2761 target: 'generative_constructor(C#_)',
2762 type: 'C'),
2763 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2764 element: 'parameter(#a)',
2765 index: 0),
2766 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2767 element: 'parameter(#b)',
2768 index: 1),
2769 ],
2770 method: ''),
2771 const Test.clazz(
2772 '''
2773 class C {
2774 factory C(a, b) = D;
2775 }
2776 class D<T> {
2777 D(a, b);
2778 }
2779 ''',
2780 const [
2781 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2782 element: 'function(C#)',
2783 parameters: '(a,b)',
2784 target: 'generative_constructor(D#)',
2785 type: 'D'),
2786 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2787 element: 'parameter(#a)',
2788 index: 0),
2789 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2790 element: 'parameter(#b)',
2791 index: 1),
2792 ],
2793 method: ''),
2794 const Test.clazz(
2795 '''
2796 class C {
2797 factory C(a, b) = D<int>;
2798 }
2799 class D<T> {
2800 D(a, b);
2801 }
2802 ''',
2803 const [
2804 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2805 element: 'function(C#)',
2806 parameters: '(a,b)',
2807 target: 'generative_constructor(D#)',
2808 type: 'D<int>'),
2809 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2810 element: 'parameter(#a)',
2811 index: 0),
2812 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2813 element: 'parameter(#b)',
2814 index: 1),
2815 ],
2816 method: ''),
2817 const Test.clazz(
2818 '''
2819 class C {
2820 factory C(a, b) = D<int>;
2821 }
2822 class D<T> {
2823 factory D(a, b) = E<D<T>>;
2824 }
2825 class E<S> {
2826 E(a, b);
2827 }
2828 ''',
2829 const [
2830 const Visit(VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
2831 element: 'function(C#)',
2832 parameters: '(a,b)',
2833 target: 'function(D#)',
2834 type: 'D<int>'),
2835 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2836 element: 'parameter(#a)',
2837 index: 0),
2838 const Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
2839 element: 'parameter(#b)',
2840 index: 1),
2841 ],
2842 method: ''),
2843 ],
2844 "Field declarations": const [
2845 const Test.clazz(
2846 '''
2847 class C {
2848 var m;
2849 }
2850 ''',
2851 const [
2852 const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
2853 element: 'field(C#m)'),
2854 ]),
2855 const Test.clazz(
2856 '''
2857 class C {
2858 var m, n;
2859 }
2860 ''',
2861 const [
2862 const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
2863 element: 'field(C#m)'),
2864 ]),
2865 const Test.clazz(
2866 '''
2867 class C {
2868 var m = 42;
2869 }
2870 ''',
2871 const [
2872 const Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
2873 element: 'field(C#m)',
2874 rhs: 42),
2875 ]),
2876 const Test(
2877 '''
2878 m() {
2879 var local;
2880 }
2881 ''',
2882 const [
2883 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2884 element: 'function(m)',
2885 parameters: '()',
2886 body: '{var local;}'),
2887 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2888 element: 'variable(m#local)'),
2889 ]),
2890 const Test(
2891 '''
2892 m() {
2893 var local = 42;
2894 }
2895 ''',
2896 const [
2897 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2898 element: 'function(m)',
2899 parameters: '()',
2900 body: '{var local=42;}'),
2901 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2902 element: 'variable(m#local)',
2903 rhs: 42),
2904 ]),
2905 const Test(
2906 '''
2907 m() {
2908 const local = 42;
2909 }
2910 ''',
2911 const [
2912 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2913 element: 'function(m)',
2914 parameters: '()',
2915 body: '{const local=42;}'),
2916 const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
2917 element: 'variable(m#local)',
2918 constant: 42),
2919 ]),
2920 const Test(
2921 '''
2922 m() {
2923 var local1, local2;
2924 }
2925 ''',
2926 const [
2927 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2928 element: 'function(m)',
2929 parameters: '()',
2930 body: '{var local1,local2;}'),
2931 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2932 element: 'variable(m#local1)'),
2933 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2934 element: 'variable(m#local2)'),
2935 ]),
2936 const Test(
2937 '''
2938 m() {
2939 var local1 = 42, local2 = true;
2940 }
2941 ''',
2942 const [
2943 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2944 element: 'function(m)',
2945 parameters: '()',
2946 body: '{var local1=42,local2=true;}'),
2947 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2948 element: 'variable(m#local1)',
2949 rhs: 42),
2950 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
2951 element: 'variable(m#local2)',
2952 rhs: true),
2953 ]),
2954 const Test(
2955 '''
2956 m() {
2957 const local1 = 42, local2 = true;
2958 }
2959 ''',
2960 const [
2961 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
2962 element: 'function(m)',
2963 parameters: '()',
2964 body: '{const local1=42,local2=true;}'),
2965 const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
2966 element: 'variable(m#local1)',
2967 constant: 42),
2968 const Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
2969 element: 'variable(m#local2)',
2970 constant: true),
2971 ]),
2972 const Test.clazz(
2973 '''
2974 class C {
2975 static var m;
2976 }
2977 ''',
2978 const [
2979 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
2980 element: 'field(C#m)'),
2981 ]),
2982 const Test.clazz(
2983 '''
2984 class C {
2985 static var m, n;
2986 }
2987 ''',
2988 const [
2989 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
2990 element: 'field(C#m)'),
2991 ]),
2992 const Test.clazz(
2993 '''
2994 class C {
2995 static var k, l, m, n;
2996 }
2997 ''',
2998 const [
2999 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
3000 element: 'field(C#m)'),
3001 ]),
3002 const Test.clazz(
3003 '''
3004 class C {
3005 static var m = 42;
3006 }
3007 ''',
3008 const [
3009 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
3010 element: 'field(C#m)',
3011 rhs: 42),
3012 ]),
3013 const Test.clazz(
3014 '''
3015 class C {
3016 static var m = 42, n = true;
3017 }
3018 ''',
3019 const [
3020 const Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
3021 element: 'field(C#m)',
3022 rhs: 42),
3023 ]),
3024 const Test.clazz(
3025 '''
3026 class C {
3027 static const m = 42;
3028 }
3029 ''',
3030 const [
3031 const Visit(VisitKind.VISIT_STATIC_CONSTANT_DECL,
3032 element: 'field(C#m)',
3033 constant: 42),
3034 ]),
3035 const Test(
3036 '''
3037 var m;
3038 ''',
3039 const [
3040 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
3041 element: 'field(m)'),
3042 ]),
3043 const Test(
3044 '''
3045 var m, n;
3046 ''',
3047 const [
3048 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
3049 element: 'field(m)'),
3050 ]),
3051 const Test(
3052 '''
3053 var m = 42;
3054 ''',
3055 const [
3056 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
3057 element: 'field(m)',
3058 rhs: 42),
3059 ]),
3060 const Test(
3061 '''
3062 const m = 42;
3063 ''',
3064 const [
3065 const Visit(VisitKind.VISIT_TOP_LEVEL_CONSTANT_DECL,
3066 element: 'field(m)',
3067 constant: 42),
3068 ]),
3069 ],
3070 };
3071
2254 main(List<String> arguments) { 3072 main(List<String> arguments) {
2255 asyncTest(() => Future.forEach([ 3073 asyncTest(() => Future.forEach([
2256 () { 3074 () {
2257 return test( 3075 return test(
2258 arguments, 3076 arguments,
2259 SEND_TESTS, 3077 SEND_TESTS,
2260 (elements) => new SemanticSendTestVisitor(elements)); 3078 (elements) => new SemanticSendTestVisitor(elements));
2261 }, 3079 },
3080 () {
3081 return test(
3082 arguments,
3083 DECL_TESTS,
3084 (elements) => new SemanticDeclTestVisitor(elements));
3085 },
2262 ], (f) => f())); 3086 ], (f) => f()));
2263 } 3087 }
2264 3088
2265 Future test(List<String> arguments, 3089 Future test(List<String> arguments,
2266 Map<String, List<Test>> TESTS, 3090 Map<String, List<Test>> TESTS,
2267 SemanticTestVisitor createVisitor(TreeElements elements)) { 3091 SemanticTestVisitor createVisitor(TreeElements elements)) {
2268 Map<String, String> sourceFiles = {}; 3092 Map<String, String> sourceFiles = {};
2269 Map<String, Test> testMap = {}; 3093 Map<String, Test> testMap = {};
2270 StringBuffer mainSource = new StringBuffer(); 3094 StringBuffer mainSource = new StringBuffer();
2271 int index = 0; 3095 int index = 0;
(...skipping 22 matching lines...) Expand all
2294 Compiler compiler = compilerFor(sourceFiles, 3118 Compiler compiler = compilerFor(sourceFiles,
2295 options: ['--analyze-all', '--analyze-only']); 3119 options: ['--analyze-all', '--analyze-only']);
2296 return compiler.run(Uri.parse('memory:main.dart')).then((_) { 3120 return compiler.run(Uri.parse('memory:main.dart')).then((_) {
2297 testMap.forEach((String filename, Test test) { 3121 testMap.forEach((String filename, Test test) {
2298 LibraryElement library = compiler.libraryLoader.lookupLibrary( 3122 LibraryElement library = compiler.libraryLoader.lookupLibrary(
2299 Uri.parse('memory:$filename')); 3123 Uri.parse('memory:$filename'));
2300 var expectedVisits = test.expectedVisits; 3124 var expectedVisits = test.expectedVisits;
2301 if (expectedVisits is! List) { 3125 if (expectedVisits is! List) {
2302 expectedVisits = [expectedVisits]; 3126 expectedVisits = [expectedVisits];
2303 } 3127 }
2304 AstElement element; 3128 Element element;
2305 String cls = test.cls; 3129 String cls = test.cls;
2306 String method = test.method; 3130 String method = test.method;
2307 if (cls == null) { 3131 if (cls == null) {
2308 element = library.find(method); 3132 element = library.find(method);
2309 } else { 3133 } else {
2310 ClassElement classElement = library.find(cls); 3134 ClassElement classElement = library.find(cls);
2311 Expect.isNotNull(classElement, 3135 Expect.isNotNull(classElement,
2312 "Class '$cls' not found in:\n" 3136 "Class '$cls' not found in:\n"
2313 "${library.compilationUnit.script.text}"); 3137 "${library.compilationUnit.script.text}");
2314 element = classElement.localLookup(method); 3138 element = classElement.localLookup(method);
2315 } 3139 }
2316 Expect.isNotNull(element, "Element '$method' not found in:\n" 3140
2317 "${library.compilationUnit.script.text}"); 3141 void testAstElement(AstElement astElement) {
2318 ResolvedAst resolvedAst = element.resolvedAst; 3142 Expect.isNotNull(astElement, "Element '$method' not found in:\n"
2319 SemanticTestVisitor visitor = createVisitor(resolvedAst.elements); 3143 "${library.compilationUnit.script.text}");
2320 try { 3144 ResolvedAst resolvedAst = astElement.resolvedAst;
2321 compiler.withCurrentElement(resolvedAst.element, () { 3145 SemanticTestVisitor visitor = createVisitor(resolvedAst.elements);
2322 //print(resolvedAst.node.toDebugString()); 3146 try {
2323 resolvedAst.node.accept(visitor); 3147 compiler.withCurrentElement(resolvedAst.element, () {
2324 }); 3148 //print(resolvedAst.node.toDebugString());
2325 } catch (e, s) { 3149 resolvedAst.node.accept(visitor);
2326 Expect.fail("$e:\n$s\nIn test:\n" 3150 });
2327 "${library.compilationUnit.script.text}"); 3151 } catch (e, s) {
3152 Expect.fail("$e:\n$s\nIn test:\n"
3153 "${library.compilationUnit.script.text}");
3154 }
3155 Expect.listEquals(expectedVisits, visitor.visits,
3156 "In test:\n"
3157 "${library.compilationUnit.script.text}");
2328 } 3158 }
2329 Expect.listEquals(expectedVisits, visitor.visits, 3159 if (element.isAbstractField) {
2330 "In test:\n" 3160 AbstractFieldElement abstractFieldElement = element;
2331 "${library.compilationUnit.script.text}"); 3161 if (abstractFieldElement.getter != null) {
3162 testAstElement(abstractFieldElement.getter);
3163 } else if (abstractFieldElement.setter != null) {
3164 testAstElement(abstractFieldElement.setter);
3165 }
3166 } else {
3167 testAstElement(element);
3168 }
2332 }); 3169 });
2333 }); 3170 });
2334 } 3171 }
2335 3172
2336 3173
2337 abstract class SemanticTestVisitor extends TraversalVisitor { 3174 abstract class SemanticTestVisitor extends TraversalVisitor {
2338 List<Visit> visits = <Visit>[]; 3175 List<Visit> visits = <Visit>[];
2339 3176
2340 SemanticTestVisitor(TreeElements elements) : super(elements); 3177 SemanticTestVisitor(TreeElements elements) : super(elements);
2341 3178
(...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 visits.add(new Visit( 5256 visits.add(new Visit(
4420 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 5257 VisitKind.ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
4421 element: constructor, 5258 element: constructor,
4422 type: type, 5259 type: type,
4423 arguments: arguments, 5260 arguments: arguments,
4424 selector: selector)); 5261 selector: selector));
4425 apply(arguments, arg); 5262 apply(arguments, arg);
4426 } 5263 }
4427 } 5264 }
4428 5265
5266 class SemanticDeclTestVisitor extends SemanticTestVisitor {
5267
5268 SemanticDeclTestVisitor(TreeElements elements) : super(elements);
5269
5270 @override
5271 errorUnresolvedSuperConstructorInvoke(
5272 Send node,
5273 Element element,
5274 NodeList arguments,
5275 Selector selector,
5276 arg) {
5277 // TODO: implement errorUnresolvedSuperConstructorInvoke
5278 }
5279
5280 @override
5281 errorUnresolvedThisConstructorInvoke(
5282 Send node,
5283 Element element,
5284 NodeList arguments,
5285 Selector selector,
5286 arg) {
5287 // TODO: implement errorUnresolvedThisConstructorInvoke
5288 }
5289
5290 @override
5291 visitAbstractMethodDecl(
5292 FunctionExpression node,
5293 MethodElement method,
5294 NodeList parameters,
5295 arg) {
5296 visits.add(new Visit(VisitKind.VISIT_ABSTRACT_METHOD_DECL,
5297 element: method, parameters: parameters));
5298 applyParameters(parameters, arg);
5299 }
5300
5301 @override
5302 visitClosureDecl(
5303 FunctionExpression node,
5304 LocalFunctionElement function,
5305 NodeList parameters,
5306 Node body,
5307 arg) {
5308 visits.add(new Visit(VisitKind.VISIT_CLOSURE_DECL,
5309 element: function, parameters: parameters, body: body));
5310 applyParameters(parameters, arg);
5311 apply(body, arg);
5312 }
5313
5314 @override
5315 visitFactoryConstructorDecl(
5316 FunctionExpression node,
5317 ConstructorElement constructor,
5318 NodeList parameters,
5319 Node body,
5320 arg) {
5321 visits.add(new Visit(VisitKind.VISIT_FACTORY_CONSTRUCTOR_DECL,
5322 element: constructor, parameters: parameters, body: body));
5323 applyParameters(parameters, arg);
5324 apply(body, arg);
5325 }
5326
5327 @override
5328 visitFieldInitializer(
5329 SendSet node,
5330 FieldElement field,
5331 Node initializer,
5332 arg) {
5333 visits.add(new Visit(VisitKind.VISIT_FIELD_INITIALIZER,
5334 element: field, rhs: initializer));
5335 apply(initializer, arg);
5336 }
5337
5338 @override
5339 visitGenerativeConstructorDecl(
5340 FunctionExpression node,
5341 ConstructorElement constructor,
5342 NodeList parameters,
5343 NodeList initializers,
5344 Node body,
5345 arg) {
5346 visits.add(new Visit(VisitKind.VISIT_GENERATIVE_CONSTRUCTOR_DECL,
5347 element: constructor, parameters: parameters, body: body));
5348 applyParameters(parameters, arg);
5349 applyInitializers(initializers, arg);
5350 apply(body, arg);
5351 }
5352
5353 @override
5354 visitInstanceMethodDecl(
5355 FunctionExpression node,
5356 MethodElement method,
5357 NodeList parameters,
5358 Node body,
5359 arg) {
5360 visits.add(new Visit(VisitKind.VISIT_INSTANCE_METHOD_DECL,
5361 element: method, parameters: parameters, body: body));
5362 applyParameters(parameters, arg);
5363 apply(body, arg);
5364 }
5365
5366 @override
5367 visitLocalFunctionDecl(
5368 FunctionExpression node,
5369 LocalFunctionElement function,
5370 NodeList parameters,
5371 Node body,
5372 arg) {
5373 visits.add(new Visit(VisitKind.VISIT_LOCAL_FUNCTION_DECL,
5374 element: function, parameters: parameters, body: body));
5375 applyParameters(parameters, arg);
5376 apply(body, arg);
5377 }
5378
5379 @override
5380 visitRedirectingFactoryConstructorDecl(
5381 FunctionExpression node,
5382 ConstructorElement constructor,
5383 NodeList parameters,
5384 InterfaceType redirectionType,
5385 ConstructorElement redirectionTarget,
5386 arg) {
5387 visits.add(new Visit(
5388 VisitKind.VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
5389 element: constructor,
5390 parameters: parameters,
5391 target: redirectionTarget,
5392 type: redirectionType));
5393 applyParameters(parameters, arg);
5394 }
5395
5396 @override
5397 visitRedirectingGenerativeConstructorDecl(
5398 FunctionExpression node,
5399 ConstructorElement constructor,
5400 NodeList parameters,
5401 NodeList initializers,
5402 arg) {
5403 visits.add(new Visit(
5404 VisitKind.VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
5405 element: constructor,
5406 parameters: parameters,
5407 initializers: initializers));
5408 applyParameters(parameters, arg);
5409 applyInitializers(initializers, arg);
5410 }
5411
5412 @override
5413 visitStaticFunctionDecl(
5414 FunctionExpression node,
5415 MethodElement function,
5416 NodeList parameters,
5417 Node body,
5418 arg) {
5419 visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_DECL,
5420 element: function, parameters: parameters, body: body));
5421 applyParameters(parameters, arg);
5422 apply(body, arg);
5423 }
5424
5425 @override
5426 visitSuperConstructorInvoke(
5427 Send node,
5428 ConstructorElement superConstructor,
5429 InterfaceType type,
5430 NodeList arguments,
5431 Selector selector,
5432 arg) {
5433 visits.add(new Visit(VisitKind.VISIT_SUPER_CONSTRUCTOR_INVOKE,
5434 element: superConstructor, type: type,
5435 arguments: arguments, selector: selector));
5436 apply(arguments, arg);
5437 }
5438
5439 @override
5440 visitThisConstructorInvoke(
5441 Send node,
5442 ConstructorElement thisConstructor,
5443 NodeList arguments,
5444 Selector selector,
5445 arg) {
5446 visits.add(new Visit(VisitKind.VISIT_THIS_CONSTRUCTOR_INVOKE,
5447 element: thisConstructor, arguments: arguments, selector: selector));
5448 apply(arguments, arg);
5449 }
5450
5451 @override
5452 visitTopLevelFunctionDecl(
5453 FunctionExpression node,
5454 MethodElement function,
5455 NodeList parameters,
5456 Node body,
5457 arg) {
5458 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_DECL,
5459 element: function, parameters: parameters, body: body));
5460 applyParameters(parameters, arg);
5461 apply(body, arg);
5462 }
5463
5464 @override
5465 errorUnresolvedFieldInitializer(
5466 SendSet node,
5467 Element element,
5468 Node initializer,
5469 arg) {
5470 // TODO: implement errorUnresolvedFieldInitializer
5471 }
5472
5473 @override
5474 visitOptionalParameterDecl(
5475 VariableDefinitions node,
5476 Node definition,
5477 ParameterElement parameter,
5478 ConstantExpression defaultValue,
5479 int index,
5480 arg) {
5481 visits.add(new Visit(VisitKind.VISIT_OPTIONAL_PARAMETER_DECL,
5482 element: parameter,
5483 constant: defaultValue != null ? defaultValue.getText() : null,
5484 index: index));
5485 }
5486
5487 @override
5488 visitParameterDecl(
5489 VariableDefinitions node,
5490 Node definition,
5491 ParameterElement parameter,
5492 int index,
5493 arg) {
5494 visits.add(new Visit(VisitKind.VISIT_REQUIRED_PARAMETER_DECL,
5495 element: parameter, index: index));
5496 }
5497
5498 @override
5499 visitInitializingFormalDecl(
5500 VariableDefinitions node,
5501 Node definition,
5502 InitializingFormalElement initializingFormal,
5503 int index,
5504 arg) {
5505 visits.add(new Visit(VisitKind.VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
5506 element: initializingFormal, index: index));
5507 }
5508
5509 @override
5510 visitLocalVariableDecl(
5511 VariableDefinitions node,
5512 Node definition,
5513 LocalVariableElement variable,
5514 Node initializer,
5515 arg) {
5516 visits.add(new Visit(VisitKind.VISIT_LOCAL_VARIABLE_DECL,
5517 element: variable, rhs: initializer));
5518 if (initializer != null) {
5519 apply(initializer, arg);
5520 }
5521 return null;
5522 }
5523
5524 @override
5525 visitLocalConstantDecl(
5526 VariableDefinitions node,
5527 Node definition,
5528 LocalVariableElement variable,
5529 ConstantExpression constant,
5530 arg) {
5531 visits.add(new Visit(VisitKind.VISIT_LOCAL_CONSTANT_DECL,
5532 element: variable, constant: constant.getText()));
5533 return null;
5534 }
5535
5536 @override
5537 visitNamedInitializingFormalDecl(
5538 VariableDefinitions node,
5539 Node definition,
5540 InitializingFormalElement initializingFormal,
5541 ConstantExpression defaultValue,
5542 arg) {
5543 visits.add(new Visit(VisitKind.VISIT_NAMED_INITIALIZING_FORMAL_DECL,
5544 element: initializingFormal,
5545 constant: defaultValue != null ? defaultValue.getText() : null));
5546 }
5547
5548 @override
5549 visitNamedParameterDecl(
5550 VariableDefinitions node,
5551 Node definition,
5552 ParameterElement parameter,
5553 ConstantExpression defaultValue,
5554 arg) {
5555 visits.add(new Visit(VisitKind.VISIT_NAMED_PARAMETER_DECL,
5556 element: parameter,
5557 constant: defaultValue != null ? defaultValue.getText() : null));
5558 }
5559
5560 @override
5561 visitOptionalInitializingFormalDecl(
5562 VariableDefinitions node,
5563 Node definition,
5564 InitializingFormalElement initializingFormal,
5565 ConstantExpression defaultValue,
5566 int index,
5567 arg) {
5568 visits.add(new Visit(VisitKind.VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
5569 element: initializingFormal,
5570 constant: defaultValue != null ? defaultValue.getText() : null,
5571 index: index));
5572 }
5573
5574 @override
5575 visitInstanceFieldDecl(
5576 VariableDefinitions node,
5577 Node definition,
5578 FieldElement field,
5579 Node initializer,
5580 arg) {
5581 visits.add(new Visit(VisitKind.VISIT_INSTANCE_FIELD_DECL,
5582 element: field, rhs: initializer));
5583 if (initializer != null) {
5584 apply(initializer, arg);
5585 }
5586 return null;
5587 }
5588
5589 @override
5590 visitStaticConstantDecl(
5591 VariableDefinitions node,
5592 Node definition,
5593 FieldElement field,
5594 ConstantExpression constant,
5595 arg) {
5596 visits.add(new Visit(VisitKind.VISIT_STATIC_CONSTANT_DECL,
5597 element: field, constant: constant.getText()));
5598 return null;
5599 }
5600
5601 @override
5602 visitStaticFieldDecl(
5603 VariableDefinitions node,
5604 Node definition,
5605 FieldElement field,
5606 Node initializer,
5607 arg) {
5608 visits.add(new Visit(VisitKind.VISIT_STATIC_FIELD_DECL,
5609 element: field, rhs: initializer));
5610 if (initializer != null) {
5611 apply(initializer, arg);
5612 }
5613 return null;
5614 }
5615
5616 @override
5617 visitTopLevelConstantDecl(
5618 VariableDefinitions node,
5619 Node definition,
5620 FieldElement field,
5621 ConstantExpression constant,
5622 arg) {
5623 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_CONSTANT_DECL,
5624 element: field, constant: constant.getText()));
5625 return null;
5626 }
5627
5628 @override
5629 visitTopLevelFieldDecl(
5630 VariableDefinitions node,
5631 Node definition,
5632 FieldElement field,
5633 Node initializer,
5634 arg) {
5635 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_DECL,
5636 element: field, rhs: initializer));
5637 if (initializer != null) {
5638 apply(initializer, arg);
5639 }
5640 return null;
5641 }
5642
5643 @override
5644 visitAbstractGetterDecl(
5645 FunctionExpression node,
5646 MethodElement getter,
5647 arg) {
5648 visits.add(new Visit(VisitKind.VISIT_ABSTRACT_GETTER_DECL,
5649 element: getter));
5650 return null;
5651 }
5652
5653 @override
5654 visitAbstractSetterDecl(
5655 FunctionExpression node,
5656 MethodElement setter,
5657 NodeList parameters,
5658 arg) {
5659 visits.add(new Visit(VisitKind.VISIT_ABSTRACT_SETTER_DECL,
5660 element: setter, parameters: parameters));
5661 applyParameters(parameters, arg);
5662 return null;
5663 }
5664
5665 @override
5666 visitInstanceGetterDecl(
5667 FunctionExpression node,
5668 MethodElement getter,
5669 Node body,
5670 arg) {
5671 visits.add(new Visit(VisitKind.VISIT_INSTANCE_GETTER_DECL,
5672 element: getter, body: body));
5673 apply(body, arg);
5674 return null;
5675 }
5676
5677 @override
5678 visitInstanceSetterDecl(
5679 FunctionExpression node,
5680 MethodElement setter,
5681 NodeList parameters,
5682 Node body,
5683 arg) {
5684 visits.add(new Visit(VisitKind.VISIT_INSTANCE_SETTER_DECL,
5685 element: setter, parameters: parameters, body: body));
5686 applyParameters(parameters, arg);
5687 apply(body, arg);
5688 return null;
5689 }
5690
5691 @override
5692 visitTopLevelGetterDecl(
5693 FunctionExpression node,
5694 MethodElement getter,
5695 Node body,
5696 arg) {
5697 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_DECL,
5698 element: getter, body: body));
5699 apply(body, arg);
5700 return null;
5701 }
5702
5703 @override
5704 visitTopLevelSetterDecl(
5705 FunctionExpression node,
5706 MethodElement setter,
5707 NodeList parameters,
5708 Node body,
5709 arg) {
5710 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_SETTER_DECL,
5711 element: setter, parameters: parameters, body: body));
5712 applyParameters(parameters, arg);
5713 apply(body, arg);
5714 return null;
5715 }
5716
5717 @override
5718 visitStaticGetterDecl(
5719 FunctionExpression node,
5720 MethodElement getter,
5721 Node body,
5722 arg) {
5723 visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_DECL,
5724 element: getter, body: body));
5725 apply(body, arg);
5726 return null;
5727 }
5728
5729 @override
5730 visitStaticSetterDecl(
5731 FunctionExpression node,
5732 MethodElement setter,
5733 NodeList parameters,
5734 Node body,
5735 arg) {
5736 visits.add(new Visit(VisitKind.VISIT_STATIC_SETTER_DECL,
5737 element: setter, parameters: parameters, body: body));
5738 applyParameters(parameters, arg);
5739 apply(body, arg);
5740 return null;
5741 }
5742 }
5743
4429 enum VisitKind { 5744 enum VisitKind {
4430 VISIT_PARAMETER_GET, 5745 VISIT_PARAMETER_GET,
4431 VISIT_PARAMETER_SET, 5746 VISIT_PARAMETER_SET,
4432 VISIT_PARAMETER_INVOKE, 5747 VISIT_PARAMETER_INVOKE,
4433 VISIT_PARAMETER_COMPOUND, 5748 VISIT_PARAMETER_COMPOUND,
4434 VISIT_PARAMETER_PREFIX, 5749 VISIT_PARAMETER_PREFIX,
4435 VISIT_PARAMETER_POSTFIX, 5750 VISIT_PARAMETER_POSTFIX,
4436 5751
4437 VISIT_LOCAL_VARIABLE_GET, 5752 VISIT_LOCAL_VARIABLE_GET,
4438 VISIT_LOCAL_VARIABLE_SET, 5753 VISIT_LOCAL_VARIABLE_SET,
4439 VISIT_LOCAL_VARIABLE_INVOKE, 5754 VISIT_LOCAL_VARIABLE_INVOKE,
4440 VISIT_LOCAL_VARIABLE_COMPOUND, 5755 VISIT_LOCAL_VARIABLE_COMPOUND,
4441 VISIT_LOCAL_VARIABLE_PREFIX, 5756 VISIT_LOCAL_VARIABLE_PREFIX,
4442 VISIT_LOCAL_VARIABLE_POSTFIX, 5757 VISIT_LOCAL_VARIABLE_POSTFIX,
5758 VISIT_LOCAL_VARIABLE_DECL,
5759 VISIT_LOCAL_CONSTANT_DECL,
4443 5760
4444 VISIT_LOCAL_FUNCTION_GET, 5761 VISIT_LOCAL_FUNCTION_GET,
4445 VISIT_LOCAL_FUNCTION_INVOKE, 5762 VISIT_LOCAL_FUNCTION_INVOKE,
5763 VISIT_LOCAL_FUNCTION_DECL,
5764 VISIT_CLOSURE_DECL,
4446 5765
4447 VISIT_STATIC_FIELD_GET, 5766 VISIT_STATIC_FIELD_GET,
4448 VISIT_STATIC_FIELD_SET, 5767 VISIT_STATIC_FIELD_SET,
4449 VISIT_STATIC_FIELD_INVOKE, 5768 VISIT_STATIC_FIELD_INVOKE,
4450 VISIT_STATIC_FIELD_COMPOUND, 5769 VISIT_STATIC_FIELD_COMPOUND,
4451 VISIT_STATIC_FIELD_PREFIX, 5770 VISIT_STATIC_FIELD_PREFIX,
4452 VISIT_STATIC_FIELD_POSTFIX, 5771 VISIT_STATIC_FIELD_POSTFIX,
5772 VISIT_STATIC_FIELD_DECL,
5773 VISIT_STATIC_CONSTANT_DECL,
4453 5774
4454 VISIT_STATIC_GETTER_GET, 5775 VISIT_STATIC_GETTER_GET,
4455 VISIT_STATIC_SETTER_SET, 5776 VISIT_STATIC_SETTER_SET,
4456 VISIT_STATIC_GETTER_INVOKE, 5777 VISIT_STATIC_GETTER_INVOKE,
4457 VISIT_STATIC_GETTER_SETTER_COMPOUND, 5778 VISIT_STATIC_GETTER_SETTER_COMPOUND,
4458 VISIT_STATIC_METHOD_SETTER_COMPOUND, 5779 VISIT_STATIC_METHOD_SETTER_COMPOUND,
4459 VISIT_STATIC_GETTER_SETTER_PREFIX, 5780 VISIT_STATIC_GETTER_SETTER_PREFIX,
4460 VISIT_STATIC_GETTER_SETTER_POSTFIX, 5781 VISIT_STATIC_GETTER_SETTER_POSTFIX,
5782 VISIT_STATIC_GETTER_DECL,
5783 VISIT_STATIC_SETTER_DECL,
4461 5784
4462 VISIT_STATIC_FUNCTION_GET, 5785 VISIT_STATIC_FUNCTION_GET,
4463 VISIT_STATIC_FUNCTION_INVOKE, 5786 VISIT_STATIC_FUNCTION_INVOKE,
5787 VISIT_STATIC_FUNCTION_DECL,
4464 5788
4465 VISIT_TOP_LEVEL_FIELD_GET, 5789 VISIT_TOP_LEVEL_FIELD_GET,
4466 VISIT_TOP_LEVEL_FIELD_SET, 5790 VISIT_TOP_LEVEL_FIELD_SET,
4467 VISIT_TOP_LEVEL_FIELD_INVOKE, 5791 VISIT_TOP_LEVEL_FIELD_INVOKE,
4468 VISIT_TOP_LEVEL_FIELD_COMPOUND, 5792 VISIT_TOP_LEVEL_FIELD_COMPOUND,
4469 VISIT_TOP_LEVEL_FIELD_PREFIX, 5793 VISIT_TOP_LEVEL_FIELD_PREFIX,
4470 VISIT_TOP_LEVEL_FIELD_POSTFIX, 5794 VISIT_TOP_LEVEL_FIELD_POSTFIX,
5795 VISIT_TOP_LEVEL_FIELD_DECL,
5796 VISIT_TOP_LEVEL_CONSTANT_DECL,
4471 5797
4472 VISIT_TOP_LEVEL_GETTER_GET, 5798 VISIT_TOP_LEVEL_GETTER_GET,
4473 VISIT_TOP_LEVEL_SETTER_SET, 5799 VISIT_TOP_LEVEL_SETTER_SET,
4474 VISIT_TOP_LEVEL_GETTER_INVOKE, 5800 VISIT_TOP_LEVEL_GETTER_INVOKE,
4475 VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND, 5801 VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND,
4476 VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX, 5802 VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX,
4477 VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX, 5803 VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX,
5804 VISIT_TOP_LEVEL_GETTER_DECL,
5805 VISIT_TOP_LEVEL_SETTER_DECL,
4478 5806
4479 VISIT_TOP_LEVEL_FUNCTION_GET, 5807 VISIT_TOP_LEVEL_FUNCTION_GET,
4480 VISIT_TOP_LEVEL_FUNCTION_INVOKE, 5808 VISIT_TOP_LEVEL_FUNCTION_INVOKE,
5809 VISIT_TOP_LEVEL_FUNCTION_DECL,
4481 5810
4482 VISIT_DYNAMIC_PROPERTY_GET, 5811 VISIT_DYNAMIC_PROPERTY_GET,
4483 VISIT_DYNAMIC_PROPERTY_SET, 5812 VISIT_DYNAMIC_PROPERTY_SET,
4484 VISIT_DYNAMIC_PROPERTY_INVOKE, 5813 VISIT_DYNAMIC_PROPERTY_INVOKE,
4485 VISIT_DYNAMIC_PROPERTY_COMPOUND, 5814 VISIT_DYNAMIC_PROPERTY_COMPOUND,
4486 VISIT_DYNAMIC_PROPERTY_PREFIX, 5815 VISIT_DYNAMIC_PROPERTY_PREFIX,
4487 VISIT_DYNAMIC_PROPERTY_POSTFIX, 5816 VISIT_DYNAMIC_PROPERTY_POSTFIX,
4488 5817
4489 VISIT_THIS_GET, 5818 VISIT_THIS_GET,
4490 VISIT_THIS_INVOKE, 5819 VISIT_THIS_INVOKE,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4582 VISIT_IS, 5911 VISIT_IS,
4583 VISIT_IS_NOT, 5912 VISIT_IS_NOT,
4584 VISIT_AS, 5913 VISIT_AS,
4585 5914
4586 VISIT_CONST_CONSTRUCTOR_INVOKE, 5915 VISIT_CONST_CONSTRUCTOR_INVOKE,
4587 VISIT_GENERATIVE_CONSTRUCTOR_INVOKE, 5916 VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
4588 VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE, 5917 VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_INVOKE,
4589 VISIT_FACTORY_CONSTRUCTOR_INVOKE, 5918 VISIT_FACTORY_CONSTRUCTOR_INVOKE,
4590 VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 5919 VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
4591 5920
5921 VISIT_SUPER_CONSTRUCTOR_INVOKE,
5922 VISIT_THIS_CONSTRUCTOR_INVOKE,
5923 VISIT_FIELD_INITIALIZER,
5924
4592 ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE, 5925 ERROR_UNRESOLVED_CLASS_CONSTRUCTOR_INVOKE,
4593 ERROR_UNRESOLVED_CONSTRUCTOR_INVOKE, 5926 ERROR_UNRESOLVED_CONSTRUCTOR_INVOKE,
4594 ERROR_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE, 5927 ERROR_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
4595 ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE, 5928 ERROR_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
4596 5929
5930 VISIT_INSTANCE_GETTER_DECL,
5931 VISIT_INSTANCE_SETTER_DECL,
5932 VISIT_INSTANCE_METHOD_DECL,
5933 VISIT_ABSTRACT_GETTER_DECL,
5934 VISIT_ABSTRACT_SETTER_DECL,
5935 VISIT_ABSTRACT_METHOD_DECL,
5936 VISIT_INSTANCE_FIELD_DECL,
5937
5938 VISIT_GENERATIVE_CONSTRUCTOR_DECL,
5939 VISIT_REDIRECTING_GENERATIVE_CONSTRUCTOR_DECL,
5940 VISIT_FACTORY_CONSTRUCTOR_DECL,
5941 VISIT_REDIRECTING_FACTORY_CONSTRUCTOR_DECL,
5942
5943 VISIT_REQUIRED_PARAMETER_DECL,
5944 VISIT_OPTIONAL_PARAMETER_DECL,
5945 VISIT_NAMED_PARAMETER_DECL,
5946 VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
5947 VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
5948 VISIT_NAMED_INITIALIZING_FORMAL_DECL,
5949
4597 // TODO(johnniwinther): Add tests for error cases. 5950 // TODO(johnniwinther): Add tests for error cases.
4598 } 5951 }
OLDNEW
« pkg/analyzer2dart/lib/src/modely.dart ('K') | « pkg/compiler/lib/src/resolution/send_structure.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698