| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js.ir_builder; | 5 part of dart2js.ir_builder; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This task iterates through all resolved elements and builds [ir.Node]s. The | 8 * This task iterates through all resolved elements and builds [ir.Node]s. The |
| 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and | 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and |
| 10 * [getIr]. | 10 * [getIr]. |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 // continuation's binding. The continuation is bound just outside the | 461 // continuation's binding. The continuation is bound just outside the |
| 462 // body to satisfy this property without extra analysis. | 462 // body to satisfy this property without extra analysis. |
| 463 // As a consequence, the break continuation needs parameters for all | 463 // As a consequence, the break continuation needs parameters for all |
| 464 // local variables in scope at the exit from the body. | 464 // local variables in scope at the exit from the body. |
| 465 List<ir.Parameter> parameters = | 465 List<ir.Parameter> parameters = |
| 466 new List<ir.Parameter>.generate(irBuilder.environment.length, (i) { | 466 new List<ir.Parameter>.generate(irBuilder.environment.length, (i) { |
| 467 return new ir.Parameter(irBuilder.environment.index2variable[i]); | 467 return new ir.Parameter(irBuilder.environment.index2variable[i]); |
| 468 }); | 468 }); |
| 469 joinContinuation = new ir.Continuation(parameters); | 469 joinContinuation = new ir.Continuation(parameters); |
| 470 irBuilder.invokeFullJoin(joinContinuation, jumps, recursive: false); | 470 irBuilder.invokeFullJoin(joinContinuation, jumps, recursive: false); |
| 471 irBuilder.add(new ir.LetCont(<ir.Continuation>[joinContinuation], | 471 irBuilder.add(new ir.LetCont(joinContinuation, innerBuilder._root)); |
| 472 innerBuilder._root)); | |
| 473 for (int i = 0; i < irBuilder.environment.length; ++i) { | 472 for (int i = 0; i < irBuilder.environment.length; ++i) { |
| 474 irBuilder.environment.index2value[i] = parameters[i]; | 473 irBuilder.environment.index2value[i] = parameters[i]; |
| 475 } | 474 } |
| 476 } else { | 475 } else { |
| 477 if (innerBuilder._root != null) { | 476 if (innerBuilder._root != null) { |
| 478 irBuilder.add(innerBuilder._root); | 477 irBuilder.add(innerBuilder._root); |
| 479 irBuilder._current = innerBuilder._current; | 478 irBuilder._current = innerBuilder._current; |
| 480 irBuilder.environment = innerBuilder.environment; | 479 irBuilder.environment = innerBuilder.environment; |
| 481 } | 480 } |
| 482 } | 481 } |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 ir.Primitive arg; | 932 ir.Primitive arg; |
| 934 if (ast.Operator.INCREMENT_OPERATORS.contains(op.source)) { | 933 if (ast.Operator.INCREMENT_OPERATORS.contains(op.source)) { |
| 935 arg = irBuilder.buildIntegerLiteral(1); | 934 arg = irBuilder.buildIntegerLiteral(1); |
| 936 } else { | 935 } else { |
| 937 arg = visit(getAssignArgument()); | 936 arg = visit(getAssignArgument()); |
| 938 } | 937 } |
| 939 valueToStore = new ir.Parameter(null); | 938 valueToStore = new ir.Parameter(null); |
| 940 ir.Continuation k = new ir.Continuation([valueToStore]); | 939 ir.Continuation k = new ir.Continuation([valueToStore]); |
| 941 ir.Expression invoke = | 940 ir.Expression invoke = |
| 942 new ir.InvokeMethod(originalValue, operatorSelector, k, [arg]); | 941 new ir.InvokeMethod(originalValue, operatorSelector, k, [arg]); |
| 943 irBuilder.add(new ir.LetCont(<ir.Continuation>[k], invoke)); | 942 irBuilder.add(new ir.LetCont(k, invoke)); |
| 944 } | 943 } |
| 945 | 944 |
| 946 if (Elements.isLocal(element)) { | 945 if (Elements.isLocal(element)) { |
| 947 irBuilder.buildLocalSet(element, valueToStore); | 946 irBuilder.buildLocalSet(element, valueToStore); |
| 948 } else if ((!node.isSuperCall && Elements.isErroneous(element)) || | 947 } else if ((!node.isSuperCall && Elements.isErroneous(element)) || |
| 949 Elements.isStaticOrTopLevel(element)) { | 948 Elements.isStaticOrTopLevel(element)) { |
| 950 irBuilder.buildStaticSet( | 949 irBuilder.buildStaticSet( |
| 951 element, elements.getSelector(node), valueToStore); | 950 element, elements.getSelector(node), valueToStore); |
| 952 } else { | 951 } else { |
| 953 // Setter or index-setter invocation | 952 // Setter or index-setter invocation |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 currentFunction = elements[node]; | 1128 currentFunction = elements[node]; |
| 1130 if (node.initializers != null) { | 1129 if (node.initializers != null) { |
| 1131 insideInitializer = true; | 1130 insideInitializer = true; |
| 1132 visit(node.initializers); | 1131 visit(node.initializers); |
| 1133 insideInitializer = false; | 1132 insideInitializer = false; |
| 1134 } | 1133 } |
| 1135 visit(node.body); | 1134 visit(node.body); |
| 1136 currentFunction = oldFunction; | 1135 currentFunction = oldFunction; |
| 1137 } | 1136 } |
| 1138 } | 1137 } |
| OLD | NEW |