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 visitAwait(HAwait node); | 9 R visitAwait(HAwait node); |
10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 | 1706 |
1707 bool canThrow() { | 1707 bool canThrow() { |
1708 return sideEffects.hasSideEffects() | 1708 return sideEffects.hasSideEffects() |
1709 || sideEffects.dependsOnSomething(); | 1709 || sideEffects.dependsOnSomething(); |
1710 } | 1710 } |
1711 } | 1711 } |
1712 | 1712 |
1713 class HForeignCode extends HForeign { | 1713 class HForeignCode extends HForeign { |
1714 final js.Template codeTemplate; | 1714 final js.Template codeTemplate; |
1715 final bool isStatement; | 1715 final bool isStatement; |
1716 final bool _canThrow; | |
1717 final native.NativeBehavior nativeBehavior; | 1716 final native.NativeBehavior nativeBehavior; |
| 1717 native.NativeThrowBehavior throwBehavior; |
1718 | 1718 |
1719 HForeignCode(this.codeTemplate, | 1719 HForeignCode(this.codeTemplate, |
1720 TypeMask type, | 1720 TypeMask type, |
1721 List<HInstruction> inputs, | 1721 List<HInstruction> inputs, |
1722 {this.isStatement: false, | 1722 {this.isStatement: false, |
1723 SideEffects effects, | 1723 SideEffects effects, |
1724 native.NativeBehavior nativeBehavior, | 1724 native.NativeBehavior nativeBehavior, |
1725 canThrow: false}) | 1725 native.NativeThrowBehavior throwBehavior}) |
1726 : this.nativeBehavior = nativeBehavior, | 1726 : this.nativeBehavior = nativeBehavior, |
1727 this._canThrow = canThrow, | 1727 this.throwBehavior = throwBehavior, |
1728 super(type, inputs) { | 1728 super(type, inputs) { |
1729 if(codeTemplate == null) throw this; | 1729 assert(codeTemplate != null); |
1730 if (effects == null && nativeBehavior != null) { | 1730 if (effects == null && nativeBehavior != null) { |
1731 effects = nativeBehavior.sideEffects; | 1731 effects = nativeBehavior.sideEffects; |
1732 } | 1732 } |
| 1733 if (this.throwBehavior == null) { |
| 1734 this.throwBehavior = (nativeBehavior == null) |
| 1735 ? native.NativeThrowBehavior.MAY |
| 1736 : nativeBehavior.throwBehavior; |
| 1737 } |
| 1738 assert(this.throwBehavior != null); |
| 1739 |
1733 if (effects != null) sideEffects.add(effects); | 1740 if (effects != null) sideEffects.add(effects); |
1734 } | 1741 } |
1735 | 1742 |
1736 HForeignCode.statement(codeTemplate, List<HInstruction> inputs, | 1743 HForeignCode.statement(js.Template codeTemplate, List<HInstruction> inputs, |
1737 SideEffects effects, | 1744 SideEffects effects, |
1738 native.NativeBehavior nativeBehavior, | 1745 native.NativeBehavior nativeBehavior, |
1739 TypeMask type) | 1746 TypeMask type) |
1740 : this(codeTemplate, type, inputs, isStatement: true, | 1747 : this(codeTemplate, type, inputs, isStatement: true, |
1741 effects: effects, nativeBehavior: nativeBehavior); | 1748 effects: effects, nativeBehavior: nativeBehavior); |
1742 | 1749 |
1743 accept(HVisitor visitor) => visitor.visitForeignCode(this); | 1750 accept(HVisitor visitor) => visitor.visitForeignCode(this); |
1744 | 1751 |
1745 bool isJsStatement() => isStatement; | 1752 bool isJsStatement() => isStatement; |
1746 bool canThrow() => _canThrow || super.canThrow(); | 1753 bool canThrow() => throwBehavior.canThrow; |
1747 } | 1754 } |
1748 | 1755 |
1749 class HForeignNew extends HForeign { | 1756 class HForeignNew extends HForeign { |
1750 ClassElement element; | 1757 ClassElement element; |
1751 | 1758 |
1752 /// If this field is not `null`, this call is from an inlined constructor and | 1759 /// If this field is not `null`, this call is from an inlined constructor and |
1753 /// we have to register the instantiated type in the code generator. The | 1760 /// we have to register the instantiated type in the code generator. The |
1754 /// [instructionType] of this node is not enough, because we also need the | 1761 /// [instructionType] of this node is not enough, because we also need the |
1755 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations]. | 1762 /// type arguments. See also [SsaFromAstMixin.currentInlinedInstantiations]. |
1756 List<DartType> instantiatedTypes; | 1763 List<DartType> instantiatedTypes; |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3151 class HDynamicType extends HRuntimeType { | 3158 class HDynamicType extends HRuntimeType { |
3152 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3159 HDynamicType(DynamicType dartType, TypeMask instructionType) |
3153 : super(const <HInstruction>[], dartType, instructionType); | 3160 : super(const <HInstruction>[], dartType, instructionType); |
3154 | 3161 |
3155 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3162 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
3156 | 3163 |
3157 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3164 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
3158 | 3165 |
3159 bool typeEquals(HInstruction other) => other is HDynamicType; | 3166 bool typeEquals(HInstruction other) => other is HDynamicType; |
3160 } | 3167 } |
OLD | NEW |