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

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: Make "as" a builtin identifier. 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 9157093859f7d1bbc32bb8b6036bb8199ea90e6d..138e78ab3e4cf50649fef89e3f1dd26eef3b7edb 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);
@@ -1813,7 +1816,7 @@ class HNot extends HInstruction {
}
class HParameterValue extends HInstruction {
- HParameterValue(element) : super(<HInstruction>[]) {
+ HParameterValue(Element element) : super(<HInstruction>[]) {
sourceElement = element;
}
@@ -2220,16 +2223,28 @@ class HIs extends HInstruction {
}
class HTypeConversion extends HCheck {
+ static final int UNCHECKED = 0;
+ static final int CHECKED = 1;
+ static final int CAST = 2;
+
HType type;
- final bool checked;
+ final int kind;
HTypeConversion(HType this.type,
HInstruction input,
- [bool this.checked = false])
+ [this.kind = UNCHECKED])
: super(<HInstruction>[input]) {
sourceElement = input.sourceElement;
}
+ bool get checked() => kind != UNCHECKED;
+ /**
+ * Whether to use cast-semantics instead of checked-mode assignment semantics
+ * for the conversion. The difference is that a cast throws on [:null:] and
+ * throws a different exception on a failed match.
+ */
+ bool get isCast() => kind == CAST;
+
HType get guaranteedType() => type;
accept(HVisitor visitor) => visitor.visitTypeConversion(this);

Powered by Google App Engine
This is Rietveld 408576698