| 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; | 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 // TODO(sra): The element type of a container type mask might be better. | 807 // TODO(sra): The element type of a container type mask might be better. |
| 808 TypeMask type = astAdapter.inferredIndexType(forInStatement); | 808 TypeMask type = astAdapter.inferredIndexType(forInStatement); |
| 809 | 809 |
| 810 HInstruction index = localsHandler.readLocal(indexVariable); | 810 HInstruction index = localsHandler.readLocal(indexVariable); |
| 811 HInstruction value = new HIndex(array, index, null, type); | 811 HInstruction value = new HIndex(array, index, null, type); |
| 812 add(value); | 812 add(value); |
| 813 | 813 |
| 814 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); | 814 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); |
| 815 localsHandler.updateLocal(loopVariableLocal, value); | 815 localsHandler.updateLocal(loopVariableLocal, value); |
| 816 // Hint to name loop value after name of loop variable. | 816 // Hint to name loop value after name of loop variable. |
| 817 if (loopVariableLocal is !SyntheticLocal) { | 817 if (loopVariableLocal is! SyntheticLocal) { |
| 818 value.sourceElement ??= loopVariableLocal; | 818 value.sourceElement ??= loopVariableLocal; |
| 819 } | 819 } |
| 820 | 820 |
| 821 forInStatement.body.accept(this); | 821 forInStatement.body.accept(this); |
| 822 } | 822 } |
| 823 | 823 |
| 824 void buildUpdate() { | 824 void buildUpdate() { |
| 825 // See buildBody as to why we check here. | 825 // See buildBody as to why we check here. |
| 826 buildConcurrentModificationErrorCheck(); | 826 buildConcurrentModificationErrorCheck(); |
| 827 | 827 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 } | 869 } |
| 870 | 870 |
| 871 void buildBody() { | 871 void buildBody() { |
| 872 TypeMask mask = astAdapter.typeOfIteratorCurrent(forInStatement); | 872 TypeMask mask = astAdapter.typeOfIteratorCurrent(forInStatement); |
| 873 _pushDynamicInvocation(forInStatement, mask, [iterator], | 873 _pushDynamicInvocation(forInStatement, mask, [iterator], |
| 874 selector: Selectors.current); | 874 selector: Selectors.current); |
| 875 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); | 875 Local loopVariableLocal = astAdapter.getLocal(forInStatement.variable); |
| 876 HInstruction value = pop(); | 876 HInstruction value = pop(); |
| 877 localsHandler.updateLocal(loopVariableLocal, value); | 877 localsHandler.updateLocal(loopVariableLocal, value); |
| 878 // Hint to name loop value after name of loop variable. | 878 // Hint to name loop value after name of loop variable. |
| 879 if (loopVariableLocal is !SyntheticLocal) { | 879 if (loopVariableLocal is! SyntheticLocal) { |
| 880 value.sourceElement ??= loopVariableLocal; | 880 value.sourceElement ??= loopVariableLocal; |
| 881 } | 881 } |
| 882 forInStatement.body.accept(this); | 882 forInStatement.body.accept(this); |
| 883 } | 883 } |
| 884 | 884 |
| 885 loopHandler.handleLoop( | 885 loopHandler.handleLoop( |
| 886 forInStatement, buildInitializer, buildCondition, () {}, buildBody); | 886 forInStatement, buildInitializer, buildCondition, () {}, buildBody); |
| 887 } | 887 } |
| 888 | 888 |
| 889 void _buildAsyncForIn(ir.ForInStatement forInStatement) { | 889 void _buildAsyncForIn(ir.ForInStatement forInStatement) { |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 // case 1: s_1; break l; | 1412 // case 1: s_1; break l; |
| 1413 // case 2: s_2; target = i; continue l; | 1413 // case 2: s_2; target = i; continue l; |
| 1414 // ... | 1414 // ... |
| 1415 // case n: s_n; target = j; continue l; | 1415 // case n: s_n; target = j; continue l; |
| 1416 // } | 1416 // } |
| 1417 // } | 1417 // } |
| 1418 // | 1418 // |
| 1419 // This is because JS does not have this same "continue label" semantics so | 1419 // This is because JS does not have this same "continue label" semantics so |
| 1420 // we encode it in the form of a state machine. | 1420 // we encode it in the form of a state machine. |
| 1421 | 1421 |
| 1422 JumpTarget switchTarget = astAdapter.getJumpTarget(switchStatement.parent); | 1422 JumpTarget switchTarget = astAdapter.getJumpTarget(switchStatement); |
| 1423 localsHandler.updateLocal(switchTarget, graph.addConstantNull(closedWorld)); | 1423 localsHandler.updateLocal(switchTarget, graph.addConstantNull(closedWorld)); |
| 1424 | 1424 |
| 1425 var switchCases = switchStatement.cases; | 1425 var switchCases = switchStatement.cases; |
| 1426 if (!hasDefault) { | 1426 if (!hasDefault) { |
| 1427 // Use null as the marker for a synthetic default clause. | 1427 // Use null as the marker for a synthetic default clause. |
| 1428 // The synthetic default is added because otherwise there would be no | 1428 // The synthetic default is added because otherwise there would be no |
| 1429 // good place to give a default value to the local. | 1429 // good place to give a default value to the local. |
| 1430 switchCases = new List<ir.SwitchCase>.from(switchCases); | 1430 switchCases = new List<ir.SwitchCase>.from(switchCases); |
| 1431 switchCases.add(null); | 1431 switchCases.add(null); |
| 1432 } | 1432 } |
| (...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3221 enterBlock.setBlockFlow( | 3221 enterBlock.setBlockFlow( |
| 3222 new HTryBlockInformation( | 3222 new HTryBlockInformation( |
| 3223 kernelBuilder.wrapStatementGraph(bodyGraph), | 3223 kernelBuilder.wrapStatementGraph(bodyGraph), |
| 3224 exception, | 3224 exception, |
| 3225 kernelBuilder.wrapStatementGraph(catchGraph), | 3225 kernelBuilder.wrapStatementGraph(catchGraph), |
| 3226 kernelBuilder.wrapStatementGraph(finallyGraph)), | 3226 kernelBuilder.wrapStatementGraph(finallyGraph)), |
| 3227 exitBlock); | 3227 exitBlock); |
| 3228 kernelBuilder.inTryStatement = previouslyInTryStatement; | 3228 kernelBuilder.inTryStatement = previouslyInTryStatement; |
| 3229 } | 3229 } |
| 3230 } | 3230 } |
| OLD | NEW |