OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// A library to help transform compounds and null-aware accessors into | 5 /// A library to help transform compounds and null-aware accessors into |
6 /// let expressions. | 6 /// let expressions. |
7 | 7 |
8 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' | 8 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' |
9 show | 9 show |
10 KernelArguments, | 10 KernelArguments, |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 import 'package:front_end/src/scanner/token.dart' show Token; | 24 import 'package:front_end/src/scanner/token.dart' show Token; |
25 | 25 |
26 import 'package:front_end/src/fasta/kernel/fasta_accessors.dart' | 26 import 'package:front_end/src/fasta/kernel/fasta_accessors.dart' |
27 show BuilderHelper; | 27 show BuilderHelper; |
28 | 28 |
29 import 'package:kernel/ast.dart' hide MethodInvocation, InvalidExpression; | 29 import 'package:kernel/ast.dart' hide MethodInvocation, InvalidExpression; |
30 | 30 |
31 import '../names.dart' show equalsName, indexGetName, indexSetName; | 31 import '../names.dart' show equalsName, indexGetName, indexSetName; |
32 | 32 |
33 import '../errors.dart' show internalError; | 33 import '../deprecated_problems.dart' show deprecated_internalProblem; |
34 | 34 |
35 /// An [Accessor] represents a subexpression for which we can't yet build a | 35 /// An [Accessor] represents a subexpression for which we can't yet build a |
36 /// kernel [Expression] because we don't yet know the context in which it is | 36 /// kernel [Expression] because we don't yet know the context in which it is |
37 /// used. | 37 /// used. |
38 /// | 38 /// |
39 /// Once the context is known, an [Accessor] can be converted into an | 39 /// Once the context is known, an [Accessor] can be converted into an |
40 /// [Expression] by calling a "build" method. | 40 /// [Expression] by calling a "build" method. |
41 /// | 41 /// |
42 /// For example, when building a kernel representation for `a[x] = b`, after | 42 /// For example, when building a kernel representation for `a[x] = b`, after |
43 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to | 43 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return complexAssignment; | 169 return complexAssignment; |
170 } else { | 170 } else { |
171 return body; | 171 return body; |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 /// Returns an [Expression] representing a compile-time error. | 175 /// Returns an [Expression] representing a compile-time error. |
176 /// | 176 /// |
177 /// At runtime, an exception will be thrown. | 177 /// At runtime, an exception will be thrown. |
178 makeInvalidRead() { | 178 makeInvalidRead() { |
179 return internalError( | 179 return deprecated_internalProblem( |
180 "Unhandled compile-time error.", null, offsetForToken(token)); | 180 "Unhandled compile-time error.", null, offsetForToken(token)); |
181 } | 181 } |
182 | 182 |
183 /// Returns an [Expression] representing a compile-time error wrapping | 183 /// Returns an [Expression] representing a compile-time error wrapping |
184 /// [value]. | 184 /// [value]. |
185 /// | 185 /// |
186 /// At runtime, [value] will be evaluated before throwing an exception. | 186 /// At runtime, [value] will be evaluated before throwing an exception. |
187 makeInvalidWrite(Expression value) { | 187 makeInvalidWrite(Expression value) { |
188 return internalError( | 188 return deprecated_internalProblem( |
189 "Unhandled compile-time error.", null, offsetForToken(token)); | 189 "Unhandled compile-time error.", null, offsetForToken(token)); |
190 } | 190 } |
191 | 191 |
192 /// Creates a data structure for tracking the desugaring of a complex | 192 /// Creates a data structure for tracking the desugaring of a complex |
193 /// assignment expression whose right hand side is [rhs], if necessary, or | 193 /// assignment expression whose right hand side is [rhs], if necessary, or |
194 /// returns `null` if not necessary. | 194 /// returns `null` if not necessary. |
195 KernelComplexAssignment startComplexAssignment(Expression rhs) => null; | 195 KernelComplexAssignment startComplexAssignment(Expression rhs) => null; |
196 } | 196 } |
197 | 197 |
198 abstract class VariableAccessor extends Accessor { | 198 abstract class VariableAccessor extends Accessor { |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 | 746 |
747 Expression buildIsNull(Expression value, int offset) { | 747 Expression buildIsNull(Expression value, int offset) { |
748 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset); | 748 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset); |
749 } | 749 } |
750 | 750 |
751 VariableDeclaration makeOrReuseVariable(Expression value) { | 751 VariableDeclaration makeOrReuseVariable(Expression value) { |
752 // TODO: Devise a way to remember if a variable declaration was reused | 752 // TODO: Devise a way to remember if a variable declaration was reused |
753 // or is fresh (hence needs a let binding). | 753 // or is fresh (hence needs a let binding). |
754 return new VariableDeclaration.forValue(value); | 754 return new VariableDeclaration.forValue(value); |
755 } | 755 } |
OLD | NEW |