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

Unified Diff: lib/compiler/implementation/ssa/nodes.dart

Issue 10540048: Implement 'as' operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update semantics to not throw on null. Merge to head. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/nodes.dart
diff --git a/lib/compiler/implementation/ssa/nodes.dart b/lib/compiler/implementation/ssa/nodes.dart
index ba7eaf346de62395eb3a9238079700cede633aed..527557c5c976e640f72e938dec0bca08b5d819a8 100644
--- a/lib/compiler/implementation/ssa/nodes.dart
+++ b/lib/compiler/implementation/ssa/nodes.dart
@@ -1489,8 +1489,6 @@ class HSubtract extends HBinaryArithmetic {
* An [HSwitch] instruction has one input for the incoming
* value, and one input per constant that it can switch on.
* Its block has one successor per constant, and one for the default.
- * If the switch didn't have a default case, the last successor is
- * the join block.
*/
class HSwitch extends HControlFlow {
HSwitch(List<HInstruction> inputs) : super(inputs);
@@ -1498,6 +1496,11 @@ class HSwitch extends HControlFlow {
HConstant constant(int index) => inputs[index + 1];
HInstruction get expression() => inputs[0];
+ /**
+ * Provides the target to jump to if none of the constants match
+ * the expression. If the switc had no default case, this is the
+ * following join-block.
+ */
HBasicBlock get defaultTarget() => block.successors.last();
accept(HVisitor visitor) => visitor.visitSwitch(this);
@@ -1831,7 +1834,7 @@ class HNot extends HInstruction {
* value from the start, whereas [HLocalValue]s need to be initialized first.
*/
class HLocalValue extends HInstruction {
- HLocalValue(element) : super(<HInstruction>[]) {
+ HLocalValue(Element element) : super(<HInstruction>[]) {
sourceElement = element;
}
@@ -1844,7 +1847,7 @@ class HLocalValue extends HInstruction {
}
class HParameterValue extends HLocalValue {
- HParameterValue(element) : super(element);
+ HParameterValue(Element element) : super(element);
toString() => 'parameter ${sourceElement.name}';
accept(HVisitor visitor) => visitor.visitParameterValue(this);
@@ -2253,22 +2256,24 @@ class HTypeConversion extends HCheck {
static final int NO_CHECK = 0;
static final int CHECKED_MODE_CHECK = 1;
static final int ARGUMENT_TYPE_CHECK = 2;
+ static final int CAST_TYPE_CHECK = 3;
- HTypeConversion(HType type, HInstruction input)
- : this.internal(type, input, NO_CHECK);
- HTypeConversion.checkedModeCheck(HType type, HInstruction input)
- : this.internal(type, input, CHECKED_MODE_CHECK);
- HTypeConversion.argumentTypeCheck(HType type, HInstruction input)
- : this.internal(type, input, ARGUMENT_TYPE_CHECK);
-
- HTypeConversion.internal(this.type, HInstruction input, this.kind)
+ HTypeConversion(this.type, HInstruction input, [this.kind = NO_CHECK])
: super(<HInstruction>[input]) {
sourceElement = input.sourceElement;
}
+ HTypeConversion.checkedModeCheck(HType type, HInstruction input)
+ : this(type, input, CHECKED_MODE_CHECK);
+ HTypeConversion.argumentTypeCheck(HType type, HInstruction input)
+ : this(type, input, ARGUMENT_TYPE_CHECK);
+ HTypeConversion.castCheck(HType type, HInstruction input)
+ : this(type, intpu, CAST_TYPE_CHECK);
+
- bool isChecked() => kind != NO_CHECK;
- bool isCheckedModeCheck() => kind == CHECKED_MODE_CHECK;
- bool isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK;
+ bool get isChecked() => kind != NO_CHECK;
+ bool get isCheckedModeCheck() => kind == CHECKED_MODE_CHECK;
+ bool get isArgumentTypeCheck() => kind == ARGUMENT_TYPE_CHECK;
+ bool get isCastTypeCheck() => kind == CAST_TYPE_CHECK;
HType get guaranteedType() => type;
@@ -2278,7 +2283,9 @@ class HTypeConversion extends HCheck {
bool isControlFlow() => kind == ARGUMENT_TYPE_CHECK;
int typeCode() => 28;
- bool typeEquals(HInstruction other) => other is HTypeConversion;
+ bool typeEquals(HInstruction other)
+ => other is HTypeConversion
+ && ((other.kind == CAST_TYPE_CHECK) == (kind == CAST_TYPE_CHECK));
bool dataEquals(HTypeConversion other) {
return type == other.type && kind == other.kind;
}

Powered by Google App Engine
This is Rietveld 408576698