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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 void dup() { | 1177 void dup() { |
1178 stack.add(stack.last()); | 1178 stack.add(stack.last()); |
1179 } | 1179 } |
1180 | 1180 |
1181 HBoolify popBoolified() { | 1181 HBoolify popBoolified() { |
1182 HBoolify boolified = new HBoolify(pop()); | 1182 HBoolify boolified = new HBoolify(pop()); |
1183 add(boolified); | 1183 add(boolified); |
1184 return boolified; | 1184 return boolified; |
1185 } | 1185 } |
1186 | 1186 |
| 1187 HInstruction attachPosition(HInstruction target, Node node) { |
| 1188 target.sourcePosition = node.getBeginToken(); |
| 1189 return target; |
| 1190 } |
| 1191 |
1187 void visit(Node node) { | 1192 void visit(Node node) { |
1188 if (node !== null) node.accept(this); | 1193 if (node !== null) node.accept(this); |
1189 } | 1194 } |
1190 | 1195 |
1191 visitBlock(Block node) { | 1196 visitBlock(Block node) { |
1192 for (Link<Node> link = node.statements.nodes; | 1197 for (Link<Node> link = node.statements.nodes; |
1193 !link.isEmpty(); | 1198 !link.isEmpty(); |
1194 link = link.tail) { | 1199 link = link.tail) { |
1195 visit(link.head); | 1200 visit(link.head); |
1196 if (isAborted()) { | 1201 if (isAborted()) { |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 HNot not = new HNot(popBoolified()); | 1592 HNot not = new HNot(popBoolified()); |
1588 push(not); | 1593 push(not); |
1589 } | 1594 } |
1590 | 1595 |
1591 void visitUnary(Send node, Operator op) { | 1596 void visitUnary(Send node, Operator op) { |
1592 assert(node.argumentsNode is Prefix); | 1597 assert(node.argumentsNode is Prefix); |
1593 visit(node.receiver); | 1598 visit(node.receiver); |
1594 assert(op.token.kind !== PLUS_TOKEN); | 1599 assert(op.token.kind !== PLUS_TOKEN); |
1595 HInstruction operand = pop(); | 1600 HInstruction operand = pop(); |
1596 | 1601 |
1597 HInstruction target = | 1602 HInstruction target = attachPosition( |
1598 new HStatic(interceptors.getPrefixOperatorInterceptor(op)); | 1603 new HStatic(interceptors.getPrefixOperatorInterceptor(op)), node); |
1599 add(target); | 1604 add(target); |
1600 HInvokeUnary result; | 1605 HInvokeUnary result; |
1601 String value = op.source.stringValue; | 1606 String value = op.source.stringValue; |
1602 switch (value) { | 1607 switch (value) { |
1603 case "-": result = new HNegate(target, operand); break; | 1608 case "-": result = new HNegate(target, operand); break; |
1604 case "~": result = new HBitNot(target, operand); break; | 1609 case "~": result = new HBitNot(target, operand); break; |
1605 default: | 1610 default: |
1606 compiler.internalError('Unexpected unary operator: $value.', node: op); | 1611 compiler.internalError('Unexpected unary operator: $value.', node: op); |
1607 break; | 1612 break; |
1608 } | 1613 } |
(...skipping 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3569 new HSubGraphBlockInformation(elseBranch.graph)); | 3574 new HSubGraphBlockInformation(elseBranch.graph)); |
3570 | 3575 |
3571 HBasicBlock conditionStartBlock = conditionBranch.block; | 3576 HBasicBlock conditionStartBlock = conditionBranch.block; |
3572 conditionStartBlock.setBlockFlow(info, joinBlock); | 3577 conditionStartBlock.setBlockFlow(info, joinBlock); |
3573 SubGraph conditionGraph = conditionBranch.graph; | 3578 SubGraph conditionGraph = conditionBranch.graph; |
3574 HIf branch = conditionGraph.end.last; | 3579 HIf branch = conditionGraph.end.last; |
3575 assert(branch is HIf); | 3580 assert(branch is HIf); |
3576 branch.blockInformation = conditionStartBlock.blockFlow; | 3581 branch.blockInformation = conditionStartBlock.blockFlow; |
3577 } | 3582 } |
3578 } | 3583 } |
OLD | NEW |