| 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 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 setChangesIndex(); | 2170 setChangesIndex(); |
| 2171 } | 2171 } |
| 2172 String toString() => 'index assign operator'; | 2172 String toString() => 'index assign operator'; |
| 2173 accept(HVisitor visitor) => visitor.visitIndexAssign(this); | 2173 accept(HVisitor visitor) => visitor.visitIndexAssign(this); |
| 2174 | 2174 |
| 2175 HInstruction get receiver => inputs[0]; | 2175 HInstruction get receiver => inputs[0]; |
| 2176 HInstruction get index => inputs[1]; | 2176 HInstruction get index => inputs[1]; |
| 2177 HInstruction get value => inputs[2]; | 2177 HInstruction get value => inputs[2]; |
| 2178 } | 2178 } |
| 2179 | 2179 |
| 2180 // TODO(karlklose): use this class to represent type conversions as well. | |
| 2181 class HIs extends HInstruction { | 2180 class HIs extends HInstruction { |
| 2182 /// A check against a raw type: 'o is int', 'o is A'. | 2181 /// A check against a raw type: 'o is int', 'o is A'. |
| 2183 static const int RAW_CHECK = 0; | 2182 static const int RAW_CHECK = 0; |
| 2184 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. | 2183 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. |
| 2185 static const int COMPOUND_CHECK = 1; | 2184 static const int COMPOUND_CHECK = 1; |
| 2186 /// A check against a single type variable: 'o is T'. | 2185 /// A check against a single type variable: 'o is T'. |
| 2187 static const int VARIABLE_CHECK = 2; | 2186 static const int VARIABLE_CHECK = 2; |
| 2187 /// A checked-mode check against a raw type. |
| 2188 static const int RAW_ASSERT = 3; |
| 2188 | 2189 |
| 2189 final DartType typeExpression; | 2190 final DartType typeExpression; |
| 2190 final bool nullOk; | 2191 final bool nullOk; |
| 2191 final int kind; | 2192 final int kind; |
| 2193 final bool isCheckedModeTest; |
| 2192 | 2194 |
| 2193 HIs(this.typeExpression, List<HInstruction> inputs, this.kind, | 2195 HIs(this.typeExpression, List<HInstruction> inputs, this.kind, |
| 2194 {this.nullOk: false}) : super(inputs) { | 2196 this.isCheckedModeTest, HType instructionType, {this.nullOk: false}) |
| 2195 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK); | 2197 : super(inputs) { |
| 2196 setUseGvn(); | 2198 assert(kind >= RAW_CHECK && kind <= RAW_ASSERT); |
| 2197 instructionType = HType.BOOLEAN; | 2199 assert(isCheckedModeTest || instructionType == HType.BOOLEAN); |
| 2200 assert(isCheckedModeTest || instructionType != RAW_ASSERT); |
| 2201 if (isCheckedModeTest) { |
| 2202 setAllSideEffects(); |
| 2203 } else { |
| 2204 setUseGvn(); |
| 2205 } |
| 2206 this.instructionType = instructionType; |
| 2198 } | 2207 } |
| 2199 | 2208 |
| 2200 HInstruction get expression => inputs[0]; | 2209 HInstruction get expression => inputs[0]; |
| 2201 | 2210 |
| 2202 HInstruction get checkCall { | 2211 HInstruction get checkCall { |
| 2203 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK); | 2212 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK); |
| 2204 return inputs[1]; | 2213 return inputs[1]; |
| 2205 } | 2214 } |
| 2206 | 2215 |
| 2216 bool canThrow() => isCheckedModeTest; |
| 2207 bool get isRawCheck => kind == RAW_CHECK; | 2217 bool get isRawCheck => kind == RAW_CHECK; |
| 2208 bool get isVariableCheck => kind == VARIABLE_CHECK; | 2218 bool get isVariableCheck => kind == VARIABLE_CHECK; |
| 2209 bool get isCompoundCheck => kind == COMPOUND_CHECK; | 2219 bool get isCompoundCheck => kind == COMPOUND_CHECK; |
| 2210 | 2220 |
| 2211 accept(HVisitor visitor) => visitor.visitIs(this); | 2221 accept(HVisitor visitor) => visitor.visitIs(this); |
| 2212 | 2222 |
| 2213 toString() => "$expression is $typeExpression"; | 2223 toString() => "$expression is $typeExpression"; |
| 2214 | 2224 |
| 2215 int typeCode() => HInstruction.IS_TYPECODE; | 2225 int typeCode() => HInstruction.IS_TYPECODE; |
| 2216 | 2226 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 HBasicBlock get start => expression.start; | 2648 HBasicBlock get start => expression.start; |
| 2639 HBasicBlock get end { | 2649 HBasicBlock get end { |
| 2640 // We don't create a switch block if there are no cases. | 2650 // We don't create a switch block if there are no cases. |
| 2641 assert(!statements.isEmpty); | 2651 assert(!statements.isEmpty); |
| 2642 return statements.last.end; | 2652 return statements.last.end; |
| 2643 } | 2653 } |
| 2644 | 2654 |
| 2645 bool accept(HStatementInformationVisitor visitor) => | 2655 bool accept(HStatementInformationVisitor visitor) => |
| 2646 visitor.visitSwitchInfo(this); | 2656 visitor.visitSwitchInfo(this); |
| 2647 } | 2657 } |
| OLD | NEW |