| 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 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2320 return typeExpression == other.typeExpression | 2320 return typeExpression == other.typeExpression |
| 2321 && kind == other.kind; | 2321 && kind == other.kind; |
| 2322 } | 2322 } |
| 2323 } | 2323 } |
| 2324 | 2324 |
| 2325 class HTypeConversion extends HCheck { | 2325 class HTypeConversion extends HCheck { |
| 2326 final DartType typeExpression; | 2326 final DartType typeExpression; |
| 2327 final int kind; | 2327 final int kind; |
| 2328 final Selector receiverTypeCheckSelector; | 2328 final Selector receiverTypeCheckSelector; |
| 2329 final bool contextIsTypeArguments; | 2329 final bool contextIsTypeArguments; |
| 2330 HType checkedType; // Not final because we refine it. |
| 2330 | 2331 |
| 2331 static const int CHECKED_MODE_CHECK = 0; | 2332 static const int CHECKED_MODE_CHECK = 0; |
| 2332 static const int ARGUMENT_TYPE_CHECK = 1; | 2333 static const int ARGUMENT_TYPE_CHECK = 1; |
| 2333 static const int CAST_TYPE_CHECK = 2; | 2334 static const int CAST_TYPE_CHECK = 2; |
| 2334 static const int BOOLEAN_CONVERSION_CHECK = 3; | 2335 static const int BOOLEAN_CONVERSION_CHECK = 3; |
| 2335 static const int RECEIVER_TYPE_CHECK = 4; | 2336 static const int RECEIVER_TYPE_CHECK = 4; |
| 2336 | 2337 |
| 2337 HTypeConversion(this.typeExpression, this.kind, | 2338 HTypeConversion(this.typeExpression, this.kind, |
| 2338 HType type, HInstruction input, | 2339 HType type, HInstruction input, |
| 2339 [this.receiverTypeCheckSelector]) | 2340 [this.receiverTypeCheckSelector]) |
| 2340 : contextIsTypeArguments = false, | 2341 : contextIsTypeArguments = false, |
| 2342 checkedType = type, |
| 2341 super(<HInstruction>[input]) { | 2343 super(<HInstruction>[input]) { |
| 2342 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); | 2344 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); |
| 2343 assert(typeExpression == null || | 2345 assert(typeExpression == null || |
| 2344 typeExpression.kind != TypeKind.TYPEDEF); | 2346 typeExpression.kind != TypeKind.TYPEDEF); |
| 2345 sourceElement = input.sourceElement; | 2347 sourceElement = input.sourceElement; |
| 2346 instructionType = type; | 2348 instructionType = type; |
| 2347 } | 2349 } |
| 2348 | 2350 |
| 2349 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind, | 2351 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind, |
| 2350 HType type, HInstruction input, | 2352 HType type, HInstruction input, |
| 2351 HInstruction typeRepresentation) | 2353 HInstruction typeRepresentation) |
| 2352 : contextIsTypeArguments = false, | 2354 : contextIsTypeArguments = false, |
| 2355 checkedType = type, |
| 2353 super(<HInstruction>[input, typeRepresentation]), | 2356 super(<HInstruction>[input, typeRepresentation]), |
| 2354 receiverTypeCheckSelector = null { | 2357 receiverTypeCheckSelector = null { |
| 2355 assert(typeExpression.kind != TypeKind.TYPEDEF); | 2358 assert(typeExpression.kind != TypeKind.TYPEDEF); |
| 2356 sourceElement = input.sourceElement; | 2359 sourceElement = input.sourceElement; |
| 2357 instructionType = type; | 2360 instructionType = type; |
| 2358 } | 2361 } |
| 2359 | 2362 |
| 2360 HTypeConversion.withContext(this.typeExpression, this.kind, | 2363 HTypeConversion.withContext(this.typeExpression, this.kind, |
| 2361 HType type, HInstruction input, | 2364 HType type, HInstruction input, |
| 2362 HInstruction context, | 2365 HInstruction context, |
| 2363 {bool this.contextIsTypeArguments}) | 2366 {bool this.contextIsTypeArguments}) |
| 2364 : super(<HInstruction>[input, context]), | 2367 : super(<HInstruction>[input, context]), |
| 2368 checkedType = type, |
| 2365 receiverTypeCheckSelector = null { | 2369 receiverTypeCheckSelector = null { |
| 2366 assert(typeExpression.kind != TypeKind.TYPEDEF); | 2370 assert(typeExpression.kind != TypeKind.TYPEDEF); |
| 2367 sourceElement = input.sourceElement; | 2371 sourceElement = input.sourceElement; |
| 2368 instructionType = type; | 2372 instructionType = type; |
| 2369 } | 2373 } |
| 2370 | 2374 |
| 2371 bool get hasTypeRepresentation { | 2375 bool get hasTypeRepresentation { |
| 2372 return typeExpression.kind == TypeKind.INTERFACE && inputs.length > 1; | 2376 return typeExpression.kind == TypeKind.INTERFACE && inputs.length > 1; |
| 2373 } | 2377 } |
| 2374 HInstruction get typeRepresentation => inputs[1]; | 2378 HInstruction get typeRepresentation => inputs[1]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2397 bool isJsStatement() => isControlFlow(); | 2401 bool isJsStatement() => isControlFlow(); |
| 2398 bool isControlFlow() => isArgumentTypeCheck || isReceiverTypeCheck; | 2402 bool isControlFlow() => isArgumentTypeCheck || isReceiverTypeCheck; |
| 2399 | 2403 |
| 2400 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; | 2404 int typeCode() => HInstruction.TYPE_CONVERSION_TYPECODE; |
| 2401 bool typeEquals(HInstruction other) => other is HTypeConversion; | 2405 bool typeEquals(HInstruction other) => other is HTypeConversion; |
| 2402 bool isCodeMotionInvariant() => false; | 2406 bool isCodeMotionInvariant() => false; |
| 2403 | 2407 |
| 2404 bool dataEquals(HTypeConversion other) { | 2408 bool dataEquals(HTypeConversion other) { |
| 2405 return kind == other.kind | 2409 return kind == other.kind |
| 2406 && typeExpression == other.typeExpression | 2410 && typeExpression == other.typeExpression |
| 2407 && instructionType == other.instructionType; | 2411 && checkedType == other.checkedType; |
| 2408 } | 2412 } |
| 2409 } | 2413 } |
| 2410 | 2414 |
| 2411 /// The [HTypeKnown] instruction marks a value with a refined type. | 2415 /// The [HTypeKnown] instruction marks a value with a refined type. |
| 2412 class HTypeKnown extends HCheck { | 2416 class HTypeKnown extends HCheck { |
| 2413 HType knownType; | 2417 HType knownType; |
| 2414 HTypeKnown(HType this.knownType, HInstruction input) | 2418 HTypeKnown(HType this.knownType, HInstruction input) |
| 2415 : super(<HInstruction>[input]) { | 2419 : super(<HInstruction>[input]) { |
| 2416 instructionType = knownType; | 2420 instructionType = knownType; |
| 2417 } | 2421 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2807 HBasicBlock get start => expression.start; | 2811 HBasicBlock get start => expression.start; |
| 2808 HBasicBlock get end { | 2812 HBasicBlock get end { |
| 2809 // We don't create a switch block if there are no cases. | 2813 // We don't create a switch block if there are no cases. |
| 2810 assert(!statements.isEmpty); | 2814 assert(!statements.isEmpty); |
| 2811 return statements.last.end; | 2815 return statements.last.end; |
| 2812 } | 2816 } |
| 2813 | 2817 |
| 2814 bool accept(HStatementInformationVisitor visitor) => | 2818 bool accept(HStatementInformationVisitor visitor) => |
| 2815 visitor.visitSwitchInfo(this); | 2819 visitor.visitSwitchInfo(this); |
| 2816 } | 2820 } |
| OLD | NEW |