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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart

Issue 2861523003: Add KernelXyzExpression stubs and factory methods. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:front_end/src/fasta/kernel/utils.dart'; 5 import 'package:front_end/src/fasta/kernel/utils.dart';
6 import 'package:front_end/src/fasta/scanner/token.dart' show Token; 6 import 'package:front_end/src/fasta/scanner/token.dart' show Token;
7 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; 7 import 'package:front_end/src/fasta/type_inference/type_promotion.dart';
8 import 'package:kernel/ast.dart'; 8 import 'package:kernel/ast.dart';
9 9
10 import '../builder/ast_factory.dart'; 10 import '../builder/ast_factory.dart';
11 import 'kernel_shadow_ast.dart'; 11 import 'kernel_shadow_ast.dart';
12 12
13 /// Concrete implementation of [builder.AstFactory] for building a kernel AST. 13 /// Concrete implementation of [builder.AstFactory] for building a kernel AST.
14 class KernelAstFactory implements AstFactory<VariableDeclaration> { 14 class KernelAstFactory implements AstFactory<VariableDeclaration> {
15 @override 15 @override
16 AsExpression asExpression(Expression operand, Token operator, DartType type) {
17 return new KernelAsExpression(operand, type)
18 ..fileOffset = offsetForToken(operator);
19 }
20
21 @override
22 AwaitExpression awaitExpression(Token keyword, Expression operand) {
23 return new KernelAwaitExpression(operand)
24 ..fileOffset = offsetForToken(keyword);
25 }
26
27 @override
16 KernelBlock block(List<Statement> statements, Token beginToken) { 28 KernelBlock block(List<Statement> statements, Token beginToken) {
17 return new KernelBlock(statements)..fileOffset = offsetForToken(beginToken); 29 return new KernelBlock(statements)..fileOffset = offsetForToken(beginToken);
18 } 30 }
19 31
20 @override 32 @override
21 KernelBoolLiteral boolLiteral(bool value, Token token) { 33 KernelBoolLiteral boolLiteral(bool value, Token token) {
22 return new KernelBoolLiteral(value)..fileOffset = offsetForToken(token); 34 return new KernelBoolLiteral(value)..fileOffset = offsetForToken(token);
23 } 35 }
24 36
25 @override 37 @override
38 ConstructorInvocation constructorInvocation(
39 Constructor target, Arguments arguments,
40 {bool isConst: false}) {
41 return new KernelConstructorInvocation(target, arguments, isConst: isConst);
42 }
43
44 @override
45 DirectMethodInvocation directMethodInvocation(
46 Expression receiver, Procedure target, Arguments arguments) {
47 return new KernelDirectMethodInvocation(receiver, target, arguments);
48 }
49
50 @override
51 DirectPropertyGet directPropertyGet(Expression receiver, Member target) {
52 return new KernelDirectPropertyGet(receiver, target);
53 }
54
55 @override
56 DirectPropertySet directPropertySet(
57 Expression receiver, Member target, Expression value) {
58 return new KernelDirectPropertySet(receiver, target, value);
59 }
60
61 @override
26 KernelDoubleLiteral doubleLiteral(double value, Token token) { 62 KernelDoubleLiteral doubleLiteral(double value, Token token) {
27 return new KernelDoubleLiteral(value)..fileOffset = offsetForToken(token); 63 return new KernelDoubleLiteral(value)..fileOffset = offsetForToken(token);
28 } 64 }
29 65
30 @override 66 @override
31 ExpressionStatement expressionStatement(Expression expression) { 67 ExpressionStatement expressionStatement(Expression expression) {
32 return new KernelExpressionStatement(expression); 68 return new KernelExpressionStatement(expression);
33 } 69 }
34 70
35 @override 71 @override
(...skipping 26 matching lines...) Expand all
62 98
63 @override 99 @override
64 KernelListLiteral listLiteral(List<Expression> expressions, 100 KernelListLiteral listLiteral(List<Expression> expressions,
65 DartType typeArgument, bool isConst, Token token) { 101 DartType typeArgument, bool isConst, Token token) {
66 return new KernelListLiteral(expressions, 102 return new KernelListLiteral(expressions,
67 typeArgument: typeArgument, isConst: isConst) 103 typeArgument: typeArgument, isConst: isConst)
68 ..fileOffset = offsetForToken(token); 104 ..fileOffset = offsetForToken(token);
69 } 105 }
70 106
71 @override 107 @override
108 LogicalExpression logicalExpression(
109 Expression left, String operator, Expression right) {
110 return new KernelLogicalExpression(left, operator, right);
111 }
112
113 @override
114 MapLiteral mapLiteral(
115 Token beginToken, Token constKeyword, List<MapEntry> entries,
116 {DartType keyType: const DynamicType(),
117 DartType valueType: const DynamicType()}) {
118 return new KernelMapLiteral(entries,
119 keyType: keyType, valueType: valueType, isConst: constKeyword != null)
120 ..fileOffset = constKeyword?.charOffset ?? beginToken.charOffset;
121 }
122
123 @override
124 Not not(Token token, Expression operand) {
125 return new KernelNot(operand)..fileOffset = offsetForToken(token);
126 }
127
128 @override
72 KernelNullLiteral nullLiteral(Token token) { 129 KernelNullLiteral nullLiteral(Token token) {
73 return new KernelNullLiteral()..fileOffset = offsetForToken(token); 130 return new KernelNullLiteral()..fileOffset = offsetForToken(token);
74 } 131 }
75 132
76 @override 133 @override
134 Rethrow rethrowExpression(Token keyword) {
135 return new KernelRethrow()..fileOffset = offsetForToken(keyword);
136 }
137
138 @override
77 KernelReturnStatement returnStatement(Expression expression, Token token) { 139 KernelReturnStatement returnStatement(Expression expression, Token token) {
78 return new KernelReturnStatement(expression) 140 return new KernelReturnStatement(expression)
79 ..fileOffset = offsetForToken(token); 141 ..fileOffset = offsetForToken(token);
80 } 142 }
81 143
82 @override 144 @override
83 StaticGet staticGet(Member readTarget, Token token) { 145 StaticGet staticGet(Member readTarget, Token token) {
84 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token); 146 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token);
85 } 147 }
86 148
87 @override 149 @override
150 StaticInvocation staticInvocation(Procedure target, Arguments arguments,
151 {bool isConst: false}) {
152 return new KernelStaticInvocation(target, arguments, isConst: isConst);
153 }
154
155 @override
88 StringConcatenation stringConcatenation( 156 StringConcatenation stringConcatenation(
89 List<Expression> expressions, Token token) { 157 List<Expression> expressions, Token token) {
90 return new KernelStringConcatenation(expressions) 158 return new KernelStringConcatenation(expressions)
91 ..fileOffset = offsetForToken(token); 159 ..fileOffset = offsetForToken(token);
92 } 160 }
93 161
94 @override 162 @override
95 StringLiteral stringLiteral(String value, Token token) { 163 StringLiteral stringLiteral(String value, Token token) {
96 return new KernelStringLiteral(value)..fileOffset = offsetForToken(token); 164 return new KernelStringLiteral(value)..fileOffset = offsetForToken(token);
97 } 165 }
98 166
99 @override 167 @override
168 SuperMethodInvocation superMethodInvocation(
169 Token beginToken, Name name, Arguments arguments,
170 [Procedure interfaceTarget]) {
171 return new KernelSuperMethodInvocation(name, arguments, interfaceTarget);
172 }
173
174 @override
175 SuperPropertyGet superPropertyGet(Name name, [Member interfaceTarget]) {
176 return new KernelSuperPropertyGet(name, interfaceTarget);
177 }
178
179 @override
180 SymbolLiteral symbolLiteral(Token hashToken, String value) {
181 return new KernelSymbolLiteral(value)
182 ..fileOffset = offsetForToken(hashToken);
183 }
184
185 @override
186 ThisExpression thisExpression(Token keyword) {
187 return new KernelThisExpression()..fileOffset = offsetForToken(keyword);
188 }
189
190 @override
191 Throw throwExpression(Token keyword, Expression expression) {
192 return new KernelThrow(expression)..fileOffset = offsetForToken(keyword);
193 }
194
195 @override
196 TypeLiteral typeLiteral(DartType type) {
197 return new KernelTypeLiteral(type);
198 }
199
200 @override
100 VariableDeclaration variableDeclaration( 201 VariableDeclaration variableDeclaration(
101 String name, Token token, int functionNestingLevel, 202 String name, Token token, int functionNestingLevel,
102 {DartType type, 203 {DartType type,
103 Expression initializer, 204 Expression initializer,
104 Token equalsToken, 205 Token equalsToken,
105 bool isFinal: false, 206 bool isFinal: false,
106 bool isConst: false}) { 207 bool isConst: false}) {
107 return new KernelVariableDeclaration(name, functionNestingLevel, 208 return new KernelVariableDeclaration(name, functionNestingLevel,
108 type: type, 209 type: type,
109 initializer: initializer, 210 initializer: initializer,
110 isFinal: isFinal, 211 isFinal: isFinal,
111 isConst: isConst) 212 isConst: isConst)
112 ..fileOffset = offsetForToken(token) 213 ..fileOffset = offsetForToken(token)
113 ..fileEqualsOffset = offsetForToken(equalsToken); 214 ..fileEqualsOffset = offsetForToken(equalsToken);
114 } 215 }
115 216
116 @override 217 @override
117 VariableGet variableGet( 218 VariableGet variableGet(
118 VariableDeclaration variable, 219 VariableDeclaration variable,
119 TypePromotionFact<VariableDeclaration> fact, 220 TypePromotionFact<VariableDeclaration> fact,
120 TypePromotionScope scope, 221 TypePromotionScope scope,
121 Token token) { 222 Token token) {
122 return new KernelVariableGet(variable, fact, scope) 223 return new KernelVariableGet(variable, fact, scope)
123 ..fileOffset = offsetForToken(token); 224 ..fileOffset = offsetForToken(token);
124 } 225 }
125 } 226 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698