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

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

Issue 1004683002: Refactor IrBuilder to use SemanticVisitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle local/static constants and index prefix/postfix. Created 5 years, 9 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 'package:async_helper/async_helper.dart'; 7 import 'package:async_helper/async_helper.dart';
8 import 'package:expect/expect.dart'; 8 import 'package:expect/expect.dart';
9 import 'package:compiler/src/constants/expressions.dart'; 9 import 'package:compiler/src/constants/expressions.dart';
10 import 'package:compiler/src/dart_types.dart'; 10 import 'package:compiler/src/dart_types.dart';
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 m() => 2 | 3; 1033 m() => 2 | 3;
1034 ''', 1034 ''',
1035 const Visit(VisitKind.VISIT_BINARY, 1035 const Visit(VisitKind.VISIT_BINARY,
1036 left: '2', operator: '|', right: '3')), 1036 left: '2', operator: '|', right: '3')),
1037 const Test( 1037 const Test(
1038 ''' 1038 '''
1039 m() => 2 ^ 3; 1039 m() => 2 ^ 3;
1040 ''', 1040 ''',
1041 const Visit(VisitKind.VISIT_BINARY, 1041 const Visit(VisitKind.VISIT_BINARY,
1042 left: '2', operator: '^', right: '3')), 1042 left: '2', operator: '^', right: '3')),
1043 const Test(
1044 '''
1045 m() => 2[3];
1046 ''',
1047 const Visit(VisitKind.VISIT_INDEX,
1048 receiver: '2', index: '3')),
1049 const Test.clazz( 1043 const Test.clazz(
1050 ''' 1044 '''
1051 class B { 1045 class B {
1052 operator +(_) => null; 1046 operator +(_) => null;
1053 } 1047 }
1054 class C extends B { 1048 class C extends B {
1055 m() => super + 42; 1049 m() => super + 42;
1056 } 1050 }
1057 ''', 1051 ''',
1058 const Visit(VisitKind.VISIT_SUPER_BINARY, 1052 const Visit(VisitKind.VISIT_SUPER_BINARY,
1059 element: 'function(B#+)', 1053 element: 'function(B#+)',
1060 operator: '+', 1054 operator: '+',
1061 right: '42')), 1055 right: '42')),
1056 // Index
1057 const Test(
1058 '''
1059 m() => 2[3];
1060 ''',
1061 const Visit(VisitKind.VISIT_INDEX,
1062 receiver: '2', index: '3')),
1063 const Test(
1064 '''
1065 m() => --2[3];
1066 ''',
1067 const Visit(VisitKind.VISIT_INDEX_PREFIX,
1068 receiver: '2', index: '3', operator: '--')),
1069 const Test(
1070 '''
1071 m() => 2[3]++;
1072 ''',
1073 const Visit(VisitKind.VISIT_INDEX_POSTFIX,
1074 receiver: '2', index: '3', operator: '++')),
1062 const Test.clazz( 1075 const Test.clazz(
1063 ''' 1076 '''
1064 class B { 1077 class B {
1065 operator [](_) => null; 1078 operator [](_) => null;
1066 } 1079 }
1067 class C extends B { 1080 class C extends B {
1068 m() => super[42]; 1081 m() => super[42];
1069 } 1082 }
1070 ''', 1083 ''',
1071 const Visit(VisitKind.VISIT_SUPER_INDEX, 1084 const Visit(VisitKind.VISIT_SUPER_INDEX,
1072 element: 'function(B#[])', 1085 element: 'function(B#[])',
1073 index: '42')), 1086 index: '42')),
1087 const Test.clazz(
1088 '''
1089 class B {
1090 operator [](_) => null;
1091 operator []=(a, b) {}
1092 }
1093 class C extends B {
1094 m() => ++super[42];
1095 }
1096 ''',
1097 const Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX,
1098 getter: 'function(B#[])',
1099 setter: 'function(B#[]=)',
1100 index: '42',
1101 operator: '++')),
1102 const Test.clazz(
1103 '''
1104 class B {
1105 operator [](_) => null;
1106 operator []=(a, b) {}
1107 }
1108 class C extends B {
1109 m() => super[42]--;
1110 }
1111 ''',
1112 const Visit(VisitKind.VISIT_SUPER_INDEX_POSTFIX,
1113 getter: 'function(B#[])',
1114 setter: 'function(B#[]=)',
1115 index: '42',
1116 operator: '--')),
1074 1117
1075 // Equals 1118 // Equals
1076 const Test( 1119 const Test(
1077 ''' 1120 '''
1078 m() => 2 == 3; 1121 m() => 2 == 3;
1079 ''', 1122 ''',
1080 const Visit(VisitKind.VISIT_EQUALS, 1123 const Visit(VisitKind.VISIT_EQUALS,
1081 left: '2', right: '3')), 1124 left: '2', right: '3')),
1082 const Test.clazz( 1125 const Test.clazz(
1083 ''' 1126 '''
(...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3882 } 3925 }
3883 3926
3884 @override 3927 @override
3885 errorUnresolvedSuperUnary( 3928 errorUnresolvedSuperUnary(
3886 Send node, 3929 Send node,
3887 UnaryOperator operator, 3930 UnaryOperator operator,
3888 ErroneousElement element, 3931 ErroneousElement element,
3889 arg) { 3932 arg) {
3890 // TODO: implement errorUnresolvedSuperUnary 3933 // TODO: implement errorUnresolvedSuperUnary
3891 } 3934 }
3935
3936 @override
3937 errorUnresolvedSuperIndex(
3938 Send node,
3939 Element element,
3940 Node index,
3941 arg) {
3942 // TODO: implement errorUnresolvedSuperIndex
3943 }
3944
3945 @override
3946 errorUnresolvedSuperIndexPostfix(
3947 Send node,
3948 Element function,
3949 Node index,
3950 IncDecOperator operator,
3951 arg) {
3952 // TODO: implement errorUnresolvedSuperIndexPostfix
3953 }
3954
3955 @override
3956 errorUnresolvedSuperIndexPrefix(
3957 Send node,
3958 Element function,
3959 Node index,
3960 IncDecOperator operator,
3961 arg) {
3962 // TODO: implement errorUnresolvedSuperIndexPrefix
3963 }
3964
3965 @override
3966 visitIndexPostfix(
3967 Send node,
3968 Node receiver,
3969 Node index,
3970 IncDecOperator operator,
3971 arg) {
3972 visits.add(new Visit(VisitKind.VISIT_INDEX_POSTFIX,
3973 receiver: receiver, index: index, operator: operator));
3974 apply(receiver, arg);
3975 apply(index, arg);
3976 }
3977
3978 @override
3979 visitIndexPrefix(
3980 Send node,
3981 Node receiver,
3982 Node index,
3983 IncDecOperator operator,
3984 arg) {
3985 visits.add(new Visit(VisitKind.VISIT_INDEX_PREFIX,
3986 receiver: receiver, index: index, operator: operator));
3987 apply(receiver, arg);
3988 apply(index, arg);
3989 }
3990
3991 @override
3992 visitSuperIndexPostfix(
3993 Send node,
3994 FunctionElement indexFunction,
3995 FunctionElement indexSetFunction,
3996 Node index,
3997 IncDecOperator operator,
3998 arg) {
3999 visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_POSTFIX,
4000 getter: indexFunction, setter: indexSetFunction,
4001 index: index, operator: operator));
4002 apply(index, arg);
4003 }
4004
4005 @override
4006 visitSuperIndexPrefix(
4007 Send node,
4008 FunctionElement indexFunction,
4009 FunctionElement indexSetFunction,
4010 Node index,
4011 IncDecOperator operator,
4012 arg) {
4013 visits.add(new Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX,
4014 getter: indexFunction, setter: indexSetFunction,
4015 index: index, operator: operator));
4016 apply(index, arg);
4017 }
3892 } 4018 }
3893 4019
3894 enum VisitKind { 4020 enum VisitKind {
3895 VISIT_PARAMETER_GET, 4021 VISIT_PARAMETER_GET,
3896 VISIT_PARAMETER_SET, 4022 VISIT_PARAMETER_SET,
3897 VISIT_PARAMETER_INVOKE, 4023 VISIT_PARAMETER_INVOKE,
3898 VISIT_PARAMETER_COMPOUND, 4024 VISIT_PARAMETER_COMPOUND,
3899 VISIT_PARAMETER_PREFIX, 4025 VISIT_PARAMETER_PREFIX,
3900 VISIT_PARAMETER_POSTFIX, 4026 VISIT_PARAMETER_POSTFIX,
3901 4027
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 VISIT_SUPER_GETTER_FIELD_POSTFIX, 4107 VISIT_SUPER_GETTER_FIELD_POSTFIX,
3982 VISIT_SUPER_FIELD_SETTER_POSTFIX, 4108 VISIT_SUPER_FIELD_SETTER_POSTFIX,
3983 4109
3984 VISIT_SUPER_METHOD_GET, 4110 VISIT_SUPER_METHOD_GET,
3985 VISIT_SUPER_METHOD_INVOKE, 4111 VISIT_SUPER_METHOD_INVOKE,
3986 4112
3987 VISIT_BINARY, 4113 VISIT_BINARY,
3988 VISIT_INDEX, 4114 VISIT_INDEX,
3989 VISIT_EQUALS, 4115 VISIT_EQUALS,
3990 VISIT_NOT_EQUALS, 4116 VISIT_NOT_EQUALS,
4117 VISIT_INDEX_PREFIX,
4118 VISIT_INDEX_POSTFIX,
3991 4119
3992 VISIT_SUPER_BINARY, 4120 VISIT_SUPER_BINARY,
3993 VISIT_SUPER_INDEX, 4121 VISIT_SUPER_INDEX,
3994 VISIT_SUPER_EQUALS, 4122 VISIT_SUPER_EQUALS,
3995 VISIT_SUPER_NOT_EQUALS, 4123 VISIT_SUPER_NOT_EQUALS,
4124 VISIT_SUPER_INDEX_PREFIX,
4125 VISIT_SUPER_INDEX_POSTFIX,
3996 4126
3997 VISIT_UNARY, 4127 VISIT_UNARY,
3998 VISIT_SUPER_UNARY, 4128 VISIT_SUPER_UNARY,
3999 VISIT_NOT, 4129 VISIT_NOT,
4000 4130
4001 VISIT_EXPRESSION_INVOKE, 4131 VISIT_EXPRESSION_INVOKE,
4002 4132
4003 VISIT_CLASS_TYPE_LITERAL_GET, 4133 VISIT_CLASS_TYPE_LITERAL_GET,
4004 VISIT_CLASS_TYPE_LITERAL_SET, 4134 VISIT_CLASS_TYPE_LITERAL_SET,
4005 VISIT_CLASS_TYPE_LITERAL_INVOKE, 4135 VISIT_CLASS_TYPE_LITERAL_INVOKE,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 4169
4040 VISIT_ASSERT, 4170 VISIT_ASSERT,
4041 VISIT_LOGICAL_AND, 4171 VISIT_LOGICAL_AND,
4042 VISIT_LOGICAL_OR, 4172 VISIT_LOGICAL_OR,
4043 VISIT_IS, 4173 VISIT_IS,
4044 VISIT_IS_NOT, 4174 VISIT_IS_NOT,
4045 VISIT_AS, 4175 VISIT_AS,
4046 4176
4047 // TODO(johnniwinther): Add tests for error cases. 4177 // TODO(johnniwinther): Add tests for error cases.
4048 } 4178 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/backend_dart/sexpr_test.dart ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698