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

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

Issue 10660026: Don't allow statement-nodes in expression contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test for checked mode. Created 8 years, 5 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 interface HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBitAnd(HBitAnd node); 7 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 8 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 9 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 10 R visitBitXor(HBitXor node);
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 /** 985 /**
986 * A [HCheck] instruction is an instruction that might do a dynamic 986 * A [HCheck] instruction is an instruction that might do a dynamic
987 * check at runtime on another instruction. To have proper instruction 987 * check at runtime on another instruction. To have proper instruction
988 * dependencies in the graph, instructions that depend on the check 988 * dependencies in the graph, instructions that depend on the check
989 * being done reference the [HCheck] instruction instead of the 989 * being done reference the [HCheck] instruction instead of the
990 * instruction itself. 990 * instruction itself.
991 */ 991 */
992 abstract class HCheck extends HInstruction { 992 abstract class HCheck extends HInstruction {
993 HCheck(inputs) : super(inputs); 993 HCheck(inputs) : super(inputs);
994 HInstruction get checkedInput() => inputs[0]; 994 HInstruction get checkedInput() => inputs[0];
995 final bool isStatement = true; 995 bool get isStatement() => true;
996 void prepareGvn() { 996 void prepareGvn() {
997 assert(!hasSideEffects()); 997 assert(!hasSideEffects());
998 setUseGvn(); 998 setUseGvn();
999 } 999 }
1000 } 1000 }
1001 1001
1002 class HTypeGuard extends HCheck { 1002 class HTypeGuard extends HCheck {
1003 final int state; 1003 final int state;
1004 final HType guardedType; 1004 final HType guardedType;
1005 bool isOn = false; 1005 bool isEnabled = false;
1006 int checkedInputIndex = 0; 1006 int checkedInputIndex = 0;
1007 1007
1008 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env); 1008 HTypeGuard(this.guardedType, this.state, List<HInstruction> env) : super(env);
1009 1009
1010 HInstruction get guarded() => inputs[checkedInputIndex]; 1010 HInstruction get guarded() => inputs[checkedInputIndex];
1011 HInstruction get checkedInput() => guarded; 1011 HInstruction get checkedInput() => guarded;
1012 1012
1013 HType computeTypeFromInputTypes() { 1013 HType computeTypeFromInputTypes() {
1014 return isOn ? guardedType : guarded.propagatedType; 1014 return isEnabled ? guardedType : guarded.propagatedType;
1015 } 1015 }
1016 1016
1017 HType get guaranteedType() => isOn ? guardedType : HType.UNKNOWN; 1017 HType get guaranteedType() => isEnabled ? guardedType : HType.UNKNOWN;
1018 1018
1019 bool isControlFlow() => true; 1019 bool isControlFlow() => true;
1020 1020
1021 bool get isStatement() => isEnabled;
1022
1021 accept(HVisitor visitor) => visitor.visitTypeGuard(this); 1023 accept(HVisitor visitor) => visitor.visitTypeGuard(this);
1022 int typeCode() => 1; 1024 int typeCode() => 1;
1023 bool typeEquals(other) => other is HTypeGuard; 1025 bool typeEquals(other) => other is HTypeGuard;
1024 bool dataEquals(HTypeGuard other) { 1026 bool dataEquals(HTypeGuard other) {
1025 return guarded == other.guarded && guardedType == other.guardedType; 1027 return guarded == other.guarded && guardedType == other.guardedType;
1026 } 1028 }
1027 } 1029 }
1028 1030
1029 class HBoundsCheck extends HCheck { 1031 class HBoundsCheck extends HCheck {
1030 static final int ALWAYS_FALSE = 0; 1032 static final int ALWAYS_FALSE = 0;
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 HBasicBlock get start() => expression.start; 2629 HBasicBlock get start() => expression.start;
2628 HBasicBlock get end() { 2630 HBasicBlock get end() {
2629 // We don't create a switch block if there are no cases. 2631 // We don't create a switch block if there are no cases.
2630 assert(!statements.isEmpty()); 2632 assert(!statements.isEmpty());
2631 return statements.last().end; 2633 return statements.last().end;
2632 } 2634 }
2633 2635
2634 bool accept(HStatementInformationVisitor visitor) => 2636 bool accept(HStatementInformationVisitor visitor) =>
2635 visitor.visitSwitchInfo(this); 2637 visitor.visitSwitchInfo(this);
2636 } 2638 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698