summaryrefslogtreecommitdiff
path: root/chapter05/src
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-22 15:50:22 -0700
committerCliff Click <cliffc@acm.org>2026-09-22 15:50:22 -0700
commitfb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 (patch)
treef27250a0efcc74354831da98d2cf764dfa7d9216 /chapter05/src
parented13d1ca215ea094b4d6beab89b90ab4c05ed396 (diff)
downloadSimple-fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12.tar.gz
Simple-fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12.zip
Graph cleanup
Phis stay with regions, stop sinks to bottom,
Diffstat (limited to 'chapter05/src')
-rw-r--r--chapter05/src/main/java/com/seaofnodes/simple/Parser.java2
-rw-r--r--chapter05/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java1
2 files changed, 2 insertions, 1 deletions
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java
index dbaa093d..359d0175 100644
--- a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java
@@ -166,6 +166,7 @@ public class Parser {
// But first clone the scope and set it as current
int ndefs = _scope.nIns();
ScopeNode fScope = _scope.dup(); // Duplicate current scope
+ fScope.ctrl(ifF); // The pending arm already starts at False
_xScopes.push(fScope); // For graph visualization we need all scopes
// Parse the true side
@@ -175,7 +176,6 @@ public class Parser {
// Parse the false side
_scope = fScope; // Restore scope, then parse else block if any
- ctrl(ifF); // Ctrl token is now set to ifFalse projection
if (matchx("else")) {
parseStatement();
fScope = _scope;
diff --git a/chapter05/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java b/chapter05/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
index 2ec62125..0c2ac4b0 100644
--- a/chapter05/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
+++ b/chapter05/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
@@ -34,6 +34,7 @@ public class SimpleGraphAdapter extends GraphAdapter<Node> {
}
private Kind kind(Node n) {
+ if( n instanceof StopNode ) return Kind.STOP;
if( n instanceof ScopeNode ) return Kind.SCOPE;
if( n instanceof StartNode ) return Kind.CTRL;
if( n instanceof RegionNode ) return Kind.REGION;