| 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 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 | 2202 |
| 2203 class HIs extends HInstruction { | 2203 class HIs extends HInstruction { |
| 2204 /// A check against a raw type: 'o is int', 'o is A'. | 2204 /// A check against a raw type: 'o is int', 'o is A'. |
| 2205 static const int RAW_CHECK = 0; | 2205 static const int RAW_CHECK = 0; |
| 2206 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. | 2206 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. |
| 2207 static const int COMPOUND_CHECK = 1; | 2207 static const int COMPOUND_CHECK = 1; |
| 2208 /// A check against a single type variable: 'o is T'. | 2208 /// A check against a single type variable: 'o is T'. |
| 2209 static const int VARIABLE_CHECK = 2; | 2209 static const int VARIABLE_CHECK = 2; |
| 2210 | 2210 |
| 2211 final DartType typeExpression; | 2211 final DartType typeExpression; |
| 2212 final bool nullOk; |
| 2212 final int kind; | 2213 final int kind; |
| 2213 | 2214 |
| 2214 HIs.direct(DartType typeExpression, | 2215 HIs(this.typeExpression, List<HInstruction> inputs, this.kind, |
| 2215 HInstruction expression) | 2216 {this.nullOk: false}) : super(inputs) { |
| 2216 : this.internal(typeExpression, [expression], RAW_CHECK); | |
| 2217 | |
| 2218 HIs.raw(DartType typeExpression, | |
| 2219 HInstruction expression, | |
| 2220 HInterceptor interceptor) | |
| 2221 : this.internal(typeExpression, [expression, interceptor], RAW_CHECK); | |
| 2222 | |
| 2223 HIs.compound(DartType typeExpression, | |
| 2224 HInstruction expression, | |
| 2225 HInstruction call) | |
| 2226 : this.internal(typeExpression, [expression, call], COMPOUND_CHECK); | |
| 2227 | |
| 2228 HIs.variable(DartType typeExpression, | |
| 2229 HInstruction expression, | |
| 2230 HInstruction call) | |
| 2231 : this.internal(typeExpression, [expression, call], VARIABLE_CHECK); | |
| 2232 | |
| 2233 HIs.internal(this.typeExpression, List<HInstruction> inputs, this.kind) | |
| 2234 : super(inputs) { | |
| 2235 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK); | 2217 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK); |
| 2236 setUseGvn(); | 2218 setUseGvn(); |
| 2237 instructionType = HType.BOOLEAN; | 2219 instructionType = HType.BOOLEAN; |
| 2238 } | 2220 } |
| 2239 | 2221 |
| 2240 HInstruction get expression => inputs[0]; | 2222 HInstruction get expression => inputs[0]; |
| 2241 | 2223 |
| 2242 HInstruction get interceptor { | |
| 2243 assert(kind == RAW_CHECK); | |
| 2244 return inputs.length > 1 ? inputs[1] : null; | |
| 2245 } | |
| 2246 | |
| 2247 HInstruction get checkCall { | 2224 HInstruction get checkCall { |
| 2248 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK); | 2225 assert(kind == VARIABLE_CHECK || kind == COMPOUND_CHECK); |
| 2249 return inputs[1]; | 2226 return inputs[1]; |
| 2250 } | 2227 } |
| 2251 | 2228 |
| 2252 bool get isRawCheck => kind == RAW_CHECK; | 2229 bool get isRawCheck => kind == RAW_CHECK; |
| 2253 bool get isVariableCheck => kind == VARIABLE_CHECK; | 2230 bool get isVariableCheck => kind == VARIABLE_CHECK; |
| 2254 bool get isCompoundCheck => kind == COMPOUND_CHECK; | 2231 bool get isCompoundCheck => kind == COMPOUND_CHECK; |
| 2255 | 2232 |
| 2256 accept(HVisitor visitor) => visitor.visitIs(this); | 2233 accept(HVisitor visitor) => visitor.visitIs(this); |
| 2257 | 2234 |
| 2258 toString() => "$expression is $typeExpression"; | 2235 toString() => "$expression is $typeExpression"; |
| 2259 | 2236 |
| 2260 int typeCode() => HInstruction.IS_TYPECODE; | 2237 int typeCode() => HInstruction.IS_TYPECODE; |
| 2261 | 2238 |
| 2262 bool typeEquals(HInstruction other) => other is HIs; | 2239 bool typeEquals(HInstruction other) => other is HIs; |
| 2263 | 2240 |
| 2264 bool dataEquals(HIs other) { | 2241 bool dataEquals(HIs other) { |
| 2265 return typeExpression == other.typeExpression | 2242 return typeExpression == other.typeExpression |
| 2243 && nullOk == other.nullOk |
| 2266 && kind == other.kind; | 2244 && kind == other.kind; |
| 2267 } | 2245 } |
| 2268 } | 2246 } |
| 2269 | 2247 |
| 2270 class HTypeConversion extends HCheck { | 2248 class HTypeConversion extends HCheck { |
| 2271 final DartType typeExpression; | 2249 final DartType typeExpression; |
| 2272 final int kind; | 2250 final int kind; |
| 2273 final Selector receiverTypeCheckSelector; | 2251 final Selector receiverTypeCheckSelector; |
| 2274 final bool contextIsTypeArguments; | 2252 final bool contextIsTypeArguments; |
| 2275 | 2253 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2729 HBasicBlock get start => expression.start; | 2707 HBasicBlock get start => expression.start; |
| 2730 HBasicBlock get end { | 2708 HBasicBlock get end { |
| 2731 // We don't create a switch block if there are no cases. | 2709 // We don't create a switch block if there are no cases. |
| 2732 assert(!statements.isEmpty); | 2710 assert(!statements.isEmpty); |
| 2733 return statements.last.end; | 2711 return statements.last.end; |
| 2734 } | 2712 } |
| 2735 | 2713 |
| 2736 bool accept(HStatementInformationVisitor visitor) => | 2714 bool accept(HStatementInformationVisitor visitor) => |
| 2737 visitor.visitSwitchInfo(this); | 2715 visitor.visitSwitchInfo(this); |
| 2738 } | 2716 } |
| OLD | NEW |