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

Unified Diff: frog/leg/ssa/nodes.dart

Issue 9632018: Switch-implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Finished implementation Created 8 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/ssa/nodes.dart
diff --git a/frog/leg/ssa/nodes.dart b/frog/leg/ssa/nodes.dart
index 6717e6426a0e7cd5b70e9cff034b12e5e1a4e6af..fa207f82fb475aa6f6380520abfcde017ffb725a 100644
--- a/frog/leg/ssa/nodes.dart
+++ b/frog/leg/ssa/nodes.dart
@@ -142,7 +142,7 @@ class HGraph {
return result;
}
- HBasicBlock addNewLoopHeaderBlock(List<SourceString> labels) {
+ HBasicBlock addNewLoopHeaderBlock(List<LabelElement> labels) {
HBasicBlock result = addNewBlock();
result.loopInformation = new HLoopInformation(result, labels);
return result;
@@ -321,6 +321,9 @@ class SubGraph {
const SubGraph(this.start, this.end);
bool contains(HBasicBlock block) {
+ assert(start !== null);
+ assert(end !== null);
+ assert(block !== null);
return start.id <= block.id && block.id <= end.id;
}
}
@@ -421,9 +424,6 @@ class HBasicBlock extends HInstructionList {
HBasicBlock dominator = null;
final List<HBasicBlock> dominatedBlocks;
- // For recognizing labeled statements.
- List<SourceString> labels;
-
HBasicBlock() : this.withId(null);
HBasicBlock.withId(this.id)
: phis = new HInstructionList(),
@@ -657,15 +657,25 @@ class HBlockInformation {
class HLabeledBlockInformation extends HBlockInformation {
final SubGraph body;
final HBasicBlock joinBlock;
- final List<SourceString> labels;
- HLabeledBlockInformation(this.body, this.joinBlock, this.labels);
+ final List<LabelElement> labels;
+ final StatementElement target;
+
+ HLabeledBlockInformation(this.body, this.joinBlock,
+ List<LabelElement> labels) :
+ this.labels = labels, this.target = labels[0].target;
+
+ // For creating block information when there are no explicit labels.
+ HLabeledBlockInformation.implicit(this.body, this.joinBlock, this.target) :
+ this.labels = const<LabelElement>[];
+
+ bool get isSwitch() => target is SwitchStatementElement;
}
class HLoopInformation extends HBlockInformation {
final HBasicBlock header;
final List<HBasicBlock> blocks;
final List<HBasicBlock> backEdges;
- final List<SourceString> labels;
+ final List<LabelElement> labels;
HLoopInformation(this.header, this.labels)
: blocks = new List<HBasicBlock>(),
@@ -1605,9 +1615,10 @@ class HGoto extends HControlFlow {
}
class HBreak extends HGoto {
- final SourceString label;
- HBreak([this.label]);
- toString() => 'break';
+ // Target is either a LabelElement or a StatementElement.
+ final Element target;
+ HBreak(this.target);
+ toString() => (target is LabelElement) ? 'break ${label.labelName}' : 'break';
accept(HVisitor visitor) => visitor.visitBreak(this);
}

Powered by Google App Engine
This is Rietveld 408576698