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

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

Issue 9421035: Support break and labeled statements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Update expectations. Created 8 years, 10 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
« no previous file with comments | « frog/leg/ssa/codegen.dart ('k') | frog/leg/ssa/optimize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/ssa/nodes.dart
diff --git a/frog/leg/ssa/nodes.dart b/frog/leg/ssa/nodes.dart
index fe30b3e4b21cd28a0bce308e546dd015155ab40e..5b07a90119b096d674d39e6ed0dc04f8b503db18 100644
--- a/frog/leg/ssa/nodes.dart
+++ b/frog/leg/ssa/nodes.dart
@@ -11,6 +11,7 @@ interface HVisitor<R> {
R visitBitXor(HBitXor node);
R visitBoolify(HBoolify node);
R visitBoundsCheck(HBoundsCheck node);
+ R visitBreak(HBreak node);
R visitDivide(HDivide node);
R visitEquals(HEquals node);
R visitExit(HExit node);
@@ -146,9 +147,9 @@ class HGraph {
return result;
}
- HBasicBlock addNewLoopHeaderBlock() {
+ HBasicBlock addNewLoopHeaderBlock(List<SourceString> labels) {
HBasicBlock result = addNewBlock();
- result.loopInformation = new HLoopInformation(result);
+ result.loopInformation = new HLoopInformation(result, labels);
return result;
}
@@ -308,6 +309,7 @@ class HBaseVisitor extends HGraphVisitor implements HVisitor {
visitBailoutTarget(HBailoutTarget node) => visitInstruction(node);
visitBoolify(HBoolify node) => visitInstruction(node);
visitBoundsCheck(HBoundsCheck node) => visitCheck(node);
+ visitBreak(HBreak node) => visitGoto(node);
visitCheck(HCheck node) => visitInstruction(node);
visitDivide(HDivide node) => visitBinaryArithmetic(node);
visitEquals(HEquals node) => visitRelational(node);
@@ -451,6 +453,7 @@ class HBasicBlock extends HInstructionList {
HInstructionList phis;
HLoopInformation loopInformation = null;
+ HLabeledBlockInformation labeledBlockInformation = null;
HBasicBlock parentLoopHeader = null;
List<HBailoutTarget> bailouts;
@@ -460,6 +463,9 @@ 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(),
@@ -473,6 +479,8 @@ class HBasicBlock extends HInstructionList {
bool isClosed() => status == STATUS_CLOSED;
bool isLoopHeader() => loopInformation !== null;
+ bool hasLabeledBlockInformation() => labeledBlockInformation !== null;
+
bool hasBailouts() => !bailouts.isEmpty();
void open() {
@@ -684,12 +692,24 @@ class HBasicBlock extends HInstructionList {
}
}
-class HLoopInformation {
+class HBlockInformation {
+ // Just a marker class.
+}
+
+class HLabeledBlockInformation extends HBlockInformation {
+ final HBasicBlock start;
+ final HBasicBlock end;
+ final List<SourceString> labels;
+ HLabeledBlockInformation(this.start, this.end, this.labels);
+}
+
+class HLoopInformation extends HBlockInformation {
final HBasicBlock header;
final List<HBasicBlock> blocks;
final List<HBasicBlock> backEdges;
+ final List<SourceString> labels;
- HLoopInformation(this.header)
+ HLoopInformation(this.header, this.labels)
: blocks = new List<HBasicBlock>(),
backEdges = new List<HBasicBlock>();
@@ -1746,6 +1766,13 @@ class HGoto extends HControlFlow {
accept(HVisitor visitor) => visitor.visitGoto(this);
}
+class HBreak extends HGoto {
+ final SourceString label;
+ HBreak([this.label]);
+ toString() => 'break';
+ accept(HVisitor visitor) => visitor.visitBreak(this);
+}
+
class HTry extends HControlFlow {
HParameterValue exception;
HBasicBlock finallyBlock;
« no previous file with comments | « frog/leg/ssa/codegen.dart ('k') | frog/leg/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698