From fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 22 Sep 2026 15:50:22 -0700 Subject: Graph cleanup Phis stay with regions, stop sinks to bottom, --- chapter10/src/main/java/com/seaofnodes/simple/Parser.java | 3 ++- .../src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'chapter10/src/main/java/com/seaofnodes') diff --git a/chapter10/src/main/java/com/seaofnodes/simple/Parser.java b/chapter10/src/main/java/com/seaofnodes/simple/Parser.java index 01c7da29..ddbbdf82 100644 --- a/chapter10/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter10/src/main/java/com/seaofnodes/simple/Parser.java @@ -331,6 +331,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 @@ -341,7 +342,7 @@ public class Parser { // Parse the false side _scope = fScope; // Restore scope, then parse else block if any - ctrl(ifF.unkeep()); // Ctrl token is now set to ifFalse projection + ifF.unkeep(); // fScope already owns the false control if (matchx("else")) { _scope.upcast(ifF,pred,true); // Up-cast predicate parseStatement(); diff --git a/chapter10/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java b/chapter10/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java index 545897d8..600e9c73 100644 --- a/chapter10/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java +++ b/chapter10/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java @@ -37,6 +37,7 @@ public class SimpleGraphAdapter extends GraphAdapter { } 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 LoopNode ) return Kind.LOOP; -- cgit v1.2.3