diff options
| author | Cliff Click <cliffc@acm.org> | 2023-09-18 16:52:59 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2023-09-18 16:52:59 -0700 |
| commit | bb1a8771e7635b3e688f35b46453e1ae5d07147c (patch) | |
| tree | 0b34bb0c8ddb42450b7d13efce17838cc0397a8b | |
| parent | b1d28a7d1d7996aaaef67b7823725c47e97a7d88 (diff) | |
| parent | 7e0b33067d83348b87652261845c2f40823012c7 (diff) | |
| download | Simple-bb1a8771e7635b3e688f35b46453e1ae5d07147c.tar.gz Simple-bb1a8771e7635b3e688f35b46453e1ae5d07147c.zip | |
Merge branch 'main' of https://github.com/dibyendumajumdar/Simple into pr/2
| -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()); |
