summaryrefslogtreecommitdiff
path: root/chapter14
diff options
context:
space:
mode:
Diffstat (limited to 'chapter14')
-rw-r--r--chapter14/src/main/java/com/seaofnodes/simple/Parser.java3
-rw-r--r--chapter14/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java1
2 files changed, 3 insertions, 1 deletions
diff --git a/chapter14/src/main/java/com/seaofnodes/simple/Parser.java b/chapter14/src/main/java/com/seaofnodes/simple/Parser.java
index 5d7d67da..34fac183 100644
--- a/chapter14/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter14/src/main/java/com/seaofnodes/simple/Parser.java
@@ -370,6 +370,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
@@ -380,7 +381,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
_scope.upcast(ifF,pred,true); // Up-cast predicate
if (matchx("else")) {
parseStatement();
diff --git a/chapter14/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java b/chapter14/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
index 39f79e69..4b1cc065 100644
--- a/chapter14/src/main/java/com/seaofnodes/simple/print/SimpleGraphAdapter.java
+++ b/chapter14/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 StartNode ) return Kind.CTRL;
if( n instanceof LoopNode ) return Kind.LOOP;