From 65cc1fa45d695266ad51252f7427ad8e9ab5ba04 Mon Sep 17 00:00:00 2001 From: dibyendumajumdar Date: Sat, 28 Oct 2023 14:24:30 +0100 Subject: Small cleanup --- chapter05/src/main/java/com/seaofnodes/simple/Parser.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'chapter05/src/main/java/com') diff --git a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java index b141d7ac..fc105523 100644 --- a/chapter05/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter05/src/main/java/com/seaofnodes/simple/Parser.java @@ -69,7 +69,7 @@ public class Parser { return _scope.lookup(CTRL_TOKEN); } - private void updateCtrlToken(Node n) { + private void setCtrlToken(Node n) { _scope.update(CTRL_TOKEN, n); } @@ -136,19 +136,17 @@ public class Parser { ScopeNode ifScope = _scope.dup(); // Duplicate current scope _allScopes.add(ifScope); // For graph visualization we need all scopes _scope = ifScope; // ifScope is now the current scope - updateCtrlToken(ifT); // set ctrl token to ifTrue projection + setCtrlToken(ifT); // set ctrl token to ifTrue projection parseStatement(); - // restore scope _scope = savedScope; // Restore scope to original, we use this for else block if any - // Setup ifF as the ctrl - updateCtrlToken(ifF); // Ctrl token is now set to ifFalse projection + setCtrlToken(ifF); // Ctrl token is now set to ifFalse projection if (match("else")) parseStatement(); // Create region node and merge scopes // If a var is in both scopes and has different binding then we need to create PhiNode for it // After merge _scope remains, and ifScope is discarded - System.out.println(new GraphVisualizer().generateDotOutput(this)); + //System.out.println(new GraphVisualizer().generateDotOutput(this)); RegionNode region = mergeScopes(ifT, ifScope, ifF, _scope); - updateCtrlToken(region); // Now region becomes the ctrl token + setCtrlToken(region); // Now region becomes the ctrl token ifScope.clear(); // Clean up ifScope _allScopes.remove(ifScope); // Discard ifScope return region; -- cgit v1.2.3