| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 value, | 1452 value, |
| 1453 compiler.boolClass, | 1453 compiler.boolClass, |
| 1454 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); | 1454 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); |
| 1455 } | 1455 } |
| 1456 HInstruction result = new HBoolify(value); | 1456 HInstruction result = new HBoolify(value); |
| 1457 add(result); | 1457 add(result); |
| 1458 return result; | 1458 return result; |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 HInstruction attachPosition(HInstruction target, Node node) { | 1461 HInstruction attachPosition(HInstruction target, Node node) { |
| 1462 target.sourcePosition = sourceFileLocationForToken(node.getBeginToken()); | 1462 target.sourcePosition = sourceFileLocationForBeginToken(node); |
| 1463 return target; | 1463 return target; |
| 1464 } | 1464 } |
| 1465 | 1465 |
| 1466 SourceFileLocation sourceFileLocationForToken(Token token) { | 1466 SourceFileLocation sourceFileLocationForBeginToken(Node node) => |
| 1467 sourceFileLocationForToken(node, node.getBeginToken()); |
| 1468 |
| 1469 SourceFileLocation sourceFileLocationForEndToken(Node node) => |
| 1470 sourceFileLocationForToken(node, node.getEndToken()); |
| 1471 |
| 1472 SourceFileLocation sourceFileLocationForToken(Node node, Token token) { |
| 1467 Element element = sourceElementStack.last(); | 1473 Element element = sourceElementStack.last(); |
| 1468 // TODO(johnniwinther): remove the 'element.patch' hack. | 1474 // TODO(johnniwinther): remove the 'element.patch' hack. |
| 1469 if (element is FunctionElement) { | 1475 if (element is FunctionElement) { |
| 1470 FunctionElement functionElement = element; | 1476 FunctionElement functionElement = element; |
| 1471 if (functionElement.patch != null) element = functionElement.patch; | 1477 if (functionElement.patch != null) element = functionElement.patch; |
| 1472 } | 1478 } |
| 1473 SourceFile sourceFile = element.getCompilationUnit().script.file; | 1479 Script script = element.getCompilationUnit().script; |
| 1474 return new SourceFileLocation(sourceFile, token); | 1480 SourceFile sourceFile = script.file; |
| 1475 } | 1481 SourceFileLocation location = new SourceFileLocation(sourceFile, token); |
| 1482 if (!location.isValid()) { |
| 1483 throw MessageKind.INVALID_SOURCE_FILE_LOCATION.message( |
| 1484 [token.charOffset, sourceFile.filename, sourceFile.text.length]); |
| 1485 } |
| 1486 return location; |
| 1487 } |
| 1476 | 1488 |
| 1477 void visit(Node node) { | 1489 void visit(Node node) { |
| 1478 if (node !== null) node.accept(this); | 1490 if (node !== null) node.accept(this); |
| 1479 } | 1491 } |
| 1480 | 1492 |
| 1481 visitBlock(Block node) { | 1493 visitBlock(Block node) { |
| 1482 for (Link<Node> link = node.statements.nodes; | 1494 for (Link<Node> link = node.statements.nodes; |
| 1483 !link.isEmpty(); | 1495 !link.isEmpty(); |
| 1484 link = link.tail) { | 1496 link = link.tail) { |
| 1485 visit(link.head); | 1497 visit(link.head); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 endLoop(conditionBlock, conditionExitBlock, jumpHandler, savedLocals); | 1677 endLoop(conditionBlock, conditionExitBlock, jumpHandler, savedLocals); |
| 1666 HLoopBlockInformation info = | 1678 HLoopBlockInformation info = |
| 1667 new HLoopBlockInformation( | 1679 new HLoopBlockInformation( |
| 1668 HLoopBlockInformation.loopType(loop), | 1680 HLoopBlockInformation.loopType(loop), |
| 1669 wrapExpressionGraph(initializerGraph), | 1681 wrapExpressionGraph(initializerGraph), |
| 1670 wrapExpressionGraph(conditionExpression), | 1682 wrapExpressionGraph(conditionExpression), |
| 1671 wrapStatementGraph(bodyGraph), | 1683 wrapStatementGraph(bodyGraph), |
| 1672 wrapExpressionGraph(updateGraph), | 1684 wrapExpressionGraph(updateGraph), |
| 1673 conditionBlock.loopInformation.target, | 1685 conditionBlock.loopInformation.target, |
| 1674 conditionBlock.loopInformation.labels, | 1686 conditionBlock.loopInformation.labels, |
| 1675 sourceFileLocationForToken(loop.getBeginToken()), | 1687 sourceFileLocationForBeginToken(loop), |
| 1676 sourceFileLocationForToken(loop.getEndToken())); | 1688 sourceFileLocationForEndToken(loop)); |
| 1677 | 1689 |
| 1678 startBlock.setBlockFlow(info, current); | 1690 startBlock.setBlockFlow(info, current); |
| 1679 loopInfo.loopBlockInformation = info; | 1691 loopInfo.loopBlockInformation = info; |
| 1680 } | 1692 } |
| 1681 | 1693 |
| 1682 visitFor(For node) { | 1694 visitFor(For node) { |
| 1683 assert(node.body !== null); | 1695 assert(node.body !== null); |
| 1684 void buildInitializer() { | 1696 void buildInitializer() { |
| 1685 if (node.initializer === null) return; | 1697 if (node.initializer === null) return; |
| 1686 Node initializer = node.initializer; | 1698 Node initializer = node.initializer; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 | 1806 |
| 1795 HLoopBlockInformation loopBlockInfo = | 1807 HLoopBlockInformation loopBlockInfo = |
| 1796 new HLoopBlockInformation( | 1808 new HLoopBlockInformation( |
| 1797 HLoopBlockInformation.DO_WHILE_LOOP, | 1809 HLoopBlockInformation.DO_WHILE_LOOP, |
| 1798 null, | 1810 null, |
| 1799 wrapExpressionGraph(conditionExpression), | 1811 wrapExpressionGraph(conditionExpression), |
| 1800 wrapStatementGraph(bodyGraph), | 1812 wrapStatementGraph(bodyGraph), |
| 1801 null, | 1813 null, |
| 1802 loopEntryBlock.loopInformation.target, | 1814 loopEntryBlock.loopInformation.target, |
| 1803 loopEntryBlock.loopInformation.labels, | 1815 loopEntryBlock.loopInformation.labels, |
| 1804 sourceFileLocationForToken(node.getBeginToken()), | 1816 sourceFileLocationForBeginToken(node), |
| 1805 sourceFileLocationForToken(node.getEndToken())); | 1817 sourceFileLocationForEndToken(node)); |
| 1806 loopEntryBlock.setBlockFlow(loopBlockInfo, current); | 1818 loopEntryBlock.setBlockFlow(loopBlockInfo, current); |
| 1807 loopInfo.loopBlockInformation = loopBlockInfo; | 1819 loopInfo.loopBlockInformation = loopBlockInfo; |
| 1808 } | 1820 } |
| 1809 | 1821 |
| 1810 visitFunctionExpression(FunctionExpression node) { | 1822 visitFunctionExpression(FunctionExpression node) { |
| 1811 ClosureClassMap nestedClosureData = | 1823 ClosureClassMap nestedClosureData = |
| 1812 compiler.closureToClassMapper.getMappingForNestedFunction(node); | 1824 compiler.closureToClassMapper.getMappingForNestedFunction(node); |
| 1813 assert(nestedClosureData !== null); | 1825 assert(nestedClosureData !== null); |
| 1814 assert(nestedClosureData.closureClassElement !== null); | 1826 assert(nestedClosureData.closureClassElement !== null); |
| 1815 ClassElement closureClassElement = | 1827 ClassElement closureClassElement = |
| (...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4203 new HSubGraphBlockInformation(elseBranch.graph)); | 4215 new HSubGraphBlockInformation(elseBranch.graph)); |
| 4204 | 4216 |
| 4205 HBasicBlock conditionStartBlock = conditionBranch.block; | 4217 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 4206 conditionStartBlock.setBlockFlow(info, joinBlock); | 4218 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 4207 SubGraph conditionGraph = conditionBranch.graph; | 4219 SubGraph conditionGraph = conditionBranch.graph; |
| 4208 HIf branch = conditionGraph.end.last; | 4220 HIf branch = conditionGraph.end.last; |
| 4209 assert(branch is HIf); | 4221 assert(branch is HIf); |
| 4210 branch.blockInformation = conditionStartBlock.blockFlow; | 4222 branch.blockInformation = conditionStartBlock.blockFlow; |
| 4211 } | 4223 } |
| 4212 } | 4224 } |
| OLD | NEW |