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

Unified Diff: pkg/compiler/lib/src/ssa/graph_builder.dart

Issue 2637483002: Implement switch statement, without the "complex switch statement" (aka switch statement with conti… (Closed)
Patch Set: . Created 3 years, 11 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: pkg/compiler/lib/src/ssa/graph_builder.dart
diff --git a/pkg/compiler/lib/src/ssa/graph_builder.dart b/pkg/compiler/lib/src/ssa/graph_builder.dart
index 8948546d14300a70abb9800e664b38ee9c95967b..57ae855691ac0211357ea9cd1b33fce465c2d3d3 100644
--- a/pkg/compiler/lib/src/ssa/graph_builder.dart
+++ b/pkg/compiler/lib/src/ssa/graph_builder.dart
@@ -35,6 +35,11 @@ abstract class GraphBuilder {
/// A reference to the compiler.
Compiler compiler;
+ /// True if the builder is processing nodes inside a try statement. This is
+ /// important for generating control flow out of a try block like returns or
+ /// breaks.
+ bool inTryStatement = false;
+
/// The JavaScript backend we are targeting in this compilation.
JavaScriptBackend get backend;
@@ -180,17 +185,6 @@ abstract class GraphBuilder {
return result;
}
- void handleIf(
- {ast.Node node,
- void visitCondition(),
- void visitThen(),
- void visitElse(),
- SourceInformation sourceInformation}) {
- SsaBranchBuilder branchBuilder = new SsaBranchBuilder(this, compiler, node);
- branchBuilder.handleIf(visitCondition, visitThen, visitElse,
- sourceInformation: sourceInformation);
- }
-
HSubGraphBlockInformation wrapStatementGraph(SubGraph statements) {
if (statements == null) return null;
return new HSubGraphBlockInformation(statements);
@@ -237,6 +231,16 @@ abstract class GraphBuilder {
return callSetRuntimeTypeInfo(typeInfo, newObject);
}
+ /// Called when control flow is about to change, in which case we need to
+ /// specify special successors if we are already in a try/catch/finally block.
+ void handleInTryStatement() {
+ if (!inTryStatement) return;
+ HBasicBlock block = close(new HExitTry());
+ HBasicBlock newBlock = graph.addNewBlock();
+ block.addSuccessor(newBlock);
+ open(newBlock);
+ }
+
HInstruction callSetRuntimeTypeInfo(
HInstruction typeInfo, HInstruction newObject);

Powered by Google App Engine
This is Rietveld 408576698