Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 190763013: Detect total switches to prevent type pollution by default cases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 visitBitAnd(HBitAnd node); 9 R visitBitAnd(HBitAnd node);
10 R visitBitNot(HBitNot node); 10 R visitBitNot(HBitNot node);
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 HConstant constant(int index) => inputs[index + 1]; 1709 HConstant constant(int index) => inputs[index + 1];
1710 HInstruction get expression => inputs[0]; 1710 HInstruction get expression => inputs[0];
1711 1711
1712 /** 1712 /**
1713 * Provides the target to jump to if none of the constants match 1713 * Provides the target to jump to if none of the constants match
1714 * the expression. If the switch had no default case, this is the 1714 * the expression. If the switch had no default case, this is the
1715 * following join-block. 1715 * following join-block.
1716 */ 1716 */
1717 HBasicBlock get defaultTarget => block.successors.last; 1717 HBasicBlock get defaultTarget => block.successors.last;
1718 1718
1719 /**
1720 * Set to true if we statically know that the case statements
1721 * are exhaustive wrt the range of the expression.
1722 */
1723 bool isTotal = false;
1724
1719 accept(HVisitor visitor) => visitor.visitSwitch(this); 1725 accept(HVisitor visitor) => visitor.visitSwitch(this);
1720 1726
1721 String toString() => "HSwitch cases = $inputs"; 1727 String toString() => "HSwitch cases = $inputs";
1722 } 1728 }
1723 1729
1724 abstract class HBinaryBitOp extends HInvokeBinary { 1730 abstract class HBinaryBitOp extends HInvokeBinary {
1725 HBinaryBitOp(left, right, selector, type) 1731 HBinaryBitOp(left, right, selector, type)
1726 : super(left, right, selector, type); 1732 : super(left, right, selector, type);
1727 } 1733 }
1728 1734
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 class HDynamicType extends HRuntimeType { 2916 class HDynamicType extends HRuntimeType {
2911 HDynamicType(DynamicType dartType, TypeMask instructionType) 2917 HDynamicType(DynamicType dartType, TypeMask instructionType)
2912 : super(const <HInstruction>[], dartType, instructionType); 2918 : super(const <HInstruction>[], dartType, instructionType);
2913 2919
2914 accept(HVisitor visitor) => visitor.visitDynamicType(this); 2920 accept(HVisitor visitor) => visitor.visitDynamicType(this);
2915 2921
2916 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 2922 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
2917 2923
2918 bool typeEquals(HInstruction other) => other is HDynamicType; 2924 bool typeEquals(HInstruction other) => other is HDynamicType;
2919 } 2925 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698