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 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 | 1538 |
1539 void pushWithPosition(HInstruction instruction, Node node) { | 1539 void pushWithPosition(HInstruction instruction, Node node) { |
1540 push(attachPosition(instruction, node)); | 1540 push(attachPosition(instruction, node)); |
1541 } | 1541 } |
1542 | 1542 |
1543 HInstruction pop() { | 1543 HInstruction pop() { |
1544 return stack.removeLast(); | 1544 return stack.removeLast(); |
1545 } | 1545 } |
1546 | 1546 |
1547 void dup() { | 1547 void dup() { |
1548 stack.add(stack.last()); | 1548 stack.add(stack.last); |
1549 } | 1549 } |
1550 | 1550 |
1551 HInstruction popBoolified() { | 1551 HInstruction popBoolified() { |
1552 HInstruction value = pop(); | 1552 HInstruction value = pop(); |
1553 if (compiler.enableTypeAssertions) { | 1553 if (compiler.enableTypeAssertions) { |
1554 return potentiallyCheckType( | 1554 return potentiallyCheckType( |
1555 value, | 1555 value, |
1556 compiler.boolClass, | 1556 compiler.boolClass, |
1557 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); | 1557 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); |
1558 } | 1558 } |
1559 HInstruction result = new HBoolify(value); | 1559 HInstruction result = new HBoolify(value); |
1560 add(result); | 1560 add(result); |
1561 return result; | 1561 return result; |
1562 } | 1562 } |
1563 | 1563 |
1564 HInstruction attachPosition(HInstruction target, Node node) { | 1564 HInstruction attachPosition(HInstruction target, Node node) { |
1565 target.sourcePosition = sourceFileLocationForBeginToken(node); | 1565 target.sourcePosition = sourceFileLocationForBeginToken(node); |
1566 return target; | 1566 return target; |
1567 } | 1567 } |
1568 | 1568 |
1569 SourceFileLocation sourceFileLocationForBeginToken(Node node) => | 1569 SourceFileLocation sourceFileLocationForBeginToken(Node node) => |
1570 sourceFileLocationForToken(node, node.getBeginToken()); | 1570 sourceFileLocationForToken(node, node.getBeginToken()); |
1571 | 1571 |
1572 SourceFileLocation sourceFileLocationForEndToken(Node node) => | 1572 SourceFileLocation sourceFileLocationForEndToken(Node node) => |
1573 sourceFileLocationForToken(node, node.getEndToken()); | 1573 sourceFileLocationForToken(node, node.getEndToken()); |
1574 | 1574 |
1575 SourceFileLocation sourceFileLocationForToken(Node node, Token token) { | 1575 SourceFileLocation sourceFileLocationForToken(Node node, Token token) { |
1576 Element element = sourceElementStack.last(); | 1576 Element element = sourceElementStack.last; |
1577 // TODO(johnniwinther): remove the 'element.patch' hack. | 1577 // TODO(johnniwinther): remove the 'element.patch' hack. |
1578 if (element is FunctionElement) { | 1578 if (element is FunctionElement) { |
1579 FunctionElement functionElement = element; | 1579 FunctionElement functionElement = element; |
1580 if (functionElement.patch != null) element = functionElement.patch; | 1580 if (functionElement.patch != null) element = functionElement.patch; |
1581 } | 1581 } |
1582 Script script = element.getCompilationUnit().script; | 1582 Script script = element.getCompilationUnit().script; |
1583 SourceFile sourceFile = script.file; | 1583 SourceFile sourceFile = script.file; |
1584 SourceFileLocation location = new SourceFileLocation(sourceFile, token); | 1584 SourceFileLocation location = new SourceFileLocation(sourceFile, token); |
1585 if (!location.isValid()) { | 1585 if (!location.isValid()) { |
1586 throw MessageKind.INVALID_SOURCE_FILE_LOCATION.message( | 1586 throw MessageKind.INVALID_SOURCE_FILE_LOCATION.message( |
(...skipping 2918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4505 new HSubGraphBlockInformation(elseBranch.graph)); | 4505 new HSubGraphBlockInformation(elseBranch.graph)); |
4506 | 4506 |
4507 HBasicBlock conditionStartBlock = conditionBranch.block; | 4507 HBasicBlock conditionStartBlock = conditionBranch.block; |
4508 conditionStartBlock.setBlockFlow(info, joinBlock); | 4508 conditionStartBlock.setBlockFlow(info, joinBlock); |
4509 SubGraph conditionGraph = conditionBranch.graph; | 4509 SubGraph conditionGraph = conditionBranch.graph; |
4510 HIf branch = conditionGraph.end.last; | 4510 HIf branch = conditionGraph.end.last; |
4511 assert(branch is HIf); | 4511 assert(branch is HIf); |
4512 branch.blockInformation = conditionStartBlock.blockFlow; | 4512 branch.blockInformation = conditionStartBlock.blockFlow; |
4513 } | 4513 } |
4514 } | 4514 } |
OLD | NEW |