| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
| 8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
| 9 R visitBailoutTarget(HBailoutTarget node); | 9 R visitBailoutTarget(HBailoutTarget node); |
| 10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 | 1536 |
| 1537 accept(HVisitor visitor) => visitor.visitLocalSet(this); | 1537 accept(HVisitor visitor) => visitor.visitLocalSet(this); |
| 1538 | 1538 |
| 1539 HLocalValue get local => inputs[0]; | 1539 HLocalValue get local => inputs[0]; |
| 1540 HInstruction get value => inputs[1]; | 1540 HInstruction get value => inputs[1]; |
| 1541 bool isJsStatement() => true; | 1541 bool isJsStatement() => true; |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 class HForeign extends HInstruction { | 1544 class HForeign extends HInstruction { |
| 1545 final DartString code; | 1545 final DartString code; |
| 1546 final HType foreignType; | 1546 final HType type; |
| 1547 final bool isStatement; | 1547 final bool isStatement; |
| 1548 | 1548 |
| 1549 HForeign(this.code, | 1549 HForeign(this.code, |
| 1550 DartString declaredType, | 1550 this.type, |
| 1551 List<HInstruction> inputs, | 1551 List<HInstruction> inputs, |
| 1552 {this.isStatement: false}) | 1552 {this.isStatement: false}) |
| 1553 : foreignType = computeTypeFromDeclaredType(declaredType), | 1553 : super(inputs) { |
| 1554 super(inputs) { | |
| 1555 setAllSideEffects(); | 1554 setAllSideEffects(); |
| 1556 setDependsOnSomething(); | 1555 setDependsOnSomething(); |
| 1557 } | 1556 } |
| 1558 | 1557 |
| 1559 HForeign.statement(code, List<HInstruction> inputs) | 1558 HForeign.statement(code, List<HInstruction> inputs) |
| 1560 : this(code, const LiteralDartString('var'), inputs, isStatement: true); | 1559 : this(code, HType.UNKNOWN, inputs, isStatement: true); |
| 1561 | 1560 |
| 1562 accept(HVisitor visitor) => visitor.visitForeign(this); | 1561 accept(HVisitor visitor) => visitor.visitForeign(this); |
| 1563 | 1562 |
| 1564 static HType computeTypeFromDeclaredType(DartString declaredType) { | 1563 HType get guaranteedType => type; |
| 1565 if (declaredType.slowToString() == 'bool') return HType.BOOLEAN; | |
| 1566 if (declaredType.slowToString() == 'int') return HType.INTEGER; | |
| 1567 if (declaredType.slowToString() == 'double') return HType.DOUBLE; | |
| 1568 if (declaredType.slowToString() == 'num') return HType.NUMBER; | |
| 1569 if (declaredType.slowToString() == 'String') return HType.STRING; | |
| 1570 if (declaredType.slowToString() == '=List') return HType.READABLE_ARRAY; | |
| 1571 return HType.UNKNOWN; | |
| 1572 } | |
| 1573 | |
| 1574 HType get guaranteedType => foreignType; | |
| 1575 | 1564 |
| 1576 bool isJsStatement() => isStatement; | 1565 bool isJsStatement() => isStatement; |
| 1577 bool canThrow() => true; | 1566 bool canThrow() => true; |
| 1578 | |
| 1579 } | 1567 } |
| 1580 | 1568 |
| 1581 class HForeignNew extends HForeign { | 1569 class HForeignNew extends HForeign { |
| 1582 ClassElement element; | 1570 ClassElement element; |
| 1583 HForeignNew(this.element, List<HInstruction> inputs) | 1571 HForeignNew(this.element, HType type, List<HInstruction> inputs) |
| 1584 : super(const LiteralDartString("new"), | 1572 : super(const LiteralDartString("new"), type, inputs); |
| 1585 const LiteralDartString("Object"), inputs); | |
| 1586 accept(HVisitor visitor) => visitor.visitForeignNew(this); | 1573 accept(HVisitor visitor) => visitor.visitForeignNew(this); |
| 1587 } | 1574 } |
| 1588 | 1575 |
| 1589 abstract class HInvokeBinary extends HInstruction { | 1576 abstract class HInvokeBinary extends HInstruction { |
| 1590 HInvokeBinary(HInstruction left, HInstruction right) | 1577 HInvokeBinary(HInstruction left, HInstruction right) |
| 1591 : super(<HInstruction>[left, right]) { | 1578 : super(<HInstruction>[left, right]) { |
| 1592 clearAllSideEffects(); | 1579 clearAllSideEffects(); |
| 1593 setUseGvn(); | 1580 setUseGvn(); |
| 1594 } | 1581 } |
| 1595 | 1582 |
| (...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2715 HBasicBlock get start => expression.start; | 2702 HBasicBlock get start => expression.start; |
| 2716 HBasicBlock get end { | 2703 HBasicBlock get end { |
| 2717 // We don't create a switch block if there are no cases. | 2704 // We don't create a switch block if there are no cases. |
| 2718 assert(!statements.isEmpty); | 2705 assert(!statements.isEmpty); |
| 2719 return statements.last.end; | 2706 return statements.last.end; |
| 2720 } | 2707 } |
| 2721 | 2708 |
| 2722 bool accept(HStatementInformationVisitor visitor) => | 2709 bool accept(HStatementInformationVisitor visitor) => |
| 2723 visitor.visitSwitchInfo(this); | 2710 visitor.visitSwitchInfo(this); |
| 2724 } | 2711 } |
| OLD | NEW |