diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-22 15:50:22 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-22 15:50:22 -0700 |
| commit | fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 (patch) | |
| tree | f27250a0efcc74354831da98d2cf764dfa7d9216 /chapter20/src | |
| parent | ed13d1ca215ea094b4d6beab89b90ab4c05ed396 (diff) | |
| download | Simple-fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12.tar.gz Simple-fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12.zip | |
Graph cleanup
Phis stay with regions, stop sinks to bottom,
Diffstat (limited to 'chapter20/src')
| -rw-r--r-- | chapter20/src/main/java/com/seaofnodes/simple/Parser.java | 3 | ||||
| -rw-r--r-- | chapter20/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/chapter20/src/main/java/com/seaofnodes/simple/Parser.java b/chapter20/src/main/java/com/seaofnodes/simple/Parser.java index 0809a6f3..af047850 100644 --- a/chapter20/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter20/src/main/java/com/seaofnodes/simple/Parser.java @@ -503,6 +503,7 @@ public class Parser { // In if true branch, the ifT proj node becomes the ctrl // But first clone the scope and set it as current 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 @@ -520,7 +521,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 // Up-cast predicate, even if not else clause, because predicate can // remain true if the true clause exits: `if( !ptr ) return 0; return ptr.fld;` _scope.addGuards(ifF,pred,true); diff --git a/chapter20/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java b/chapter20/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java index 15afe5d1..5c277abc 100644 --- a/chapter20/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java +++ b/chapter20/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java @@ -38,6 +38,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 FunNode ) return Kind.FUN; if( n instanceof StartNode ) return Kind.CTRL; |
