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

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

Issue 2784283002: Remove unnecessary import prefixes. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /// This file declares a "shadow hierarchy" of concrete classes which extend 5 /// This file declares a "shadow hierarchy" of concrete classes which extend
6 /// the kernel class hierarchy using mixins from `builder/shadow_ast.dart`. 6 /// the kernel class hierarchy using mixins from `builder/shadow_ast.dart`.
7 /// 7 ///
8 /// Instances of these classes may be created using the factory methods in 8 /// Instances of these classes may be created using the factory methods in
9 /// `ast_factory.dart`. 9 /// `ast_factory.dart`.
10 /// 10 ///
11 /// Note that these classes represent the Dart language prior to desugaring. 11 /// Note that these classes represent the Dart language prior to desugaring.
12 /// When a single Dart construct desugars to a tree containing multiple kernel 12 /// When a single Dart construct desugars to a tree containing multiple kernel
13 /// AST nodes, the shadow class extends the kernel object at the top of the 13 /// AST nodes, the shadow class extends the kernel object at the top of the
14 /// desugared tree. 14 /// desugared tree.
15 /// 15 ///
16 /// This means that in some cases multiple shadow classes may extend the same 16 /// This means that in some cases multiple shadow classes may extend the same
17 /// kernel class, because multiple constructs in Dart may desugar to a tree 17 /// kernel class, because multiple constructs in Dart may desugar to a tree
18 /// with the same kind of root node. 18 /// with the same kind of root node.
19 import 'package:kernel/ast.dart' as kernel; 19 import 'package:kernel/ast.dart';
20 import 'package:kernel/ast.dart' show DartType;
21 20
22 import '../builder/shadow_ast.dart' as builder; 21 import '../builder/shadow_ast.dart';
23 22
24 /// Concrete shadow object representing a statement block in kernel form. 23 /// Concrete shadow object representing a statement block in kernel form.
25 class KernelBlock extends kernel.Block 24 class KernelBlock extends Block with ShadowBlock implements KernelStatement {
26 with builder.ShadowBlock
27 implements KernelStatement {
28 KernelBlock(List<KernelStatement> statements) : super(statements); 25 KernelBlock(List<KernelStatement> statements) : super(statements);
29 26
30 @override 27 @override
31 List<KernelStatement> get shadowStatements => statements; 28 List<KernelStatement> get shadowStatements => statements;
32 } 29 }
33 30
34 /// Common base class for shadow objects representing expressions in kernel 31 /// Common base class for shadow objects representing expressions in kernel
35 /// form. 32 /// form.
36 abstract class KernelExpression 33 abstract class KernelExpression implements Expression, ShadowExpression {}
37 implements kernel.Expression, builder.ShadowExpression {}
38 34
39 /// Concrete shadow object representing a function expression in kernel form. 35 /// Concrete shadow object representing a function expression in kernel form.
40 class KernelFunctionExpression extends kernel.FunctionExpression 36 class KernelFunctionExpression extends FunctionExpression
41 with builder.ShadowFunctionExpression 37 with ShadowFunctionExpression
42 implements KernelExpression { 38 implements KernelExpression {
43 KernelFunctionExpression(kernel.FunctionNode function) : super(function); 39 KernelFunctionExpression(FunctionNode function) : super(function);
44 40
45 @override 41 @override
46 KernelStatement get shadowBody => function.body; 42 KernelStatement get shadowBody => function.body;
47 43
48 @override 44 @override
49 DartType get shadowFunctionType { 45 DartType get shadowFunctionType {
50 return function.functionType; 46 return function.functionType;
51 } 47 }
52 48
53 @override 49 @override
54 bool get shadowIsAsync { 50 bool get shadowIsAsync {
55 // TODO(paulberry): is there a helper function in kernel that does this? 51 // TODO(paulberry): is there a helper function in kernel that does this?
56 var asyncMarker = function.asyncMarker; 52 var asyncMarker = function.asyncMarker;
57 return asyncMarker == kernel.AsyncMarker.Async || 53 return asyncMarker == AsyncMarker.Async ||
58 asyncMarker == kernel.AsyncMarker.AsyncStar; 54 asyncMarker == AsyncMarker.AsyncStar;
59 } 55 }
60 56
61 @override 57 @override
62 bool get shadowIsExpressionFunction => 58 bool get shadowIsExpressionFunction => function.body is ReturnStatement;
63 function.body is kernel.ReturnStatement;
64 59
65 @override 60 @override
66 bool get shadowIsGenerator { 61 bool get shadowIsGenerator {
67 // TODO(paulberry): is there a helper function in kernel that does this? 62 // TODO(paulberry): is there a helper function in kernel that does this?
68 var asyncMarker = function.asyncMarker; 63 var asyncMarker = function.asyncMarker;
69 return asyncMarker == kernel.AsyncMarker.SyncStar || 64 return asyncMarker == AsyncMarker.SyncStar ||
70 asyncMarker == kernel.AsyncMarker.AsyncStar; 65 asyncMarker == AsyncMarker.AsyncStar;
71 } 66 }
72 67
73 @override 68 @override
74 set shadowReturnType(DartType type) { 69 set shadowReturnType(DartType type) {
75 function.returnType = type; 70 function.returnType = type;
76 } 71 }
77 } 72 }
78 73
79 /// Concrete shadow object representing an integer literal in kernel form. 74 /// Concrete shadow object representing an integer literal in kernel form.
80 class KernelIntLiteral extends kernel.IntLiteral 75 class KernelIntLiteral extends IntLiteral
81 with builder.ShadowIntLiteral 76 with ShadowIntLiteral
82 implements KernelExpression { 77 implements KernelExpression {
83 KernelIntLiteral(int value) : super(value); 78 KernelIntLiteral(int value) : super(value);
84 } 79 }
85 80
86 /// Concrete shadow object representing a list literal in kernel form. 81 /// Concrete shadow object representing a list literal in kernel form.
87 class KernelListLiteral extends _KernelListLiteral 82 class KernelListLiteral extends _KernelListLiteral
88 with builder.ShadowListLiteral 83 with ShadowListLiteral
89 implements KernelExpression { 84 implements KernelExpression {
90 /// TODO(paulberry): see if we can eliminate the need for this by allowing 85 /// TODO(paulberry): see if we can eliminate the need for this by allowing
91 /// `null` to be stored in [kernel.ListLiteral] prior to type inference. 86 /// `null` to be stored in [ListLiteral] prior to type inference.
92 DartType _declaredTypeArgument; 87 DartType _declaredTypeArgument;
93 88
94 KernelListLiteral(List<KernelExpression> expressions, 89 KernelListLiteral(List<KernelExpression> expressions,
95 {DartType typeArgument, bool isConst: false}) 90 {DartType typeArgument, bool isConst: false})
96 : _declaredTypeArgument = typeArgument, 91 : _declaredTypeArgument = typeArgument,
97 super(expressions, typeArgument ?? const kernel.DynamicType(), isConst); 92 super(expressions, typeArgument ?? const DynamicType(), isConst);
98 93
99 @override 94 @override
100 Iterable<KernelExpression> get shadowExpressions { 95 Iterable<KernelExpression> get shadowExpressions {
101 List<KernelExpression> shadowExpressions = expressions; 96 List<KernelExpression> shadowExpressions = expressions;
102 return shadowExpressions; 97 return shadowExpressions;
103 } 98 }
104 99
105 @override 100 @override
106 kernel.DartType get shadowTypeArgument => _declaredTypeArgument; 101 DartType get shadowTypeArgument => _declaredTypeArgument;
107 102
108 @override 103 @override
109 set shadowTypeArgument(kernel.DartType type) { 104 set shadowTypeArgument(DartType type) {
110 typeArgument = type; 105 typeArgument = type;
111 } 106 }
112 } 107 }
113 108
114 /// Concrete shadow object representing a null literal in kernel form. 109 /// Concrete shadow object representing a null literal in kernel form.
115 class KernelNullLiteral extends kernel.NullLiteral 110 class KernelNullLiteral extends NullLiteral
116 with builder.ShadowNullLiteral 111 with ShadowNullLiteral
117 implements KernelExpression {} 112 implements KernelExpression {}
118 113
119 /// Concrete shadow object representing a return statement in kernel form. 114 /// Concrete shadow object representing a return statement in kernel form.
120 class KernelReturnStatement extends _KernelReturnStatement 115 class KernelReturnStatement extends _KernelReturnStatement
121 with builder.ShadowReturnStatement 116 with ShadowReturnStatement
122 implements KernelStatement { 117 implements KernelStatement {
123 KernelReturnStatement([KernelExpression expression]) : super(expression); 118 KernelReturnStatement([KernelExpression expression]) : super(expression);
124 119
125 @override 120 @override
126 KernelExpression get shadowExpression => expression; 121 KernelExpression get shadowExpression => expression;
127 } 122 }
128 123
129 /// Common base class for shadow objects representing statements in kernel 124 /// Common base class for shadow objects representing statements in kernel
130 /// form. 125 /// form.
131 abstract class KernelStatement extends kernel.Statement 126 abstract class KernelStatement extends Statement implements ShadowStatement {}
132 implements builder.ShadowStatement {}
133 127
134 /// Concrete shadow object representing a variable declaration in kernel form. 128 /// Concrete shadow object representing a variable declaration in kernel form.
135 class KernelVariableDeclaration extends _KernelVariableDeclaration 129 class KernelVariableDeclaration extends _KernelVariableDeclaration
136 with builder.ShadowVariableDeclaration 130 with ShadowVariableDeclaration
137 implements KernelStatement { 131 implements KernelStatement {
138 /// TODO(paulberry): see if we can eliminate the need for this by allowing 132 /// TODO(paulberry): see if we can eliminate the need for this by allowing
139 /// `null` to be stored in [kernel.VariableDeclaration] prior to type 133 /// `null` to be stored in [VariableDeclaration] prior to type
140 /// inference. Alternative: create a subclass of DynamicType which represents 134 /// inference. Alternative: create a subclass of DynamicType which represents
141 /// implicit dynamic ("MissingType" or "ImplicitDynamicType" perhaps). 135 /// implicit dynamic ("MissingType" or "ImplicitDynamicType" perhaps).
142 DartType _declaredType; 136 DartType _declaredType;
143 137
144 KernelVariableDeclaration(String name, 138 KernelVariableDeclaration(String name,
145 {KernelExpression initializer, 139 {KernelExpression initializer,
146 DartType type, 140 DartType type,
147 bool isFinal: false, 141 bool isFinal: false,
148 bool isConst: false}) 142 bool isConst: false})
149 : _declaredType = type, 143 : _declaredType = type,
150 super(name, initializer, type ?? const kernel.DynamicType(), isFinal, 144 super(name, initializer, type ?? const DynamicType(), isFinal, isConst);
151 isConst);
152 145
153 @override 146 @override
154 KernelExpression get shadowInitializer => initializer; 147 KernelExpression get shadowInitializer => initializer;
155 148
156 @override 149 @override
157 DartType get shadowType => _declaredType; 150 DartType get shadowType => _declaredType;
158 151
159 @override 152 @override
160 set shadowType(kernel.DartType type) { 153 set shadowType(DartType type) {
161 this.type = type; 154 this.type = type;
162 } 155 }
163 156
164 @override 157 @override
165 set type(kernel.DartType type) { 158 set type(DartType type) {
166 super.type = _declaredType = type; 159 super.type = _declaredType = type;
167 } 160 }
168 } 161 }
169 162
170 /// Concrete shadow object representing a read from a variable in kernel form. 163 /// Concrete shadow object representing a read from a variable in kernel form.
171 class KernelVariableGet extends _KernelVariableGet 164 class KernelVariableGet extends _KernelVariableGet
172 with builder.ShadowVariableGet 165 with ShadowVariableGet
173 implements KernelExpression { 166 implements KernelExpression {
174 KernelVariableGet(kernel.VariableDeclaration variable, 167 KernelVariableGet(VariableDeclaration variable, [DartType promotedType])
175 [DartType promotedType])
176 : super(variable, promotedType); 168 : super(variable, promotedType);
177 169
178 @override 170 @override
179 KernelVariableDeclaration get shadowDeclaration => variable; 171 KernelVariableDeclaration get shadowDeclaration => variable;
180 } 172 }
181 173
182 /// Adaptor class allowing [kernel.ListLiteral] to be extended with a mixin. 174 /// Adaptor class allowing [ListLiteral] to be extended with a mixin.
183 /// 175 ///
184 /// TODO(paulberry): see if we can eliminate the need for this class by adding 176 /// TODO(paulberry): see if we can eliminate the need for this class by adding
185 /// a named constructor to [kernel.ListLiteral] in which all arguments are 177 /// a named constructor to [ListLiteral] in which all arguments are
186 /// required. 178 /// required.
187 class _KernelListLiteral extends kernel.ListLiteral { 179 class _KernelListLiteral extends ListLiteral {
188 _KernelListLiteral( 180 _KernelListLiteral(
189 List<kernel.Expression> expressions, DartType typeArgument, bool isConst) 181 List<Expression> expressions, DartType typeArgument, bool isConst)
190 : super(expressions, typeArgument: typeArgument, isConst: isConst); 182 : super(expressions, typeArgument: typeArgument, isConst: isConst);
191 } 183 }
192 184
193 /// Adaptor class allowing [kernel.ReturnStatement] to be extended with a mixin. 185 /// Adaptor class allowing [ReturnStatement] to be extended with a mixin.
194 /// 186 ///
195 /// TODO(paulberry): see if we can eliminate the need for this class by adding 187 /// TODO(paulberry): see if we can eliminate the need for this class by adding
196 /// a named constructor to [kernel.ReturnStatement] in which all arguments are 188 /// a named constructor to [ReturnStatement] in which all arguments are
197 /// required. 189 /// required.
198 class _KernelReturnStatement extends kernel.ReturnStatement { 190 class _KernelReturnStatement extends ReturnStatement {
199 _KernelReturnStatement(KernelExpression expression) : super(expression); 191 _KernelReturnStatement(KernelExpression expression) : super(expression);
200 } 192 }
201 193
202 /// Adaptor class allowing [kernel.VariableDeclaration] to be extended with a 194 /// Adaptor class allowing [VariableDeclaration] to be extended with a
203 /// mixin. 195 /// mixin.
204 /// 196 ///
205 /// TODO(paulberry): see if we can eliminate the need for this class by adding 197 /// TODO(paulberry): see if we can eliminate the need for this class by adding
206 /// a named constructor to [kernel.VariableDeclaration] in which all arguments 198 /// a named constructor to [VariableDeclaration] in which all arguments
207 /// are required. 199 /// are required.
208 class _KernelVariableDeclaration extends kernel.VariableDeclaration { 200 class _KernelVariableDeclaration extends VariableDeclaration {
209 _KernelVariableDeclaration(String name, kernel.Expression initializer, 201 _KernelVariableDeclaration(String name, Expression initializer, DartType type,
210 DartType type, bool isFinal, bool isConst) 202 bool isFinal, bool isConst)
211 : super(name, 203 : super(name,
212 initializer: initializer, 204 initializer: initializer,
213 type: type, 205 type: type,
214 isFinal: isFinal, 206 isFinal: isFinal,
215 isConst: isConst); 207 isConst: isConst);
216 } 208 }
217 209
218 /// Adaptor class allowing [kernel.VariableGet] to be extended with a mixin. 210 /// Adaptor class allowing [VariableGet] to be extended with a mixin.
219 /// 211 ///
220 /// TODO(paulberry): see if we can eliminate the need for this class by adding 212 /// TODO(paulberry): see if we can eliminate the need for this class by adding
221 /// a named constructor to [kernel.VariableGet] in which all arguments are 213 /// a named constructor to [VariableGet] in which all arguments are
222 /// required. 214 /// required.
223 class _KernelVariableGet extends kernel.VariableGet { 215 class _KernelVariableGet extends VariableGet {
224 _KernelVariableGet(kernel.VariableDeclaration variable, DartType promotedType) 216 _KernelVariableGet(VariableDeclaration variable, DartType promotedType)
225 : super(variable, promotedType); 217 : super(variable, promotedType);
226 } 218 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698