summaryrefslogtreecommitdiff
path: root/chapter04
diff options
context:
space:
mode:
authorDibyendu Majumdar <dibyendumajumdar@users.noreply.github.com>2023-10-27 19:22:24 +0100
committerGitHub <noreply@github.com>2023-10-27 11:22:24 -0700
commit1c2965adcdfa8d732998bf154dd341ad8fe3032d (patch)
tree6c570fe93a4696792915fc159242f63513914433 /chapter04
parent0049146baf2502809ed3f29b07cc5f90513cb747 (diff)
downloadSimple-1c2965adcdfa8d732998bf154dd341ad8fe3032d.tar.gz
Simple-1c2965adcdfa8d732998bf154dd341ad8fe3032d.zip
Applied fix for #12 to chapter 3 (#15)
ScopeNode added to chapter 3 Revised the description for Chapter 3 and 4 to include ScopeNode.
Diffstat (limited to 'chapter04')
-rw-r--r--chapter04/README.md3
-rw-r--r--chapter04/src/main/java/com/seaofnodes/simple/Parser.java2
2 files changed, 4 insertions, 1 deletions
diff --git a/chapter04/README.md b/chapter04/README.md
index 7e8a8eea..45d054de 100644
--- a/chapter04/README.md
+++ b/chapter04/README.md
@@ -33,6 +33,7 @@ Below is our list of Nodes from [Chapter 3](../chapter03/README.md):
| Mul | Data | Multiply two values | Two data nodes, values are multiplied, order not important | Result of the multiply |
| Div | Data | Divide a value by another | Two data nodes, values are divided, order matters | Result of the division |
| UnaryMinus | Data | Negate a value | One data node, value is negated | Result of the unary minus |
+| Scope | ? | Represents scopes in the graph | All nodes that define variables | None |
## Projection Nodes
@@ -228,7 +229,7 @@ The peephole method does following:
private Node deadCodeElim(Node m) {
// If self is going dead and not being returned here (Nodes returned
// from peephole commonly have no uses (yet)), then kill self.
- if( m != this && isDead() ) {
+ if( m != this && isUnused() ) {
// Killing self - and since self recursively kills self's inputs we
// might end up killing 'm', which we are returning as a live Node.
// So we add a bogus extra null output edge to stop kill().
diff --git a/chapter04/src/main/java/com/seaofnodes/simple/Parser.java b/chapter04/src/main/java/com/seaofnodes/simple/Parser.java
index a6872106..147515f6 100644
--- a/chapter04/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter04/src/main/java/com/seaofnodes/simple/Parser.java
@@ -45,6 +45,8 @@ public class Parser {
String src() { return new String( _lexer._input ); }
+
+
public ReturnNode parse() {
_scope.push();
try {