| 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 library fasta.body_builder; | 5 library fasta.body_builder; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
| 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; | 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; |
| 9 | 9 |
| 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; | 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; |
| (...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 Expression expression = popForValue(); | 2235 Expression expression = popForValue(); |
| 2236 var lvalue = pop(); | 2236 var lvalue = pop(); |
| 2237 exitLocalScope(); | 2237 exitLocalScope(); |
| 2238 JumpTarget continueTarget = exitContinueTarget(); | 2238 JumpTarget continueTarget = exitContinueTarget(); |
| 2239 JumpTarget breakTarget = exitBreakTarget(); | 2239 JumpTarget breakTarget = exitBreakTarget(); |
| 2240 if (continueTarget.hasUsers) { | 2240 if (continueTarget.hasUsers) { |
| 2241 body = new LabeledStatement(body); | 2241 body = new LabeledStatement(body); |
| 2242 continueTarget.resolveContinues(body); | 2242 continueTarget.resolveContinues(body); |
| 2243 } | 2243 } |
| 2244 VariableDeclaration variable; | 2244 VariableDeclaration variable; |
| 2245 bool declaresVariable = false; |
| 2245 if (lvalue is VariableDeclaration) { | 2246 if (lvalue is VariableDeclaration) { |
| 2247 declaresVariable = true; |
| 2246 variable = lvalue; | 2248 variable = lvalue; |
| 2247 } else if (lvalue is FastaAccessor) { | 2249 } else if (lvalue is FastaAccessor) { |
| 2248 /// We are in this case, where `lvalue` isn't a [VariableDeclaration]: | 2250 /// We are in this case, where `lvalue` isn't a [VariableDeclaration]: |
| 2249 /// | 2251 /// |
| 2250 /// for (lvalue in expression) body | 2252 /// for (lvalue in expression) body |
| 2251 /// | 2253 /// |
| 2252 /// This is normalized to: | 2254 /// This is normalized to: |
| 2253 /// | 2255 /// |
| 2254 /// for (final #t in expression) { | 2256 /// for (final #t in expression) { |
| 2255 /// lvalue = #t; | 2257 /// lvalue = #t; |
| 2256 /// body; | 2258 /// body; |
| 2257 /// } | 2259 /// } |
| 2258 variable = new VariableDeclaration.forValue(null); | 2260 variable = new VariableDeclaration.forValue(null); |
| 2259 body = combineStatements( | 2261 body = combineStatements( |
| 2260 new KernelExpressionStatement(lvalue | 2262 new KernelExpressionStatement(lvalue |
| 2261 .buildAssignment(new VariableGet(variable), voidContext: true)), | 2263 .buildAssignment(new VariableGet(variable), voidContext: true)), |
| 2262 body); | 2264 body); |
| 2263 } else { | 2265 } else { |
| 2264 variable = new VariableDeclaration.forValue(buildCompileTimeError( | 2266 variable = new VariableDeclaration.forValue(buildCompileTimeError( |
| 2265 "Expected lvalue, but got ${lvalue}", forToken.next.next.charOffset)); | 2267 "Expected lvalue, but got ${lvalue}", forToken.next.next.charOffset)); |
| 2266 } | 2268 } |
| 2267 Statement result = new ForInStatement(variable, expression, body, | 2269 Statement result = new KernelForInStatement( |
| 2270 variable, expression, body, declaresVariable, |
| 2268 isAsync: awaitToken != null) | 2271 isAsync: awaitToken != null) |
| 2269 ..fileOffset = body.fileOffset; | 2272 ..fileOffset = body.fileOffset; |
| 2270 if (breakTarget.hasUsers) { | 2273 if (breakTarget.hasUsers) { |
| 2271 result = new LabeledStatement(result); | 2274 result = new LabeledStatement(result); |
| 2272 breakTarget.resolveBreaks(result); | 2275 breakTarget.resolveBreaks(result); |
| 2273 } | 2276 } |
| 2274 exitLoopOrSwitch(result); | 2277 exitLoopOrSwitch(result); |
| 2275 } | 2278 } |
| 2276 | 2279 |
| 2277 @override | 2280 @override |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 if (starToken == null) { | 3200 if (starToken == null) { |
| 3198 return AsyncMarker.Async; | 3201 return AsyncMarker.Async; |
| 3199 } else { | 3202 } else { |
| 3200 assert(identical(starToken.stringValue, "*")); | 3203 assert(identical(starToken.stringValue, "*")); |
| 3201 return AsyncMarker.AsyncStar; | 3204 return AsyncMarker.AsyncStar; |
| 3202 } | 3205 } |
| 3203 } else { | 3206 } else { |
| 3204 return internalError("Unknown async modifier: $asyncToken"); | 3207 return internalError("Unknown async modifier: $asyncToken"); |
| 3205 } | 3208 } |
| 3206 } | 3209 } |
| OLD | NEW |