| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 import 'package:front_end/src/scanner/token.dart' show Token; | 26 import 'package:front_end/src/scanner/token.dart' show Token; |
| 27 | 27 |
| 28 import 'package:front_end/src/fasta/kernel/fasta_accessors.dart' | 28 import 'package:front_end/src/fasta/kernel/fasta_accessors.dart' |
| 29 show BuilderHelper; | 29 show BuilderHelper; |
| 30 | 30 |
| 31 import 'package:kernel/ast.dart' hide MethodInvocation, InvalidExpression; | 31 import 'package:kernel/ast.dart' hide MethodInvocation, InvalidExpression; |
| 32 | 32 |
| 33 import '../names.dart' show equalsName, indexGetName, indexSetName; | 33 import '../names.dart' show equalsName, indexGetName, indexSetName; |
| 34 | 34 |
| 35 import '../errors.dart' show internalError; | 35 import '../deprecated_problems.dart' show deprecated_internalProblem; |
| 36 | 36 |
| 37 /// An [Accessor] represents a subexpression for which we can't yet build a | 37 /// An [Accessor] represents a subexpression for which we can't yet build a |
| 38 /// kernel [Expression] because we don't yet know the context in which it is | 38 /// kernel [Expression] because we don't yet know the context in which it is |
| 39 /// used. | 39 /// used. |
| 40 /// | 40 /// |
| 41 /// Once the context is known, an [Accessor] can be converted into an | 41 /// Once the context is known, an [Accessor] can be converted into an |
| 42 /// [Expression] by calling a "build" method. | 42 /// [Expression] by calling a "build" method. |
| 43 /// | 43 /// |
| 44 /// For example, when building a kernel representation for `a[x] = b`, after | 44 /// For example, when building a kernel representation for `a[x] = b`, after |
| 45 /// parsing `a[x]` but before parsing `= b`, we don't yet know whether to | 45 /// 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... |
| 171 return complexAssignment; | 171 return complexAssignment; |
| 172 } else { | 172 } else { |
| 173 return body; | 173 return body; |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 /// Returns an [Expression] representing a compile-time error. | 177 /// Returns an [Expression] representing a compile-time error. |
| 178 /// | 178 /// |
| 179 /// At runtime, an exception will be thrown. | 179 /// At runtime, an exception will be thrown. |
| 180 makeInvalidRead() { | 180 makeInvalidRead() { |
| 181 return internalError( | 181 return deprecated_internalProblem( |
| 182 "Unhandled compile-time error.", null, offsetForToken(token)); | 182 "Unhandled compile-time error.", null, offsetForToken(token)); |
| 183 } | 183 } |
| 184 | 184 |
| 185 /// Returns an [Expression] representing a compile-time error wrapping | 185 /// Returns an [Expression] representing a compile-time error wrapping |
| 186 /// [value]. | 186 /// [value]. |
| 187 /// | 187 /// |
| 188 /// At runtime, [value] will be evaluated before throwing an exception. | 188 /// At runtime, [value] will be evaluated before throwing an exception. |
| 189 makeInvalidWrite(Expression value) { | 189 makeInvalidWrite(Expression value) { |
| 190 return internalError( | 190 return deprecated_internalProblem( |
| 191 "Unhandled compile-time error.", null, offsetForToken(token)); | 191 "Unhandled compile-time error.", null, offsetForToken(token)); |
| 192 } | 192 } |
| 193 | 193 |
| 194 /// Creates a data structure for tracking the desugaring of a complex | 194 /// Creates a data structure for tracking the desugaring of a complex |
| 195 /// assignment expression whose right hand side is [rhs]. | 195 /// assignment expression whose right hand side is [rhs]. |
| 196 KernelComplexAssignment startComplexAssignment(Expression rhs) => | 196 KernelComplexAssignment startComplexAssignment(Expression rhs) => |
| 197 new KernelIllegalAssignment(rhs); | 197 new KernelIllegalAssignment(rhs); |
| 198 } | 198 } |
| 199 | 199 |
| 200 abstract class VariableAccessor extends Accessor { | 200 abstract class VariableAccessor extends Accessor { |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 726 |
| 727 Expression buildIsNull(Expression value, int offset) { | 727 Expression buildIsNull(Expression value, int offset) { |
| 728 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset); | 728 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset); |
| 729 } | 729 } |
| 730 | 730 |
| 731 VariableDeclaration makeOrReuseVariable(Expression value) { | 731 VariableDeclaration makeOrReuseVariable(Expression value) { |
| 732 // TODO: Devise a way to remember if a variable declaration was reused | 732 // TODO: Devise a way to remember if a variable declaration was reused |
| 733 // or is fresh (hence needs a let binding). | 733 // or is fresh (hence needs a let binding). |
| 734 return new VariableDeclaration.forValue(value); | 734 return new VariableDeclaration.forValue(value); |
| 735 } | 735 } |
| OLD | NEW |