| 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_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closure; | 7 import '../closure.dart' as closure; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/names.dart' show | 9 import '../common/names.dart' show |
| 10 Identifiers, | 10 Identifiers, |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 buildUpdate: subbuildSequence(node.update), | 1083 buildUpdate: subbuildSequence(node.update), |
| 1084 closureScope: getClosureScopeForNode(node), | 1084 closureScope: getClosureScopeForNode(node), |
| 1085 loopVariables: loopVariables, | 1085 loopVariables: loopVariables, |
| 1086 target: target); | 1086 target: target); |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 visitIf(ast.If node) { | 1089 visitIf(ast.If node) { |
| 1090 irBuilder.buildIf( | 1090 irBuilder.buildIf( |
| 1091 build(node.condition), | 1091 build(node.condition), |
| 1092 subbuild(node.thenPart), | 1092 subbuild(node.thenPart), |
| 1093 subbuild(node.elsePart)); | 1093 subbuild(node.elsePart), |
| 1094 sourceInformationBuilder.buildIf(node)); |
| 1094 } | 1095 } |
| 1095 | 1096 |
| 1096 visitLabeledStatement(ast.LabeledStatement node) { | 1097 visitLabeledStatement(ast.LabeledStatement node) { |
| 1097 ast.Statement body = node.statement; | 1098 ast.Statement body = node.statement; |
| 1098 if (body is ast.Loop) { | 1099 if (body is ast.Loop) { |
| 1099 visit(body); | 1100 visit(body); |
| 1100 } else { | 1101 } else { |
| 1101 JumpTarget target = elements.getTargetDefinition(body); | 1102 JumpTarget target = elements.getTargetDefinition(body); |
| 1102 irBuilder.buildLabeledStatement( | 1103 irBuilder.buildLabeledStatement( |
| 1103 buildBody: subbuild(body), | 1104 buildBody: subbuild(body), |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 ir.Primitive buildComparison() { | 1487 ir.Primitive buildComparison() { |
| 1487 ir.Primitive constant = | 1488 ir.Primitive constant = |
| 1488 translateConstant(labelOrCase.expression); | 1489 translateConstant(labelOrCase.expression); |
| 1489 return irBuilder.buildIdentical(value, constant); | 1490 return irBuilder.buildIdentical(value, constant); |
| 1490 } | 1491 } |
| 1491 | 1492 |
| 1492 if (condition == null) { | 1493 if (condition == null) { |
| 1493 condition = buildComparison(); | 1494 condition = buildComparison(); |
| 1494 } else { | 1495 } else { |
| 1495 condition = irBuilder.buildLogicalOperator(condition, | 1496 condition = irBuilder.buildLogicalOperator(condition, |
| 1496 nested(buildComparison), isLazyOr: true); | 1497 nested(buildComparison), |
| 1498 sourceInformationBuilder.buildSwitchCase(switchCase), |
| 1499 isLazyOr: true); |
| 1497 } | 1500 } |
| 1498 } | 1501 } |
| 1499 } | 1502 } |
| 1500 return condition; | 1503 return condition; |
| 1501 }); | 1504 }); |
| 1502 } | 1505 } |
| 1503 | 1506 |
| 1504 SubbuildFunction buildBody; | 1507 SubbuildFunction buildBody; |
| 1505 if (nextContinueTarget != null && | 1508 if (nextContinueTarget != null && |
| 1506 switchCase == nextContinueTarget.statement) { | 1509 switchCase == nextContinueTarget.statement) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1527 <ir.Primitive>[], | 1530 <ir.Primitive>[], |
| 1528 sourceInformationBuilder.buildGeneric(node)); | 1531 sourceInformationBuilder.buildGeneric(node)); |
| 1529 irBuilder.buildThrow(exception); | 1532 irBuilder.buildThrow(exception); |
| 1530 } | 1533 } |
| 1531 } | 1534 } |
| 1532 }); | 1535 }); |
| 1533 return null; | 1536 return null; |
| 1534 }; | 1537 }; |
| 1535 } | 1538 } |
| 1536 | 1539 |
| 1537 cases.add(new SwitchCaseInfo(buildCondition, buildBody)); | 1540 cases.add(new SwitchCaseInfo(buildCondition, buildBody, |
| 1541 sourceInformationBuilder.buildSwitchCase(switchCase))); |
| 1538 } | 1542 } |
| 1539 | 1543 |
| 1540 irBuilder.buildSimpleSwitch(join, cases, buildDefaultBody); | 1544 irBuilder.buildSimpleSwitch(join, cases, buildDefaultBody); |
| 1541 irBuilder.state.breakCollectors.removeLast(); | 1545 irBuilder.state.breakCollectors.removeLast(); |
| 1542 irBuilder.state.continueCollectors.length -= continueTargets.length; | 1546 irBuilder.state.continueCollectors.length -= continueTargets.length; |
| 1543 if (continueTargets.isEmpty) return; | 1547 if (continueTargets.isEmpty) return; |
| 1544 | 1548 |
| 1545 // If there were recursive cases build a while loop whose body is a | 1549 // If there were recursive cases build a while loop whose body is a |
| 1546 // switch containing (only) the recursive cases. The condition is | 1550 // switch containing (only) the recursive cases. The condition is |
| 1547 // 'state != initialValue' so the loop is not taken when the state variable | 1551 // 'state != initialValue' so the loop is not taken when the state variable |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 new Selector.fromElement(error), | 1585 new Selector.fromElement(error), |
| 1582 <ir.Primitive>[], | 1586 <ir.Primitive>[], |
| 1583 sourceInformationBuilder.buildGeneric(node)); | 1587 sourceInformationBuilder.buildGeneric(node)); |
| 1584 irBuilder.buildThrow(exception); | 1588 irBuilder.buildThrow(exception); |
| 1585 } | 1589 } |
| 1586 } | 1590 } |
| 1587 }); | 1591 }); |
| 1588 return null; | 1592 return null; |
| 1589 } | 1593 } |
| 1590 | 1594 |
| 1591 cases.add(new SwitchCaseInfo(buildCondition, buildBody)); | 1595 cases.add(new SwitchCaseInfo(buildCondition, buildBody, |
| 1596 sourceInformationBuilder.buildSwitch(node))); |
| 1592 } | 1597 } |
| 1593 | 1598 |
| 1594 // A loop with a simple switch in the body. | 1599 // A loop with a simple switch in the body. |
| 1595 IrBuilder whileBuilder = irBuilder.makeDelimitedBuilder(); | 1600 IrBuilder whileBuilder = irBuilder.makeDelimitedBuilder(); |
| 1596 whileBuilder.buildWhile( | 1601 whileBuilder.buildWhile( |
| 1597 buildCondition: (IrBuilder builder) { | 1602 buildCondition: (IrBuilder builder) { |
| 1598 ir.Primitive condition = builder.buildIdentical( | 1603 ir.Primitive condition = builder.buildIdentical( |
| 1599 builder.environment.index2value[stateIndex], initial); | 1604 builder.environment.index2value[stateIndex], initial); |
| 1600 return builder.buildNegation(condition); | 1605 return builder.buildNegation(condition, |
| 1606 sourceInformationBuilder.buildSwitch(node)); |
| 1601 }, | 1607 }, |
| 1602 buildBody: (IrBuilder builder) { | 1608 buildBody: (IrBuilder builder) { |
| 1603 builder.buildSimpleSwitch(loop, cases, null); | 1609 builder.buildSimpleSwitch(loop, cases, null); |
| 1604 }); | 1610 }); |
| 1605 // Jump to the exit continuation. This jump is the body of the loop exit | 1611 // Jump to the exit continuation. This jump is the body of the loop exit |
| 1606 // continuation, so the loop exit continuation can be eta-reduced. The | 1612 // continuation, so the loop exit continuation can be eta-reduced. The |
| 1607 // jump is here for simplicity because `buildWhile` does not expose the | 1613 // jump is here for simplicity because `buildWhile` does not expose the |
| 1608 // loop's exit continuation directly and has already emitted all jumps | 1614 // loop's exit continuation directly and has already emitted all jumps |
| 1609 // to it anyway. | 1615 // to it anyway. |
| 1610 whileBuilder.jumpTo(exit); | 1616 whileBuilder.jumpTo(exit); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 subbuild(node.tryBlock), | 1667 subbuild(node.tryBlock), |
| 1662 subbuild(node.finallyBlock)); | 1668 subbuild(node.finallyBlock)); |
| 1663 } | 1669 } |
| 1664 } | 1670 } |
| 1665 | 1671 |
| 1666 // ## Expressions ## | 1672 // ## Expressions ## |
| 1667 ir.Primitive visitConditional(ast.Conditional node) { | 1673 ir.Primitive visitConditional(ast.Conditional node) { |
| 1668 return irBuilder.buildConditional( | 1674 return irBuilder.buildConditional( |
| 1669 build(node.condition), | 1675 build(node.condition), |
| 1670 subbuild(node.thenExpression), | 1676 subbuild(node.thenExpression), |
| 1671 subbuild(node.elseExpression)); | 1677 subbuild(node.elseExpression), |
| 1678 sourceInformationBuilder.buildIf(node)); |
| 1672 } | 1679 } |
| 1673 | 1680 |
| 1674 // For all simple literals: | 1681 // For all simple literals: |
| 1675 // Build(Literal(c), C) = C[let val x = Constant(c) in [], x] | 1682 // Build(Literal(c), C) = C[let val x = Constant(c) in [], x] |
| 1676 ir.Primitive visitLiteralBool(ast.LiteralBool node) { | 1683 ir.Primitive visitLiteralBool(ast.LiteralBool node) { |
| 1677 assert(irBuilder.isOpen); | 1684 assert(irBuilder.isOpen); |
| 1678 return irBuilder.buildBooleanConstant(node.value); | 1685 return irBuilder.buildBooleanConstant(node.value); |
| 1679 } | 1686 } |
| 1680 | 1687 |
| 1681 ir.Primitive visitLiteralDouble(ast.LiteralDouble node) { | 1688 ir.Primitive visitLiteralDouble(ast.LiteralDouble node) { |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 ast.Node receiver, | 1927 ast.Node receiver, |
| 1921 Name name, | 1928 Name name, |
| 1922 _) { | 1929 _) { |
| 1923 ir.Primitive target = visit(receiver); | 1930 ir.Primitive target = visit(receiver); |
| 1924 return irBuilder.buildIfNotNullSend( | 1931 return irBuilder.buildIfNotNullSend( |
| 1925 target, | 1932 target, |
| 1926 nested(() => irBuilder.buildDynamicGet( | 1933 nested(() => irBuilder.buildDynamicGet( |
| 1927 target, | 1934 target, |
| 1928 new Selector.getter(name), | 1935 new Selector.getter(name), |
| 1929 elements.getTypeMask(node), | 1936 elements.getTypeMask(node), |
| 1930 sourceInformationBuilder.buildGet(node)))); | 1937 sourceInformationBuilder.buildGet(node))), |
| 1938 sourceInformationBuilder.buildIf(node)); |
| 1931 } | 1939 } |
| 1932 | 1940 |
| 1933 @override | 1941 @override |
| 1934 ir.Primitive visitDynamicTypeLiteralGet( | 1942 ir.Primitive visitDynamicTypeLiteralGet( |
| 1935 ast.Send node, | 1943 ast.Send node, |
| 1936 ConstantExpression constant, | 1944 ConstantExpression constant, |
| 1937 _) { | 1945 _) { |
| 1938 return buildConstantExpression(constant, | 1946 return buildConstantExpression(constant, |
| 1939 sourceInformationBuilder.buildGet(node)); | 1947 sourceInformationBuilder.buildGet(node)); |
| 1940 } | 1948 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 | 2067 |
| 2060 @override | 2068 @override |
| 2061 ir.Primitive visitTypeVariableTypeLiteralGet(ast.Send node, | 2069 ir.Primitive visitTypeVariableTypeLiteralGet(ast.Send node, |
| 2062 TypeVariableElement element, _) { | 2070 TypeVariableElement element, _) { |
| 2063 return translateTypeVariableTypeLiteral(element, | 2071 return translateTypeVariableTypeLiteral(element, |
| 2064 sourceInformationBuilder.buildGet(node)); | 2072 sourceInformationBuilder.buildGet(node)); |
| 2065 } | 2073 } |
| 2066 | 2074 |
| 2067 ir.Primitive translateLogicalOperator(ast.Expression left, | 2075 ir.Primitive translateLogicalOperator(ast.Expression left, |
| 2068 ast.Expression right, | 2076 ast.Expression right, |
| 2077 SourceInformation sourceInformation, |
| 2069 {bool isLazyOr}) { | 2078 {bool isLazyOr}) { |
| 2070 ir.Primitive leftValue = visit(left); | 2079 ir.Primitive leftValue = visit(left); |
| 2071 | 2080 |
| 2072 ir.Primitive buildRightValue(IrBuilder rightBuilder) { | 2081 ir.Primitive buildRightValue(IrBuilder rightBuilder) { |
| 2073 return withBuilder(rightBuilder, () => visit(right)); | 2082 return withBuilder(rightBuilder, () => visit(right)); |
| 2074 } | 2083 } |
| 2075 | 2084 |
| 2076 return irBuilder.buildLogicalOperator( | 2085 return irBuilder.buildLogicalOperator( |
| 2077 leftValue, buildRightValue, isLazyOr: isLazyOr); | 2086 leftValue, buildRightValue, sourceInformation, isLazyOr: isLazyOr); |
| 2078 } | 2087 } |
| 2079 | 2088 |
| 2080 @override | 2089 @override |
| 2081 ir.Primitive visitIfNull( | 2090 ir.Primitive visitIfNull( |
| 2082 ast.Send node, ast.Node left, ast.Node right, _) { | 2091 ast.Send node, ast.Node left, ast.Node right, _) { |
| 2083 return irBuilder.buildIfNull(build(left), subbuild(right)); | 2092 return irBuilder.buildIfNull(build(left), subbuild(right), |
| 2093 sourceInformationBuilder.buildIf(node)); |
| 2084 } | 2094 } |
| 2085 | 2095 |
| 2086 @override | 2096 @override |
| 2087 ir.Primitive visitLogicalAnd( | 2097 ir.Primitive visitLogicalAnd( |
| 2088 ast.Send node, ast.Node left, ast.Node right, _) { | 2098 ast.Send node, ast.Node left, ast.Node right, _) { |
| 2089 return translateLogicalOperator(left, right, isLazyOr: false); | 2099 return translateLogicalOperator(left, right, |
| 2100 sourceInformationBuilder.buildIf(node), isLazyOr: false); |
| 2090 } | 2101 } |
| 2091 | 2102 |
| 2092 @override | 2103 @override |
| 2093 ir.Primitive visitLogicalOr( | 2104 ir.Primitive visitLogicalOr( |
| 2094 ast.Send node, ast.Node left, ast.Node right, _) { | 2105 ast.Send node, ast.Node left, ast.Node right, _) { |
| 2095 return translateLogicalOperator(left, right, isLazyOr: true); | 2106 return translateLogicalOperator(left, right, |
| 2107 sourceInformationBuilder.buildIf(node), isLazyOr: true); |
| 2096 } | 2108 } |
| 2097 | 2109 |
| 2098 @override | 2110 @override |
| 2099 ir.Primitive visitAs( | 2111 ir.Primitive visitAs( |
| 2100 ast.Send node, | 2112 ast.Send node, |
| 2101 ast.Node expression, | 2113 ast.Node expression, |
| 2102 DartType type, | 2114 DartType type, |
| 2103 _) { | 2115 _) { |
| 2104 ir.Primitive receiver = visit(expression); | 2116 ir.Primitive receiver = visit(expression); |
| 2105 return irBuilder.buildTypeOperator( | 2117 return irBuilder.buildTypeOperator( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2125 | 2137 |
| 2126 @override | 2138 @override |
| 2127 ir.Primitive visitIsNot(ast.Send node, | 2139 ir.Primitive visitIsNot(ast.Send node, |
| 2128 ast.Node expression, DartType type, _) { | 2140 ast.Node expression, DartType type, _) { |
| 2129 ir.Primitive value = visit(expression); | 2141 ir.Primitive value = visit(expression); |
| 2130 ir.Primitive check = irBuilder.buildTypeOperator( | 2142 ir.Primitive check = irBuilder.buildTypeOperator( |
| 2131 value, | 2143 value, |
| 2132 type, | 2144 type, |
| 2133 sourceInformationBuilder.buildIs(node), | 2145 sourceInformationBuilder.buildIs(node), |
| 2134 isTypeTest: true); | 2146 isTypeTest: true); |
| 2135 return irBuilder.buildNegation(check); | 2147 return irBuilder.buildNegation(check, |
| 2148 sourceInformationBuilder.buildIf(node)); |
| 2136 } | 2149 } |
| 2137 | 2150 |
| 2138 ir.Primitive translateBinary(ast.Send node, | 2151 ir.Primitive translateBinary(ast.Send node, |
| 2139 ast.Node left, | 2152 ast.Node left, |
| 2140 op.BinaryOperator operator, | 2153 op.BinaryOperator operator, |
| 2141 ast.Node right) { | 2154 ast.Node right) { |
| 2142 ir.Primitive receiver = visit(left); | 2155 ir.Primitive receiver = visit(left); |
| 2143 Selector selector = new Selector.binaryOperator(operator.selectorName); | 2156 Selector selector = new Selector.binaryOperator(operator.selectorName); |
| 2144 List<ir.Primitive> arguments = <ir.Primitive>[visit(right)]; | 2157 List<ir.Primitive> arguments = <ir.Primitive>[visit(right)]; |
| 2145 CallStructure callStructure = | 2158 CallStructure callStructure = |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 _) { | 2237 _) { |
| 2225 return translateSuperBinary(function, op.BinaryOperator.EQ, argument, | 2238 return translateSuperBinary(function, op.BinaryOperator.EQ, argument, |
| 2226 sourceInformationBuilder.buildBinary(node)); | 2239 sourceInformationBuilder.buildBinary(node)); |
| 2227 } | 2240 } |
| 2228 | 2241 |
| 2229 @override | 2242 @override |
| 2230 ir.Primitive visitNot( | 2243 ir.Primitive visitNot( |
| 2231 ast.Send node, | 2244 ast.Send node, |
| 2232 ast.Node expression, | 2245 ast.Node expression, |
| 2233 _) { | 2246 _) { |
| 2234 return irBuilder.buildNegation(visit(expression)); | 2247 return irBuilder.buildNegation(visit(expression), |
| 2248 sourceInformationBuilder.buildIf(node)); |
| 2235 } | 2249 } |
| 2236 | 2250 |
| 2237 @override | 2251 @override |
| 2238 ir.Primitive visitNotEquals( | 2252 ir.Primitive visitNotEquals( |
| 2239 ast.Send node, | 2253 ast.Send node, |
| 2240 ast.Node left, | 2254 ast.Node left, |
| 2241 ast.Node right, | 2255 ast.Node right, |
| 2242 _) { | 2256 _) { |
| 2243 return irBuilder.buildNegation( | 2257 return irBuilder.buildNegation( |
| 2244 translateBinary(node, left, op.BinaryOperator.NOT_EQ, right)); | 2258 translateBinary(node, left, op.BinaryOperator.NOT_EQ, right), |
| 2259 sourceInformationBuilder.buildIf(node)); |
| 2245 } | 2260 } |
| 2246 | 2261 |
| 2247 @override | 2262 @override |
| 2248 ir.Primitive visitSuperNotEquals( | 2263 ir.Primitive visitSuperNotEquals( |
| 2249 ast.Send node, | 2264 ast.Send node, |
| 2250 FunctionElement function, | 2265 FunctionElement function, |
| 2251 ast.Node argument, | 2266 ast.Node argument, |
| 2252 _) { | 2267 _) { |
| 2253 return irBuilder.buildNegation( | 2268 return irBuilder.buildNegation( |
| 2254 translateSuperBinary(function, op.BinaryOperator.NOT_EQ, argument, | 2269 translateSuperBinary(function, op.BinaryOperator.NOT_EQ, argument, |
| 2255 sourceInformationBuilder.buildBinary(node))); | 2270 sourceInformationBuilder.buildBinary(node)), |
| 2271 sourceInformationBuilder.buildIf(node)); |
| 2256 } | 2272 } |
| 2257 | 2273 |
| 2258 @override | 2274 @override |
| 2259 ir.Primitive visitUnary(ast.Send node, | 2275 ir.Primitive visitUnary(ast.Send node, |
| 2260 op.UnaryOperator operator, ast.Node expression, _) { | 2276 op.UnaryOperator operator, ast.Node expression, _) { |
| 2261 // TODO(johnniwinther): Clean up the creation of selectors. | 2277 // TODO(johnniwinther): Clean up the creation of selectors. |
| 2262 Selector selector = operator.selector; | 2278 Selector selector = operator.selector; |
| 2263 ir.Primitive receiver = translateReceiver(expression); | 2279 ir.Primitive receiver = translateReceiver(expression); |
| 2264 return irBuilder.buildDynamicInvocation( | 2280 return irBuilder.buildDynamicInvocation( |
| 2265 receiver, selector, elements.getTypeMask(node), const [], | 2281 receiver, selector, elements.getTypeMask(node), const [], |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 nested(() { | 2436 nested(() { |
| 2421 List<ir.Primitive> arguments = <ir.Primitive>[]; | 2437 List<ir.Primitive> arguments = <ir.Primitive>[]; |
| 2422 CallStructure callStructure = translateDynamicArguments( | 2438 CallStructure callStructure = translateDynamicArguments( |
| 2423 argumentsNode, selector.callStructure, arguments); | 2439 argumentsNode, selector.callStructure, arguments); |
| 2424 return irBuilder.buildDynamicInvocation( | 2440 return irBuilder.buildDynamicInvocation( |
| 2425 target, | 2441 target, |
| 2426 new Selector(selector.kind, selector.memberName, callStructure), | 2442 new Selector(selector.kind, selector.memberName, callStructure), |
| 2427 elements.getTypeMask(node), | 2443 elements.getTypeMask(node), |
| 2428 arguments, | 2444 arguments, |
| 2429 sourceInformationBuilder.buildCall(node, node.selector)); | 2445 sourceInformationBuilder.buildCall(node, node.selector)); |
| 2430 })); | 2446 }), |
| 2447 sourceInformationBuilder.buildIf(node)); |
| 2431 } | 2448 } |
| 2432 | 2449 |
| 2433 ir.Primitive handleLocalInvoke( | 2450 ir.Primitive handleLocalInvoke( |
| 2434 ast.Send node, | 2451 ast.Send node, |
| 2435 LocalElement element, | 2452 LocalElement element, |
| 2436 ast.NodeList argumentsNode, | 2453 ast.NodeList argumentsNode, |
| 2437 CallStructure callStructure, | 2454 CallStructure callStructure, |
| 2438 _) { | 2455 _) { |
| 2439 ir.Primitive function = irBuilder.buildLocalGet(element); | 2456 ir.Primitive function = irBuilder.buildLocalGet(element); |
| 2440 List<ir.Primitive> arguments = <ir.Primitive>[]; | 2457 List<ir.Primitive> arguments = <ir.Primitive>[]; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2674 void setValue(ir.Primitive value)) { | 2691 void setValue(ir.Primitive value)) { |
| 2675 ir.Primitive value = getValue(); | 2692 ir.Primitive value = getValue(); |
| 2676 op.BinaryOperator operator = rhs.operator; | 2693 op.BinaryOperator operator = rhs.operator; |
| 2677 if (operator.kind == op.BinaryOperatorKind.IF_NULL) { | 2694 if (operator.kind == op.BinaryOperatorKind.IF_NULL) { |
| 2678 // Unlike other compound operators if-null conditionally will not do the | 2695 // Unlike other compound operators if-null conditionally will not do the |
| 2679 // assignment operation. | 2696 // assignment operation. |
| 2680 return irBuilder.buildIfNull(value, nested(() { | 2697 return irBuilder.buildIfNull(value, nested(() { |
| 2681 ir.Primitive newValue = build(rhs.rhs); | 2698 ir.Primitive newValue = build(rhs.rhs); |
| 2682 setValue(newValue); | 2699 setValue(newValue); |
| 2683 return newValue; | 2700 return newValue; |
| 2684 })); | 2701 }), |
| 2702 sourceInformationBuilder.buildIf(node)); |
| 2685 } | 2703 } |
| 2686 | 2704 |
| 2687 Selector operatorSelector = | 2705 Selector operatorSelector = |
| 2688 new Selector.binaryOperator(operator.selectorName); | 2706 new Selector.binaryOperator(operator.selectorName); |
| 2689 ir.Primitive rhsValue; | 2707 ir.Primitive rhsValue; |
| 2690 if (rhs.kind == CompoundKind.ASSIGNMENT) { | 2708 if (rhs.kind == CompoundKind.ASSIGNMENT) { |
| 2691 rhsValue = visit(rhs.rhs); | 2709 rhsValue = visit(rhs.rhs); |
| 2692 } else { | 2710 } else { |
| 2693 rhsValue = irBuilder.buildIntegerConstant(1); | 2711 rhsValue = irBuilder.buildIntegerConstant(1); |
| 2694 } | 2712 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2715 ir.Primitive getValue(), | 2733 ir.Primitive getValue(), |
| 2716 ast.Node rhs, | 2734 ast.Node rhs, |
| 2717 void setValue(ir.Primitive value)) { | 2735 void setValue(ir.Primitive value)) { |
| 2718 ir.Primitive value = getValue(); | 2736 ir.Primitive value = getValue(); |
| 2719 // Unlike other compound operators if-null conditionally will not do the | 2737 // Unlike other compound operators if-null conditionally will not do the |
| 2720 // assignment operation. | 2738 // assignment operation. |
| 2721 return irBuilder.buildIfNull(value, nested(() { | 2739 return irBuilder.buildIfNull(value, nested(() { |
| 2722 ir.Primitive newValue = build(rhs); | 2740 ir.Primitive newValue = build(rhs); |
| 2723 setValue(newValue); | 2741 setValue(newValue); |
| 2724 return newValue; | 2742 return newValue; |
| 2725 })); | 2743 }), |
| 2744 sourceInformationBuilder.buildIf(node)); |
| 2726 } | 2745 } |
| 2727 | 2746 |
| 2728 @override | 2747 @override |
| 2729 ir.Primitive handleDynamicSet( | 2748 ir.Primitive handleDynamicSet( |
| 2730 ast.SendSet node, | 2749 ast.SendSet node, |
| 2731 ast.Node receiver, | 2750 ast.Node receiver, |
| 2732 Name name, | 2751 Name name, |
| 2733 ast.Node rhs, | 2752 ast.Node rhs, |
| 2734 _) { | 2753 _) { |
| 2735 return irBuilder.buildDynamicSet( | 2754 return irBuilder.buildDynamicSet( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2748 ast.Node rhs, | 2767 ast.Node rhs, |
| 2749 _) { | 2768 _) { |
| 2750 ir.Primitive target = visit(receiver); | 2769 ir.Primitive target = visit(receiver); |
| 2751 return irBuilder.buildIfNotNullSend( | 2770 return irBuilder.buildIfNotNullSend( |
| 2752 target, | 2771 target, |
| 2753 nested(() => irBuilder.buildDynamicSet( | 2772 nested(() => irBuilder.buildDynamicSet( |
| 2754 target, | 2773 target, |
| 2755 new Selector.setter(name), | 2774 new Selector.setter(name), |
| 2756 elements.getTypeMask(node), | 2775 elements.getTypeMask(node), |
| 2757 visit(rhs), | 2776 visit(rhs), |
| 2758 sourceInformationBuilder.buildAssignment(node)))); | 2777 sourceInformationBuilder.buildAssignment(node))), |
| 2778 sourceInformationBuilder.buildIf(node)); |
| 2759 } | 2779 } |
| 2760 | 2780 |
| 2761 @override | 2781 @override |
| 2762 ir.Primitive handleLocalSet( | 2782 ir.Primitive handleLocalSet( |
| 2763 ast.SendSet node, | 2783 ast.SendSet node, |
| 2764 LocalElement element, | 2784 LocalElement element, |
| 2765 ast.Node rhs, | 2785 ast.Node rhs, |
| 2766 _) { | 2786 _) { |
| 2767 ir.Primitive value = visit(rhs); | 2787 ir.Primitive value = visit(rhs); |
| 2768 value = checkTypeVsElement(value, element); | 2788 value = checkTypeVsElement(value, element); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2865 }, rhs, (ir.Primitive result) { | 2885 }, rhs, (ir.Primitive result) { |
| 2866 irBuilder.buildDynamicSet( | 2886 irBuilder.buildDynamicSet( |
| 2867 target, | 2887 target, |
| 2868 new Selector.setter(name), | 2888 new Selector.setter(name), |
| 2869 elements.getTypeMask(node), | 2889 elements.getTypeMask(node), |
| 2870 result, | 2890 result, |
| 2871 sourceInformationBuilder.buildAssignment(node)); | 2891 sourceInformationBuilder.buildAssignment(node)); |
| 2872 }); | 2892 }); |
| 2873 } | 2893 } |
| 2874 return node.isConditional | 2894 return node.isConditional |
| 2875 ? irBuilder.buildIfNotNullSend(target, nested(helper)) | 2895 ? irBuilder.buildIfNotNullSend( |
| 2896 target, nested(helper), sourceInformationBuilder.buildIf(node)) |
| 2876 : helper(); | 2897 : helper(); |
| 2877 } | 2898 } |
| 2878 | 2899 |
| 2879 @override | 2900 @override |
| 2880 ir.Primitive handleDynamicSetIfNulls( | 2901 ir.Primitive handleDynamicSetIfNulls( |
| 2881 ast.Send node, | 2902 ast.Send node, |
| 2882 ast.Node receiver, | 2903 ast.Node receiver, |
| 2883 Name name, | 2904 Name name, |
| 2884 ast.Node rhs, | 2905 ast.Node rhs, |
| 2885 _) { | 2906 _) { |
| 2886 ir.Primitive target = translateReceiver(receiver); | 2907 ir.Primitive target = translateReceiver(receiver); |
| 2887 ir.Primitive helper() { | 2908 ir.Primitive helper() { |
| 2888 return translateSetIfNull(node, () { | 2909 return translateSetIfNull(node, () { |
| 2889 return irBuilder.buildDynamicGet( | 2910 return irBuilder.buildDynamicGet( |
| 2890 target, | 2911 target, |
| 2891 new Selector.getter(name), | 2912 new Selector.getter(name), |
| 2892 elements.getGetterTypeMaskInComplexSendSet(node), | 2913 elements.getGetterTypeMaskInComplexSendSet(node), |
| 2893 sourceInformationBuilder.buildGet(node)); | 2914 sourceInformationBuilder.buildGet(node)); |
| 2894 }, rhs, (ir.Primitive result) { | 2915 }, rhs, (ir.Primitive result) { |
| 2895 irBuilder.buildDynamicSet( | 2916 irBuilder.buildDynamicSet( |
| 2896 target, | 2917 target, |
| 2897 new Selector.setter(name), | 2918 new Selector.setter(name), |
| 2898 elements.getTypeMask(node), | 2919 elements.getTypeMask(node), |
| 2899 result, | 2920 result, |
| 2900 sourceInformationBuilder.buildAssignment(node)); | 2921 sourceInformationBuilder.buildAssignment(node)); |
| 2901 }); | 2922 }); |
| 2902 } | 2923 } |
| 2903 return node.isConditional | 2924 return node.isConditional |
| 2904 ? irBuilder.buildIfNotNullSend(target, nested(helper)) | 2925 ? irBuilder.buildIfNotNullSend( |
| 2926 target, nested(helper), sourceInformationBuilder.buildIf(node)) |
| 2905 : helper(); | 2927 : helper(); |
| 2906 } | 2928 } |
| 2907 | 2929 |
| 2908 ir.Primitive buildLocalNoSuchSetter( | 2930 ir.Primitive buildLocalNoSuchSetter( |
| 2909 LocalElement local, | 2931 LocalElement local, |
| 2910 ir.Primitive value, | 2932 ir.Primitive value, |
| 2911 SourceInformation sourceInformation) { | 2933 SourceInformation sourceInformation) { |
| 2912 Selector selector = new Selector.setter( | 2934 Selector selector = new Selector.setter( |
| 2913 new Name(local.name, local.library, isSetter: true)); | 2935 new Name(local.name, local.library, isSetter: true)); |
| 2914 return irBuilder.buildStaticNoSuchMethod( | 2936 return irBuilder.buildStaticNoSuchMethod( |
| (...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4202 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); | 4224 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); |
| 4203 | 4225 |
| 4204 String getJsInteropTargetPath(FunctionElement element) { | 4226 String getJsInteropTargetPath(FunctionElement element) { |
| 4205 return '${_backend.namer.fixedBackendPath(element)}.' | 4227 return '${_backend.namer.fixedBackendPath(element)}.' |
| 4206 '${_backend.getFixedBackendName(element)}'; | 4228 '${_backend.getFixedBackendName(element)}'; |
| 4207 } | 4229 } |
| 4208 | 4230 |
| 4209 DartType get jsJavascriptObjectType => | 4231 DartType get jsJavascriptObjectType => |
| 4210 _backend.helpers.jsJavaScriptObjectClass.thisType; | 4232 _backend.helpers.jsJavaScriptObjectClass.thisType; |
| 4211 } | 4233 } |
| OLD | NEW |