diff options
| -rw-r--r-- | chapter01/README.md | 2 | ||||
| -rw-r--r-- | chapter01/src/main/java/com/seaofnodes/simple/node/Node.java | 6 | ||||
| -rw-r--r-- | chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/chapter01/README.md b/chapter01/README.md index 69a09328..5a59ace8 100644 --- a/chapter01/README.md +++ b/chapter01/README.md @@ -86,7 +86,7 @@ We discuss this in detail in Chapter 9: Functions and Calls. A Constant node represents a constant value. At present, the only constants that we allow are integer literals; therefore Constants contain an integer -value. As we add other types of constants, we refactor how we represent +value. As we add other types of constants, we will refactor how we represent Constants. Constants have no semantic inputs. However, we set Start as an input to diff --git a/chapter01/src/main/java/com/seaofnodes/simple/node/Node.java b/chapter01/src/main/java/com/seaofnodes/simple/node/Node.java index bafa58f4..f817db52 100644 --- a/chapter01/src/main/java/com/seaofnodes/simple/node/Node.java +++ b/chapter01/src/main/java/com/seaofnodes/simple/node/Node.java @@ -33,7 +33,6 @@ public abstract class Node { * input. These nodes are users of this node, thus these are def-use * references to Nodes. * <p> - * Outputs directly match inputs, making a directed graph that can be * walked in either direction. These outputs are typically used for * efficient optimizations but otherwise have no semantics meaning. @@ -67,6 +66,11 @@ public abstract class Node { public int nIns() { return _inputs.size(); } + /** + * Gets the ith output node + * @param i Offset of the output node + * @return Output node (not null) + */ public Node out(int i) { return _outputs.get(i); } public int nOuts() { return _outputs.size(); } diff --git a/chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java b/chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java index 9bc2fc1c..15ae7863 100644 --- a/chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java +++ b/chapter01/src/test/java/com/seaofnodes/simple/ParserTest.java @@ -8,7 +8,7 @@ public class ParserTest { @Test public void testSimpleProgram() { - Parser parser = new Parser(); + Parser parser = new Parser(new NodeIDGenerator()); StartNode startNode = parser.parse("return 1;"); Assert.assertNotNull(startNode); Assert.assertEquals(2, startNode.nOuts()); |
