| 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 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 const Test.prefix( | 498 const Test.prefix( |
| 499 ''' | 499 ''' |
| 500 class C { | 500 class C { |
| 501 static o(a, b) {} | 501 static o(a, b) {} |
| 502 } | 502 } |
| 503 ''', | 503 ''', |
| 504 'm() { p.C.o(null, 42); }', | 504 'm() { p.C.o(null, 42); }', |
| 505 const Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE, | 505 const Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE, |
| 506 element: 'function(C#o)', | 506 element: 'function(C#o)', |
| 507 arguments: '(null,42)')), | 507 arguments: '(null,42)')), |
| 508 const Test( |
| 509 ''' |
| 510 class C { static o(a, b) {} } |
| 511 m() => C.o(null); |
| 512 ''', |
| 513 const Visit(VisitKind.VISIT_STATIC_FUNCTION_INCOMPATIBLE_INVOKE, |
| 514 element: 'function(C#o)', |
| 515 arguments: '(null)')), |
| 508 ], | 516 ], |
| 509 'Top level fields': const [ | 517 'Top level fields': const [ |
| 510 // Top level fields | 518 // Top level fields |
| 511 const Test( | 519 const Test( |
| 512 ''' | 520 ''' |
| 513 var o; | 521 var o; |
| 514 m() => o; | 522 m() => o; |
| 515 ''', | 523 ''', |
| 516 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, | 524 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_GET, |
| 517 element: 'field(o)')), | 525 element: 'field(o)')), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 547 element: 'field(o)', | 555 element: 'field(o)', |
| 548 arguments: '(null,42)')), | 556 arguments: '(null,42)')), |
| 549 const Test.prefix( | 557 const Test.prefix( |
| 550 ''' | 558 ''' |
| 551 var o; | 559 var o; |
| 552 ''', | 560 ''', |
| 553 'm() { p.o(null, 42); }', | 561 'm() { p.o(null, 42); }', |
| 554 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_INVOKE, | 562 const Visit(VisitKind.VISIT_TOP_LEVEL_FIELD_INVOKE, |
| 555 element: 'field(o)', | 563 element: 'field(o)', |
| 556 arguments: '(null,42)')), | 564 arguments: '(null,42)')), |
| 565 const Test( |
| 566 ''' |
| 567 m() => o; |
| 568 ''', |
| 569 const Visit(VisitKind.VISIT_UNRESOLVED_GET, |
| 570 name: 'o')), |
| 557 ], | 571 ], |
| 558 'Top level properties': const [ | 572 'Top level properties': const [ |
| 559 // Top level properties | 573 // Top level properties |
| 560 const Test( | 574 const Test( |
| 561 ''' | 575 ''' |
| 562 get o => null; | 576 get o => null; |
| 563 m() => o; | 577 m() => o; |
| 564 ''', | 578 ''', |
| 565 const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET, | 579 const Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET, |
| 566 element: 'getter(o)')), | 580 element: 'getter(o)')), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_GET, | 630 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_GET, |
| 617 element: 'function(o)')), | 631 element: 'function(o)')), |
| 618 const Test( | 632 const Test( |
| 619 ''' | 633 ''' |
| 620 o(a, b) {} | 634 o(a, b) {} |
| 621 m() => o(null, 42); | 635 m() => o(null, 42); |
| 622 ''', | 636 ''', |
| 623 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE, | 637 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE, |
| 624 element: 'function(o)', | 638 element: 'function(o)', |
| 625 arguments: '(null,42)')), | 639 arguments: '(null,42)')), |
| 640 const Test( |
| 641 ''' |
| 642 o(a, b) {} |
| 643 m() => o(null); |
| 644 ''', |
| 645 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INCOMPATIBLE_INVOKE, |
| 646 element: 'function(o)', |
| 647 arguments: '(null)')), |
| 626 const Test.prefix( | 648 const Test.prefix( |
| 627 ''' | 649 ''' |
| 628 o(a, b) {} | 650 o(a, b) {} |
| 629 ''', | 651 ''', |
| 630 'm() { p.o(null, 42); }', | 652 'm() { p.o(null, 42); }', |
| 631 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE, | 653 const Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE, |
| 632 element: 'function(o)', | 654 element: 'function(o)', |
| 633 arguments: '(null,42)')), | 655 arguments: '(null,42)')), |
| 656 const Test( |
| 657 ''' |
| 658 m() => o(null, 42); |
| 659 ''', |
| 660 const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE, |
| 661 name: 'o', |
| 662 arguments: '(null,42)')), |
| 634 ], | 663 ], |
| 635 'Dynamic properties': const [ | 664 'Dynamic properties': const [ |
| 636 // Dynamic properties | 665 // Dynamic properties |
| 637 const Test('m(o) => o.foo;', | 666 const Test('m(o) => o.foo;', |
| 638 const [ | 667 const [ |
| 639 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET, | 668 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET, |
| 640 receiver: 'o', | 669 receiver: 'o', |
| 641 name: 'foo'), | 670 name: 'foo'), |
| 642 const Visit(VisitKind.VISIT_PARAMETER_GET, | 671 const Visit(VisitKind.VISIT_PARAMETER_GET, |
| 643 element: 'parameter(m#o)'), | 672 element: 'parameter(m#o)'), |
| (...skipping 2990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3634 MethodElement function, | 3663 MethodElement function, |
| 3635 NodeList arguments, | 3664 NodeList arguments, |
| 3636 CallStructure callStructure, | 3665 CallStructure callStructure, |
| 3637 arg) { | 3666 arg) { |
| 3638 visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE, | 3667 visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_INVOKE, |
| 3639 element: function, arguments: arguments)); | 3668 element: function, arguments: arguments)); |
| 3640 apply(arguments, arg); | 3669 apply(arguments, arg); |
| 3641 } | 3670 } |
| 3642 | 3671 |
| 3643 @override | 3672 @override |
| 3673 visitStaticFunctionIncompatibleInvoke( |
| 3674 Send node, |
| 3675 MethodElement function, |
| 3676 NodeList arguments, |
| 3677 CallStructure callStructure, |
| 3678 arg) { |
| 3679 visits.add(new Visit(VisitKind.VISIT_STATIC_FUNCTION_INCOMPATIBLE_INVOKE, |
| 3680 element: function, arguments: arguments)); |
| 3681 apply(arguments, arg); |
| 3682 } |
| 3683 |
| 3684 @override |
| 3644 visitStaticGetterGet( | 3685 visitStaticGetterGet( |
| 3645 Send node, | 3686 Send node, |
| 3646 FunctionElement getter, | 3687 FunctionElement getter, |
| 3647 arg) { | 3688 arg) { |
| 3648 visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_GET, | 3689 visits.add(new Visit(VisitKind.VISIT_STATIC_GETTER_GET, |
| 3649 element: getter)); | 3690 element: getter)); |
| 3650 } | 3691 } |
| 3651 | 3692 |
| 3652 @override | 3693 @override |
| 3653 visitStaticGetterInvoke( | 3694 visitStaticGetterInvoke( |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3822 MethodElement function, | 3863 MethodElement function, |
| 3823 NodeList arguments, | 3864 NodeList arguments, |
| 3824 CallStructure callStructure, | 3865 CallStructure callStructure, |
| 3825 arg) { | 3866 arg) { |
| 3826 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE, | 3867 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INVOKE, |
| 3827 element: function, arguments: arguments)); | 3868 element: function, arguments: arguments)); |
| 3828 apply(arguments, arg); | 3869 apply(arguments, arg); |
| 3829 } | 3870 } |
| 3830 | 3871 |
| 3831 @override | 3872 @override |
| 3873 visitTopLevelFunctionIncompatibleInvoke( |
| 3874 Send node, |
| 3875 MethodElement function, |
| 3876 NodeList arguments, |
| 3877 CallStructure callStructure, |
| 3878 arg) { |
| 3879 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_FUNCTION_INCOMPATIBLE_INVOKE, |
| 3880 element: function, arguments: arguments)); |
| 3881 apply(arguments, arg); |
| 3882 } |
| 3883 |
| 3884 @override |
| 3832 visitTopLevelGetterGet( | 3885 visitTopLevelGetterGet( |
| 3833 Send node, | 3886 Send node, |
| 3834 FunctionElement getter, | 3887 FunctionElement getter, |
| 3835 arg) { | 3888 arg) { |
| 3836 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET, | 3889 visits.add(new Visit(VisitKind.VISIT_TOP_LEVEL_GETTER_GET, |
| 3837 element: getter)); | 3890 element: getter)); |
| 3838 } | 3891 } |
| 3839 | 3892 |
| 3840 @override | 3893 @override |
| 3841 visitTopLevelGetterInvoke( | 3894 visitTopLevelGetterInvoke( |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5058 errorUnresolvedCompound( | 5111 errorUnresolvedCompound( |
| 5059 Send node, | 5112 Send node, |
| 5060 ErroneousElement element, | 5113 ErroneousElement element, |
| 5061 AssignmentOperator operator, | 5114 AssignmentOperator operator, |
| 5062 Node rhs, | 5115 Node rhs, |
| 5063 arg) { | 5116 arg) { |
| 5064 // TODO: implement errorUnresolvedCompound | 5117 // TODO: implement errorUnresolvedCompound |
| 5065 } | 5118 } |
| 5066 | 5119 |
| 5067 @override | 5120 @override |
| 5068 errorUnresolvedGet( | 5121 visitUnresolvedGet( |
| 5069 Send node, | 5122 Send node, |
| 5070 ErroneousElement element, | 5123 Element element, |
| 5071 arg) { | 5124 arg) { |
| 5072 // TODO: implement errorUnresolvedGet | 5125 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_GET, name: element.name)); |
| 5073 } | 5126 } |
| 5074 | 5127 |
| 5075 @override | 5128 @override |
| 5076 errorUnresolvedInvoke( | 5129 visitUnresolvedInvoke( |
| 5077 Send node, | 5130 Send node, |
| 5078 ErroneousElement element, | 5131 Element element, |
| 5079 NodeList arguments, | 5132 NodeList arguments, |
| 5080 Selector selector, | 5133 Selector selector, |
| 5081 arg) { | 5134 arg) { |
| 5082 // TODO: implement errorUnresolvedInvoke | 5135 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_INVOKE, |
| 5136 name: element.name, arguments: arguments)); |
| 5083 } | 5137 } |
| 5084 | 5138 |
| 5085 @override | 5139 @override |
| 5086 errorUnresolvedPostfix( | 5140 errorUnresolvedPostfix( |
| 5087 Send node, | 5141 Send node, |
| 5088 ErroneousElement element, | 5142 ErroneousElement element, |
| 5089 IncDecOperator operator, | 5143 IncDecOperator operator, |
| 5090 arg) { | 5144 arg) { |
| 5091 visits.add(new Visit( | 5145 visits.add(new Visit( |
| 5092 VisitKind.ERROR_UNRESOLVED_POSTFIX, operator: operator)); | 5146 VisitKind.ERROR_UNRESOLVED_POSTFIX, operator: operator)); |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6029 VISIT_STATIC_GETTER_INVOKE, | 6083 VISIT_STATIC_GETTER_INVOKE, |
| 6030 VISIT_STATIC_GETTER_SETTER_COMPOUND, | 6084 VISIT_STATIC_GETTER_SETTER_COMPOUND, |
| 6031 VISIT_STATIC_METHOD_SETTER_COMPOUND, | 6085 VISIT_STATIC_METHOD_SETTER_COMPOUND, |
| 6032 VISIT_STATIC_GETTER_SETTER_PREFIX, | 6086 VISIT_STATIC_GETTER_SETTER_PREFIX, |
| 6033 VISIT_STATIC_GETTER_SETTER_POSTFIX, | 6087 VISIT_STATIC_GETTER_SETTER_POSTFIX, |
| 6034 VISIT_STATIC_GETTER_DECL, | 6088 VISIT_STATIC_GETTER_DECL, |
| 6035 VISIT_STATIC_SETTER_DECL, | 6089 VISIT_STATIC_SETTER_DECL, |
| 6036 | 6090 |
| 6037 VISIT_STATIC_FUNCTION_GET, | 6091 VISIT_STATIC_FUNCTION_GET, |
| 6038 VISIT_STATIC_FUNCTION_INVOKE, | 6092 VISIT_STATIC_FUNCTION_INVOKE, |
| 6093 VISIT_STATIC_FUNCTION_INCOMPATIBLE_INVOKE, |
| 6039 VISIT_STATIC_FUNCTION_DECL, | 6094 VISIT_STATIC_FUNCTION_DECL, |
| 6040 | 6095 |
| 6041 VISIT_TOP_LEVEL_FIELD_GET, | 6096 VISIT_TOP_LEVEL_FIELD_GET, |
| 6042 VISIT_TOP_LEVEL_FIELD_SET, | 6097 VISIT_TOP_LEVEL_FIELD_SET, |
| 6043 VISIT_TOP_LEVEL_FIELD_INVOKE, | 6098 VISIT_TOP_LEVEL_FIELD_INVOKE, |
| 6044 VISIT_TOP_LEVEL_FIELD_COMPOUND, | 6099 VISIT_TOP_LEVEL_FIELD_COMPOUND, |
| 6045 VISIT_TOP_LEVEL_FIELD_PREFIX, | 6100 VISIT_TOP_LEVEL_FIELD_PREFIX, |
| 6046 VISIT_TOP_LEVEL_FIELD_POSTFIX, | 6101 VISIT_TOP_LEVEL_FIELD_POSTFIX, |
| 6047 VISIT_TOP_LEVEL_FIELD_DECL, | 6102 VISIT_TOP_LEVEL_FIELD_DECL, |
| 6048 VISIT_TOP_LEVEL_CONSTANT_DECL, | 6103 VISIT_TOP_LEVEL_CONSTANT_DECL, |
| 6049 | 6104 |
| 6050 VISIT_TOP_LEVEL_GETTER_GET, | 6105 VISIT_TOP_LEVEL_GETTER_GET, |
| 6051 VISIT_TOP_LEVEL_SETTER_SET, | 6106 VISIT_TOP_LEVEL_SETTER_SET, |
| 6052 VISIT_TOP_LEVEL_GETTER_INVOKE, | 6107 VISIT_TOP_LEVEL_GETTER_INVOKE, |
| 6053 VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND, | 6108 VISIT_TOP_LEVEL_GETTER_SETTER_COMPOUND, |
| 6054 VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX, | 6109 VISIT_TOP_LEVEL_GETTER_SETTER_PREFIX, |
| 6055 VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX, | 6110 VISIT_TOP_LEVEL_GETTER_SETTER_POSTFIX, |
| 6056 VISIT_TOP_LEVEL_GETTER_DECL, | 6111 VISIT_TOP_LEVEL_GETTER_DECL, |
| 6057 VISIT_TOP_LEVEL_SETTER_DECL, | 6112 VISIT_TOP_LEVEL_SETTER_DECL, |
| 6058 | 6113 |
| 6059 VISIT_TOP_LEVEL_FUNCTION_GET, | 6114 VISIT_TOP_LEVEL_FUNCTION_GET, |
| 6060 VISIT_TOP_LEVEL_FUNCTION_INVOKE, | 6115 VISIT_TOP_LEVEL_FUNCTION_INVOKE, |
| 6116 VISIT_TOP_LEVEL_FUNCTION_INCOMPATIBLE_INVOKE, |
| 6061 VISIT_TOP_LEVEL_FUNCTION_DECL, | 6117 VISIT_TOP_LEVEL_FUNCTION_DECL, |
| 6062 | 6118 |
| 6063 VISIT_DYNAMIC_PROPERTY_GET, | 6119 VISIT_DYNAMIC_PROPERTY_GET, |
| 6064 VISIT_DYNAMIC_PROPERTY_SET, | 6120 VISIT_DYNAMIC_PROPERTY_SET, |
| 6065 VISIT_DYNAMIC_PROPERTY_INVOKE, | 6121 VISIT_DYNAMIC_PROPERTY_INVOKE, |
| 6066 VISIT_DYNAMIC_PROPERTY_COMPOUND, | 6122 VISIT_DYNAMIC_PROPERTY_COMPOUND, |
| 6067 VISIT_DYNAMIC_PROPERTY_PREFIX, | 6123 VISIT_DYNAMIC_PROPERTY_PREFIX, |
| 6068 VISIT_DYNAMIC_PROPERTY_POSTFIX, | 6124 VISIT_DYNAMIC_PROPERTY_POSTFIX, |
| 6069 | 6125 |
| 6070 VISIT_THIS_GET, | 6126 VISIT_THIS_GET, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 6094 VISIT_SUPER_GETTER_FIELD_PREFIX, | 6150 VISIT_SUPER_GETTER_FIELD_PREFIX, |
| 6095 VISIT_SUPER_FIELD_SETTER_PREFIX, | 6151 VISIT_SUPER_FIELD_SETTER_PREFIX, |
| 6096 VISIT_SUPER_GETTER_SETTER_POSTFIX, | 6152 VISIT_SUPER_GETTER_SETTER_POSTFIX, |
| 6097 VISIT_SUPER_GETTER_FIELD_POSTFIX, | 6153 VISIT_SUPER_GETTER_FIELD_POSTFIX, |
| 6098 VISIT_SUPER_FIELD_SETTER_POSTFIX, | 6154 VISIT_SUPER_FIELD_SETTER_POSTFIX, |
| 6099 | 6155 |
| 6100 VISIT_SUPER_METHOD_GET, | 6156 VISIT_SUPER_METHOD_GET, |
| 6101 VISIT_SUPER_METHOD_INVOKE, | 6157 VISIT_SUPER_METHOD_INVOKE, |
| 6102 VISIT_SUPER_METHOD_INCOMPATIBLE_INVOKE, | 6158 VISIT_SUPER_METHOD_INCOMPATIBLE_INVOKE, |
| 6103 | 6159 |
| 6160 VISIT_UNRESOLVED_GET, |
| 6161 VISIT_UNRESOLVED_INVOKE, |
| 6104 VISIT_UNRESOLVED_SUPER_GET, | 6162 VISIT_UNRESOLVED_SUPER_GET, |
| 6105 VISIT_UNRESOLVED_SUPER_INVOKE, | 6163 VISIT_UNRESOLVED_SUPER_INVOKE, |
| 6106 | 6164 |
| 6107 VISIT_BINARY, | 6165 VISIT_BINARY, |
| 6108 VISIT_INDEX, | 6166 VISIT_INDEX, |
| 6109 VISIT_EQUALS, | 6167 VISIT_EQUALS, |
| 6110 VISIT_NOT_EQUALS, | 6168 VISIT_NOT_EQUALS, |
| 6111 VISIT_INDEX_PREFIX, | 6169 VISIT_INDEX_PREFIX, |
| 6112 VISIT_INDEX_POSTFIX, | 6170 VISIT_INDEX_POSTFIX, |
| 6113 | 6171 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6203 VISIT_OPTIONAL_PARAMETER_DECL, | 6261 VISIT_OPTIONAL_PARAMETER_DECL, |
| 6204 VISIT_NAMED_PARAMETER_DECL, | 6262 VISIT_NAMED_PARAMETER_DECL, |
| 6205 VISIT_REQUIRED_INITIALIZING_FORMAL_DECL, | 6263 VISIT_REQUIRED_INITIALIZING_FORMAL_DECL, |
| 6206 VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL, | 6264 VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL, |
| 6207 VISIT_NAMED_INITIALIZING_FORMAL_DECL, | 6265 VISIT_NAMED_INITIALIZING_FORMAL_DECL, |
| 6208 | 6266 |
| 6209 ERROR_UNRESOLVED_POSTFIX, | 6267 ERROR_UNRESOLVED_POSTFIX, |
| 6210 | 6268 |
| 6211 // TODO(johnniwinther): Add tests for more error cases. | 6269 // TODO(johnniwinther): Add tests for more error cases. |
| 6212 } | 6270 } |
| OLD | NEW |