summaryrefslogtreecommitdiff
path: root/chapter03/src
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2024-08-15 12:13:46 -0700
committerGitHub <noreply@github.com>2024-08-15 12:13:46 -0700
commitfcc6da8be593ea4cc0cb3848d4509bd626ebbe1e (patch)
tree34403fbb2a78c264ede63671b91389f7d66472bb /chapter03/src
parenta35078a6d30c1eb5dabcf6d9c001cdd41e2b7c89 (diff)
downloadSimple-fcc6da8be593ea4cc0cb3848d4509bd626ebbe1e.tar.gz
Simple-fcc6da8be593ea4cc0cb3848d4509bd626ebbe1e.zip
Scope docs (#99)
* More scope docs * readme updates
Diffstat (limited to 'chapter03/src')
-rw-r--r--chapter03/src/main/java/com/seaofnodes/simple/node/ScopeNode.java11
-rw-r--r--chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java1
2 files changed, 6 insertions, 6 deletions
diff --git a/chapter03/src/main/java/com/seaofnodes/simple/node/ScopeNode.java b/chapter03/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
index e9ff0f44..379ef033 100644
--- a/chapter03/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
+++ b/chapter03/src/main/java/com/seaofnodes/simple/node/ScopeNode.java
@@ -7,11 +7,12 @@ import java.util.*;
/**
* The Scope node is purely a parser helper - it tracks names to nodes with a
* stack of scopes.
+ * @see <a href="file:../../../../../../../../chapter03/README.md">chapter03/README.md</a>
*/
public class ScopeNode extends Node {
/**
- * Names for every input edge
+ * A Stack of symbol tables; a symbol table is a map from names to node indices.
*/
public final Stack<HashMap<String, Integer>> _scopes;
@@ -48,7 +49,7 @@ public class ScopeNode extends Node {
* Recover the names for all variable bindings.
* The result is an array of names that is aligned with the
* inputs to the Node.
- *
+ * <p>
* This is an expensive operation.
*/
public String[] reverseNames() {
@@ -77,21 +78,21 @@ public class ScopeNode extends Node {
}
/**
* Lookup a name in all scopes starting from most deeply nested.
- *
+ * <p>
* @param name Name to be looked up
* @see #update(String, Node, int)
*/
public Node lookup( String name ) { return update(name,null,_scopes.size()-1); }
/**
* If the name is present in any scope, then redefine else null
- *
+ * <p>
* @param name Name being redefined
* @param n The node to bind to the name
*/
public Node update( String name, Node n ) { return update(name,n,_scopes.size()-1); }
/**
* Both recursive lookup and update.
- *
+ * <p>
* A shared implementation allows us to create lazy phis both during
* lookups and updates; the lazy phi creation is part of chapter 8.
*
diff --git a/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index 950d87fe..bdb1d9ea 100644
--- a/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter03/src/test/java/com/seaofnodes/simple/Chapter03Test.java
@@ -1,7 +1,6 @@
package com.seaofnodes.simple;
import com.seaofnodes.simple.node.*;
-import com.seaofnodes.simple.type.TypeInteger;
import org.junit.Test;
import static org.junit.Assert.*;