| 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 library dart2js.ir_builder; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import '../common/names.dart' show | 7 import '../common/names.dart' show |
| 8 Names, | 8 Names, |
| 9 Selectors; | 9 Selectors; |
| 10 import '../compile_time_constants.dart' show | 10 import '../compile_time_constants.dart' show |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 // let cont then() = [[thenPart]]; join(v, ...) | 766 // let cont then() = [[thenPart]]; join(v, ...) |
| 767 // and else() = [[elsePart]]; join(v, ...) | 767 // and else() = [[elsePart]]; join(v, ...) |
| 768 // in | 768 // in |
| 769 // if condition (then, else) | 769 // if condition (then, else) |
| 770 ir.Continuation thenContinuation = new ir.Continuation([]); | 770 ir.Continuation thenContinuation = new ir.Continuation([]); |
| 771 ir.Continuation elseContinuation = new ir.Continuation([]); | 771 ir.Continuation elseContinuation = new ir.Continuation([]); |
| 772 thenContinuation.body = thenBuilder._root; | 772 thenContinuation.body = thenBuilder._root; |
| 773 elseContinuation.body = elseBuilder._root; | 773 elseContinuation.body = elseBuilder._root; |
| 774 add(new ir.LetCont(join.continuation, | 774 add(new ir.LetCont(join.continuation, |
| 775 new ir.LetCont.two(thenContinuation, elseContinuation, | 775 new ir.LetCont.two(thenContinuation, elseContinuation, |
| 776 new ir.Branch(new ir.IsTrue(condition), | 776 new ir.Branch.strict(condition, |
| 777 thenContinuation, | 777 thenContinuation, |
| 778 elseContinuation)))); | 778 elseContinuation)))); |
| 779 environment = join.environment; | 779 environment = join.environment; |
| 780 return environment.discard(1); | 780 return environment.discard(1); |
| 781 } | 781 } |
| 782 | 782 |
| 783 /** | 783 /** |
| 784 * Add an explicit `return null` for functions that don't have a return | 784 * Add an explicit `return null` for functions that don't have a return |
| 785 * statement on each branch. This includes functions with an empty body, | 785 * statement on each branch. This includes functions with an empty body, |
| 786 * such as `foo(){ }`. | 786 * such as `foo(){ }`. |
| 787 */ | 787 */ |
| 788 void _ensureReturn() { | 788 void _ensureReturn() { |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 // If exactly one of the then and else continuation bodies is open (i.e., | 1110 // If exactly one of the then and else continuation bodies is open (i.e., |
| 1111 // the other one has an exit on all paths), then Continuation.plug expects | 1111 // the other one has an exit on all paths), then Continuation.plug expects |
| 1112 // that continuation to be listed first. Arbitrarily use [then, else] | 1112 // that continuation to be listed first. Arbitrarily use [then, else] |
| 1113 // order otherwise. | 1113 // order otherwise. |
| 1114 List<ir.Continuation> arms = !thenBuilder.isOpen && elseBuilder.isOpen | 1114 List<ir.Continuation> arms = !thenBuilder.isOpen && elseBuilder.isOpen |
| 1115 ? <ir.Continuation>[elseContinuation, thenContinuation] | 1115 ? <ir.Continuation>[elseContinuation, thenContinuation] |
| 1116 : <ir.Continuation>[thenContinuation, elseContinuation]; | 1116 : <ir.Continuation>[thenContinuation, elseContinuation]; |
| 1117 | 1117 |
| 1118 ir.Expression result = | 1118 ir.Expression result = |
| 1119 new ir.LetCont.many(arms, | 1119 new ir.LetCont.many(arms, |
| 1120 new ir.Branch(new ir.IsTrue(condition), | 1120 new ir.Branch.strict(condition, |
| 1121 thenContinuation, | 1121 thenContinuation, |
| 1122 elseContinuation)); | 1122 elseContinuation)); |
| 1123 | 1123 |
| 1124 JumpCollector join; // Null if there is no join. | 1124 JumpCollector join; // Null if there is no join. |
| 1125 if (thenBuilder.isOpen && elseBuilder.isOpen) { | 1125 if (thenBuilder.isOpen && elseBuilder.isOpen) { |
| 1126 // There is a join-point continuation. Build the term | 1126 // There is a join-point continuation. Build the term |
| 1127 // 'let cont join(x, ...) = [] in Result' and plug invocations of the | 1127 // 'let cont join(x, ...) = [] in Result' and plug invocations of the |
| 1128 // join-point continuation into the then and else continuations. | 1128 // join-point continuation into the then and else continuations. |
| 1129 join = new ForwardJumpCollector(environment); | 1129 join = new ForwardJumpCollector(environment); |
| 1130 thenBuilder.jumpTo(join); | 1130 thenBuilder.jumpTo(join); |
| 1131 elseBuilder.jumpTo(join); | 1131 elseBuilder.jumpTo(join); |
| 1132 result = new ir.LetCont(join.continuation, result); | 1132 result = new ir.LetCont(join.continuation, result); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 // Create loop exit and body entry continuations and a branch to them. | 1283 // Create loop exit and body entry continuations and a branch to them. |
| 1284 ir.Continuation exitContinuation = new ir.Continuation([]); | 1284 ir.Continuation exitContinuation = new ir.Continuation([]); |
| 1285 ir.Continuation bodyContinuation = new ir.Continuation([]); | 1285 ir.Continuation bodyContinuation = new ir.Continuation([]); |
| 1286 bodyContinuation.body = outerBodyBuilder._root; | 1286 bodyContinuation.body = outerBodyBuilder._root; |
| 1287 // Note the order of continuations: the first one is the one that will | 1287 // Note the order of continuations: the first one is the one that will |
| 1288 // be filled by LetCont.plug. | 1288 // be filled by LetCont.plug. |
| 1289 ir.LetCont branch = | 1289 ir.LetCont branch = |
| 1290 new ir.LetCont.two(exitContinuation, bodyContinuation, | 1290 new ir.LetCont.two(exitContinuation, bodyContinuation, |
| 1291 new ir.Branch(new ir.IsTrue(condition), | 1291 new ir.Branch.strict(condition, |
| 1292 bodyContinuation, | 1292 bodyContinuation, |
| 1293 exitContinuation)); | 1293 exitContinuation)); |
| 1294 // If there are breaks in the body, then there must be a join-point | 1294 // If there are breaks in the body, then there must be a join-point |
| 1295 // continuation for the normal exit and the breaks. Otherwise, the | 1295 // continuation for the normal exit and the breaks. Otherwise, the |
| 1296 // successor is translated in the hole in the exit continuation. | 1296 // successor is translated in the hole in the exit continuation. |
| 1297 bool hasBreaks = !breakCollector.isEmpty; | 1297 bool hasBreaks = !breakCollector.isEmpty; |
| 1298 ir.LetCont letBreak; | 1298 ir.LetCont letBreak; |
| 1299 if (hasBreaks) { | 1299 if (hasBreaks) { |
| 1300 IrBuilder exitBuilder = makeDelimitedBuilder(); | 1300 IrBuilder exitBuilder = makeDelimitedBuilder(); |
| 1301 exitBuilder.jumpTo(breakCollector); | 1301 exitBuilder.jumpTo(breakCollector); |
| 1302 exitContinuation.body = exitBuilder._root; | 1302 exitContinuation.body = exitBuilder._root; |
| 1303 letBreak = new ir.LetCont(breakCollector.continuation, branch); | 1303 letBreak = new ir.LetCont(breakCollector.continuation, branch); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 // let cont exit() = [ ] | 1442 // let cont exit() = [ ] |
| 1443 // and body() = <<BODY>> | 1443 // and body() = <<BODY>> |
| 1444 // in branch condition (body, exit) | 1444 // in branch condition (body, exit) |
| 1445 ir.Continuation exitContinuation = new ir.Continuation([]); | 1445 ir.Continuation exitContinuation = new ir.Continuation([]); |
| 1446 ir.Continuation bodyContinuation = new ir.Continuation([]); | 1446 ir.Continuation bodyContinuation = new ir.Continuation([]); |
| 1447 bodyContinuation.body = bodyBuilder._root; | 1447 bodyContinuation.body = bodyBuilder._root; |
| 1448 // Note the order of continuations: the first one is the one that will | 1448 // Note the order of continuations: the first one is the one that will |
| 1449 // be filled by LetCont.plug. | 1449 // be filled by LetCont.plug. |
| 1450 ir.LetCont branch = | 1450 ir.LetCont branch = |
| 1451 new ir.LetCont.two(exitContinuation, bodyContinuation, | 1451 new ir.LetCont.two(exitContinuation, bodyContinuation, |
| 1452 new ir.Branch(new ir.IsTrue(condition), | 1452 new ir.Branch.strict(condition, |
| 1453 bodyContinuation, | 1453 bodyContinuation, |
| 1454 exitContinuation)); | 1454 exitContinuation)); |
| 1455 // If there are breaks in the body, then there must be a join-point | 1455 // If there are breaks in the body, then there must be a join-point |
| 1456 // continuation for the normal exit and the breaks. Otherwise, the | 1456 // continuation for the normal exit and the breaks. Otherwise, the |
| 1457 // successor is translated in the hole in the exit continuation. | 1457 // successor is translated in the hole in the exit continuation. |
| 1458 bool hasBreaks = !breakCollector.isEmpty; | 1458 bool hasBreaks = !breakCollector.isEmpty; |
| 1459 ir.LetCont letBreak; | 1459 ir.LetCont letBreak; |
| 1460 if (hasBreaks) { | 1460 if (hasBreaks) { |
| 1461 IrBuilder exitBuilder = makeDelimitedBuilder(); | 1461 IrBuilder exitBuilder = makeDelimitedBuilder(); |
| 1462 exitBuilder.jumpTo(breakCollector); | 1462 exitBuilder.jumpTo(breakCollector); |
| 1463 exitContinuation.body = exitBuilder._root; | 1463 exitContinuation.body = exitBuilder._root; |
| 1464 letBreak = new ir.LetCont(breakCollector.continuation, branch); | 1464 letBreak = new ir.LetCont(breakCollector.continuation, branch); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 if (bodyBuilder.isOpen) bodyBuilder.jumpTo(loop); | 1517 if (bodyBuilder.isOpen) bodyBuilder.jumpTo(loop); |
| 1518 | 1518 |
| 1519 // Create body entry and loop exit continuations and a branch to them. | 1519 // Create body entry and loop exit continuations and a branch to them. |
| 1520 ir.Continuation exitContinuation = new ir.Continuation([]); | 1520 ir.Continuation exitContinuation = new ir.Continuation([]); |
| 1521 ir.Continuation bodyContinuation = new ir.Continuation([]); | 1521 ir.Continuation bodyContinuation = new ir.Continuation([]); |
| 1522 bodyContinuation.body = bodyBuilder._root; | 1522 bodyContinuation.body = bodyBuilder._root; |
| 1523 // Note the order of continuations: the first one is the one that will | 1523 // Note the order of continuations: the first one is the one that will |
| 1524 // be filled by LetCont.plug. | 1524 // be filled by LetCont.plug. |
| 1525 ir.LetCont branch = | 1525 ir.LetCont branch = |
| 1526 new ir.LetCont.two(exitContinuation, bodyContinuation, | 1526 new ir.LetCont.two(exitContinuation, bodyContinuation, |
| 1527 new ir.Branch(new ir.IsTrue(condition), | 1527 new ir.Branch.strict(condition, |
| 1528 bodyContinuation, | 1528 bodyContinuation, |
| 1529 exitContinuation)); | 1529 exitContinuation)); |
| 1530 // If there are breaks in the body, then there must be a join-point | 1530 // If there are breaks in the body, then there must be a join-point |
| 1531 // continuation for the normal exit and the breaks. Otherwise, the | 1531 // continuation for the normal exit and the breaks. Otherwise, the |
| 1532 // successor is translated in the hole in the exit continuation. | 1532 // successor is translated in the hole in the exit continuation. |
| 1533 bool hasBreaks = !breakCollector.isEmpty; | 1533 bool hasBreaks = !breakCollector.isEmpty; |
| 1534 ir.LetCont letBreak; | 1534 ir.LetCont letBreak; |
| 1535 if (hasBreaks) { | 1535 if (hasBreaks) { |
| 1536 IrBuilder exitBuilder = makeDelimitedBuilder(); | 1536 IrBuilder exitBuilder = makeDelimitedBuilder(); |
| 1537 exitBuilder.jumpTo(breakCollector); | 1537 exitBuilder.jumpTo(breakCollector); |
| 1538 exitContinuation.body = exitBuilder._root; | 1538 exitContinuation.body = exitBuilder._root; |
| 1539 letBreak = new ir.LetCont(breakCollector.continuation, branch); | 1539 letBreak = new ir.LetCont(breakCollector.continuation, branch); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 IrBuilder exitBuilder = continueBuilder.makeDelimitedBuilder(); | 1603 IrBuilder exitBuilder = continueBuilder.makeDelimitedBuilder(); |
| 1604 exitBuilder.jumpTo(breakCollector); | 1604 exitBuilder.jumpTo(breakCollector); |
| 1605 exitContinuation.body = exitBuilder._root; | 1605 exitContinuation.body = exitBuilder._root; |
| 1606 ir.Continuation repeatContinuation = new ir.Continuation([]); | 1606 ir.Continuation repeatContinuation = new ir.Continuation([]); |
| 1607 IrBuilder repeatBuilder = continueBuilder.makeDelimitedBuilder(); | 1607 IrBuilder repeatBuilder = continueBuilder.makeDelimitedBuilder(); |
| 1608 repeatBuilder.jumpTo(loop); | 1608 repeatBuilder.jumpTo(loop); |
| 1609 repeatContinuation.body = repeatBuilder._root; | 1609 repeatContinuation.body = repeatBuilder._root; |
| 1610 | 1610 |
| 1611 continueBuilder.add( | 1611 continueBuilder.add( |
| 1612 new ir.LetCont.two(exitContinuation, repeatContinuation, | 1612 new ir.LetCont.two(exitContinuation, repeatContinuation, |
| 1613 new ir.Branch(new ir.IsTrue(condition), | 1613 new ir.Branch.strict(condition, |
| 1614 repeatContinuation, | 1614 repeatContinuation, |
| 1615 exitContinuation))); | 1615 exitContinuation))); |
| 1616 continueCollector.continuation.body = continueBuilder._root; | 1616 continueCollector.continuation.body = continueBuilder._root; |
| 1617 | 1617 |
| 1618 // Construct the loop continuation (i.e., the body and condition). | 1618 // Construct the loop continuation (i.e., the body and condition). |
| 1619 // <Loop> = | 1619 // <Loop> = |
| 1620 // let cont continue(x, ...) = | 1620 // let cont continue(x, ...) = |
| 1621 // <Continue> | 1621 // <Continue> |
| 1622 // in [[body]]; continue(v, ...) | 1622 // in [[body]]; continue(v, ...) |
| 1623 loopBuilder.add( | 1623 loopBuilder.add( |
| 1624 new ir.LetCont(continueCollector.continuation, | 1624 new ir.LetCont(continueCollector.continuation, |
| 1625 bodyBuilder._root)); | 1625 bodyBuilder._root)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 ir.Continuation thenContinuation = new ir.Continuation([]); | 1671 ir.Continuation thenContinuation = new ir.Continuation([]); |
| 1672 thenContinuation.body = thenBuilder._root; | 1672 thenContinuation.body = thenBuilder._root; |
| 1673 ir.Continuation elseContinuation = new ir.Continuation([]); | 1673 ir.Continuation elseContinuation = new ir.Continuation([]); |
| 1674 // A LetCont.many term has a hole as the body of the first listed | 1674 // A LetCont.many term has a hole as the body of the first listed |
| 1675 // continuation, to be plugged by the translation. Therefore put the | 1675 // continuation, to be plugged by the translation. Therefore put the |
| 1676 // else continuation first. | 1676 // else continuation first. |
| 1677 casesBuilder.add( | 1677 casesBuilder.add( |
| 1678 new ir.LetCont.two(elseContinuation, thenContinuation, | 1678 new ir.LetCont.two(elseContinuation, thenContinuation, |
| 1679 new ir.Branch(new ir.IsTrue(condition), | 1679 new ir.Branch.strict(condition, |
| 1680 thenContinuation, | 1680 thenContinuation, |
| 1681 elseContinuation))); | 1681 elseContinuation))); |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 if (defaultCase != null) { | 1684 if (defaultCase != null) { |
| 1685 defaultCase.buildBody(casesBuilder); | 1685 defaultCase.buildBody(casesBuilder); |
| 1686 } | 1686 } |
| 1687 if (casesBuilder.isOpen) casesBuilder.jumpTo(join); | 1687 if (casesBuilder.isOpen) casesBuilder.jumpTo(join); |
| 1688 | 1688 |
| 1689 casesBuilder.state.breakCollectors.removeLast(); | 1689 casesBuilder.state.breakCollectors.removeLast(); |
| 1690 | 1690 |
| 1691 if (!join.isEmpty) { | 1691 if (!join.isEmpty) { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 | 1876 |
| 1877 // Build the type test guarding this clause. We can share the | 1877 // Build the type test guarding this clause. We can share the |
| 1878 // environment with the nested builder because this part cannot mutate | 1878 // environment with the nested builder because this part cannot mutate |
| 1879 // it. | 1879 // it. |
| 1880 IrBuilder checkBuilder = builder.makeDelimitedBuilder(environment); | 1880 IrBuilder checkBuilder = builder.makeDelimitedBuilder(environment); |
| 1881 ir.Primitive typeMatches = | 1881 ir.Primitive typeMatches = |
| 1882 checkBuilder.buildTypeOperator(exceptionParameter, | 1882 checkBuilder.buildTypeOperator(exceptionParameter, |
| 1883 clause.type, | 1883 clause.type, |
| 1884 isTypeTest: true); | 1884 isTypeTest: true); |
| 1885 checkBuilder.add(new ir.LetCont.two(thenContinuation, elseContinuation, | 1885 checkBuilder.add(new ir.LetCont.two(thenContinuation, elseContinuation, |
| 1886 new ir.Branch(new ir.IsTrue(typeMatches), | 1886 new ir.Branch.strict(typeMatches, |
| 1887 thenContinuation, | 1887 thenContinuation, |
| 1888 elseContinuation))); | 1888 elseContinuation))); |
| 1889 catchBody = checkBuilder._root; | 1889 catchBody = checkBuilder._root; |
| 1890 } | 1890 } |
| 1891 builder.add(catchBody); | 1891 builder.add(catchBody); |
| 1892 | 1892 |
| 1893 return <ir.Parameter>[exceptionParameter, traceParameter]; | 1893 return <ir.Parameter>[exceptionParameter, traceParameter]; |
| 1894 } | 1894 } |
| 1895 | 1895 |
| 1896 void leaveTryCatch(IrBuilder builder, JumpCollector join, | 1896 void leaveTryCatch(IrBuilder builder, JumpCollector join, |
| 1897 ir.Expression body) { | 1897 ir.Expression body) { |
| 1898 // Add the binding for the join-point continuation and continue the | 1898 // Add the binding for the join-point continuation and continue the |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 ir.Constant trueConstant = makeBoolConstant(true); | 2225 ir.Constant trueConstant = makeBoolConstant(true); |
| 2226 ir.Constant falseConstant = makeBoolConstant(false); | 2226 ir.Constant falseConstant = makeBoolConstant(false); |
| 2227 | 2227 |
| 2228 thenContinuation.body = new ir.LetPrim(falseConstant) | 2228 thenContinuation.body = new ir.LetPrim(falseConstant) |
| 2229 ..plug(new ir.InvokeContinuation(joinContinuation, [falseConstant])); | 2229 ..plug(new ir.InvokeContinuation(joinContinuation, [falseConstant])); |
| 2230 elseContinuation.body = new ir.LetPrim(trueConstant) | 2230 elseContinuation.body = new ir.LetPrim(trueConstant) |
| 2231 ..plug(new ir.InvokeContinuation(joinContinuation, [trueConstant])); | 2231 ..plug(new ir.InvokeContinuation(joinContinuation, [trueConstant])); |
| 2232 | 2232 |
| 2233 add(new ir.LetCont(joinContinuation, | 2233 add(new ir.LetCont(joinContinuation, |
| 2234 new ir.LetCont.two(thenContinuation, elseContinuation, | 2234 new ir.LetCont.two(thenContinuation, elseContinuation, |
| 2235 new ir.Branch(new ir.IsTrue(condition), | 2235 new ir.Branch.strict(condition, |
| 2236 thenContinuation, | 2236 thenContinuation, |
| 2237 elseContinuation)))); | 2237 elseContinuation)))); |
| 2238 return resultParameter; | 2238 return resultParameter; |
| 2239 } | 2239 } |
| 2240 | 2240 |
| 2241 /// Create a lazy and/or expression. [leftValue] is the value of the left | 2241 /// Create a lazy and/or expression. [leftValue] is the value of the left |
| 2242 /// operand and [buildRightValue] is called to process the value of the right | 2242 /// operand and [buildRightValue] is called to process the value of the right |
| 2243 /// operand in the context of its own [IrBuilder]. | 2243 /// operand in the context of its own [IrBuilder]. |
| 2244 ir.Primitive buildLogicalOperator( | 2244 ir.Primitive buildLogicalOperator( |
| 2245 ir.Primitive leftValue, | 2245 ir.Primitive leftValue, |
| 2246 ir.Primitive buildRightValue(IrBuilder builder), | 2246 ir.Primitive buildRightValue(IrBuilder builder), |
| 2247 {bool isLazyOr: false}) { | 2247 {bool isLazyOr: false}) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2285 rightFalseBuilder.jumpTo(join, rightFalse); | 2285 rightFalseBuilder.jumpTo(join, rightFalse); |
| 2286 ir.Continuation leftTrueContinuation = new ir.Continuation([]); | 2286 ir.Continuation leftTrueContinuation = new ir.Continuation([]); |
| 2287 ir.Continuation leftFalseContinuation = new ir.Continuation([]); | 2287 ir.Continuation leftFalseContinuation = new ir.Continuation([]); |
| 2288 ir.Continuation rightTrueContinuation = new ir.Continuation([]); | 2288 ir.Continuation rightTrueContinuation = new ir.Continuation([]); |
| 2289 ir.Continuation rightFalseContinuation = new ir.Continuation([]); | 2289 ir.Continuation rightFalseContinuation = new ir.Continuation([]); |
| 2290 rightTrueContinuation.body = rightTrueBuilder._root; | 2290 rightTrueContinuation.body = rightTrueBuilder._root; |
| 2291 rightFalseContinuation.body = rightFalseBuilder._root; | 2291 rightFalseContinuation.body = rightFalseBuilder._root; |
| 2292 // The right subexpression has two continuations. | 2292 // The right subexpression has two continuations. |
| 2293 rightBuilder.add( | 2293 rightBuilder.add( |
| 2294 new ir.LetCont.two(rightTrueContinuation, rightFalseContinuation, | 2294 new ir.LetCont.two(rightTrueContinuation, rightFalseContinuation, |
| 2295 new ir.Branch(new ir.IsTrue(rightValue), | 2295 new ir.Branch.strict(rightValue, |
| 2296 rightTrueContinuation, | 2296 rightTrueContinuation, |
| 2297 rightFalseContinuation))); | 2297 rightFalseContinuation))); |
| 2298 // Depending on the operator, the left subexpression's continuations are | 2298 // Depending on the operator, the left subexpression's continuations are |
| 2299 // either the right subexpression or an invocation of the join-point | 2299 // either the right subexpression or an invocation of the join-point |
| 2300 // continuation. | 2300 // continuation. |
| 2301 if (isLazyOr) { | 2301 if (isLazyOr) { |
| 2302 leftTrueContinuation.body = emptyBuilder._root; | 2302 leftTrueContinuation.body = emptyBuilder._root; |
| 2303 leftFalseContinuation.body = rightBuilder._root; | 2303 leftFalseContinuation.body = rightBuilder._root; |
| 2304 } else { | 2304 } else { |
| 2305 leftTrueContinuation.body = rightBuilder._root; | 2305 leftTrueContinuation.body = rightBuilder._root; |
| 2306 leftFalseContinuation.body = emptyBuilder._root; | 2306 leftFalseContinuation.body = emptyBuilder._root; |
| 2307 } | 2307 } |
| 2308 | 2308 |
| 2309 add(new ir.LetCont(join.continuation, | 2309 add(new ir.LetCont(join.continuation, |
| 2310 new ir.LetCont.two(leftTrueContinuation, leftFalseContinuation, | 2310 new ir.LetCont.two(leftTrueContinuation, leftFalseContinuation, |
| 2311 new ir.Branch(new ir.IsTrue(leftValue), | 2311 new ir.Branch.strict(leftValue, |
| 2312 leftTrueContinuation, | 2312 leftTrueContinuation, |
| 2313 leftFalseContinuation)))); | 2313 leftFalseContinuation)))); |
| 2314 environment = join.environment; | 2314 environment = join.environment; |
| 2315 return environment.discard(1); | 2315 return environment.discard(1); |
| 2316 } | 2316 } |
| 2317 | 2317 |
| 2318 ir.Primitive buildIdentical(ir.Primitive x, ir.Primitive y, | 2318 ir.Primitive buildIdentical(ir.Primitive x, ir.Primitive y, |
| 2319 {SourceInformation sourceInformation}) { | 2319 {SourceInformation sourceInformation}) { |
| 2320 return addPrimitive(new ir.ApplyBuiltinOperator( | 2320 return addPrimitive(new ir.ApplyBuiltinOperator( |
| 2321 ir.BuiltinOperator.Identical, <ir.Primitive>[x, y], | 2321 ir.BuiltinOperator.Identical, <ir.Primitive>[x, y], |
| 2322 sourceInformation)); | 2322 sourceInformation)); |
| 2323 } | 2323 } |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 } | 2879 } |
| 2880 | 2880 |
| 2881 class SwitchCaseInfo { | 2881 class SwitchCaseInfo { |
| 2882 final List<ir.Primitive> constants = <ir.Primitive>[]; | 2882 final List<ir.Primitive> constants = <ir.Primitive>[]; |
| 2883 final SubbuildFunction buildBody; | 2883 final SubbuildFunction buildBody; |
| 2884 | 2884 |
| 2885 SwitchCaseInfo(this.buildBody); | 2885 SwitchCaseInfo(this.buildBody); |
| 2886 | 2886 |
| 2887 void addConstant(ir.Primitive constant) => constants.add(constant); | 2887 void addConstant(ir.Primitive constant) => constants.add(constant); |
| 2888 } | 2888 } |
| OLD | NEW |