summaryrefslogtreecommitdiff
path: root/chapter02/src/main
diff options
context:
space:
mode:
authorThalia Archibald <thalia@archibald.dev>2024-06-21 06:13:09 -0700
committerGitHub <noreply@github.com>2024-06-21 14:13:09 +0100
commite5f4f7b85fbb91a293a7d89d7b85adfbaeeb51f4 (patch)
tree9b6ecc7ef37b1ec7f08efed6f908f478dc551e03 /chapter02/src/main
parenta749c244bea3e2774d453165cbd18ed52863a8f5 (diff)
downloadSimple-e5f4f7b85fbb91a293a7d89d7b85adfbaeeb51f4.tar.gz
Simple-e5f4f7b85fbb91a293a7d89d7b85adfbaeeb51f4.zip
Format whitespace (#86)
* Trim trailing whitespace * Ensure final new lines * Convert line endings from CRLF to LF * Replace tabs with spaces
Diffstat (limited to 'chapter02/src/main')
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/GraphVisualizer.java8
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/Parser.java4
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/Utils.java2
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/AddNode.java6
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/ConstantNode.java8
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/DivNode.java2
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/MinusNode.java6
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/MulNode.java2
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/Node.java18
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/ReturnNode.java4
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/node/SubNode.java2
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/type/Type.java4
-rw-r--r--chapter02/src/main/java/com/seaofnodes/simple/type/TypeInteger.java12
13 files changed, 39 insertions, 39 deletions
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/GraphVisualizer.java b/chapter02/src/main/java/com/seaofnodes/simple/GraphVisualizer.java
index df128674..4c625be1 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/GraphVisualizer.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/GraphVisualizer.java
@@ -21,7 +21,7 @@ public class GraphVisualizer {
sb.append("/*\n");
sb.append(parser.src());
sb.append("\n*/\n");
-
+
// To keep the Scopes below the graph and pointing up into the graph we
// need to group the Nodes in a subgraph cluster, and the scopes into a
// different subgraph cluster. THEN we can draw edges between the
@@ -35,13 +35,13 @@ public class GraphVisualizer {
// Merge multiple edges hitting the same node. Makes common shared
// nodes much prettier to look at.
sb.append("\tconcentrate=\"true\";\n");
-
+
// Just the Nodes first, in a cluster no edges
nodes(sb, all);
// Walk the Node edges
nodeEdges(sb, all);
-
+
sb.append("}\n");
return sb.toString();
}
@@ -89,7 +89,7 @@ public class GraphVisualizer {
}
}
}
-
+
/**
* Finds all nodes in the graph.
*/
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/Parser.java b/chapter02/src/main/java/com/seaofnodes/simple/Parser.java
index f5aca5ba..155cd353 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/Parser.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/Parser.java
@@ -244,7 +244,7 @@ public class Parser {
return TypeInteger.constant(Long.parseLong(snum));
}
- // First letter of an identifier
+ // First letter of an identifier
private boolean isIdStart(char ch) {
return Character.isAlphabetic(ch) || ch == '_';
}
@@ -260,7 +260,7 @@ public class Parser {
return new String(_input, start, --_position - start);
}
- //
+ //
private boolean isPunctuation(char ch) {
return "=;[]<>()+-/*".indexOf(ch) != -1;
}
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/Utils.java b/chapter02/src/main/java/com/seaofnodes/simple/Utils.java
index 4d663c25..45f15327 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/Utils.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/Utils.java
@@ -36,4 +36,4 @@ public class Utils {
return i;
return -1;
}
-} \ No newline at end of file
+}
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/AddNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/AddNode.java
index a0376dd4..2d58cb75 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/AddNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/AddNode.java
@@ -6,7 +6,7 @@ public class AddNode extends Node {
public AddNode(Node lhs, Node rhs) { super(null, lhs, rhs); }
@Override public String label() { return "Add"; }
-
+
@Override public String glabel() { return "+"; }
@Override
@@ -15,7 +15,7 @@ public class AddNode extends Node {
in(2)._print0(sb.append("+"));
return sb.append(")");
}
-
+
@Override
public Type compute() {
@@ -32,5 +32,5 @@ public class AddNode extends Node {
// TODO: add of 0
return null;
}
-
+
}
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/ConstantNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/ConstantNode.java
index ec85bf1f..e4d7f412 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/ConstantNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/ConstantNode.java
@@ -21,10 +21,10 @@ public class ConstantNode extends Node {
super(Parser.START);
_con = type;
}
-
+
@Override
public String label() { return "#"+_con; }
-
+
@Override
public String uniqueName() { return "Con_" + _nid; }
@@ -32,11 +32,11 @@ public class ConstantNode extends Node {
StringBuilder _print1(StringBuilder sb) {
return _con._print(sb);
}
-
+
@Override
public Type compute() { return _con; }
@Override
public Node idealize() { return null; }
-
+
}
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/DivNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/DivNode.java
index 4f502e5f..e3c3616a 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/DivNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/DivNode.java
@@ -16,7 +16,7 @@ public class DivNode extends Node {
in(2)._print0(sb.append("/"));
return sb.append(")");
}
-
+
@Override
public Type compute() {
if (in(1)._type instanceof TypeInteger i0 &&
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/MinusNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/MinusNode.java
index 08924563..0d59ef25 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/MinusNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/MinusNode.java
@@ -7,15 +7,15 @@ public class MinusNode extends Node {
public MinusNode(Node in) { super(null, in); }
@Override public String label() { return "Minus"; }
-
+
@Override public String glabel() { return "-"; }
-
+
@Override
StringBuilder _print1(StringBuilder sb) {
in(1)._print0(sb.append("(-"));
return sb.append(")");
}
-
+
@Override
public Type compute() {
if (in(1)._type instanceof TypeInteger i0)
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/MulNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/MulNode.java
index c6718d27..26c28281 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/MulNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/MulNode.java
@@ -7,7 +7,7 @@ public class MulNode extends Node {
public MulNode(Node lhs, Node rhs) { super(null, lhs, rhs); }
@Override public String label() { return "Mul"; }
-
+
@Override public String glabel() { return "*"; }
@Override
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/Node.java b/chapter02/src/main/java/com/seaofnodes/simple/node/Node.java
index 960742e8..7e5f2701 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/Node.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/Node.java
@@ -74,9 +74,9 @@ public abstract class Node {
// ------------------------------------------------------------------------
-
+
// Debugger Printing.
-
+
// {@code toString} is what you get in the debugger. It has to print 1
// line (because this is what a debugger typically displays by default) and
// has to be robust with broken graph/nodes.
@@ -103,7 +103,7 @@ public abstract class Node {
// Every Node implements this.
abstract StringBuilder _print1(StringBuilder sb);
-
+
/**
* Gets the ith input node
* @param i Offset of the input node
@@ -120,13 +120,13 @@ public abstract class Node {
public boolean isUnused() { return nOuts() == 0; }
public boolean isCFG() { return false; }
-
+
/**
* Change a <em>def</em> into a Node. Keeps the edges correct, by removing
* the corresponding <em>use->def</em> edge. This may make the original
* <em>def</em> go dead. This function is co-recursive with {@link #kill}.
- *
+ *
* @param idx which def to set
* @param new_def the new definition
* @return new_def for flow coding
@@ -195,7 +195,7 @@ public abstract class Node {
public final Node peephole( ) {
// Compute initial or improved Type
Type type = _type = compute();
-
+
if (_disablePeephole)
return this; // Peephole optimizations turned off
@@ -206,15 +206,15 @@ public abstract class Node {
}
// Future chapter: Global Value Numbering goes here
-
+
// Ask each node for a better replacement
Node n = idealize();
if( n != null ) return n;
-
+
return this; // No progress
}
-
+
/**
* This function needs to be
* <a href="https://en.wikipedia.org/wiki/Monotonic_function">Monotonic</a>
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/ReturnNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/ReturnNode.java
index a0f2e931..7fa470f8 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/ReturnNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/ReturnNode.java
@@ -19,7 +19,7 @@ public class ReturnNode extends Node {
public Node ctrl() { return in(0); }
public Node expr() { return in(1); }
-
+
@Override
public String label() { return "Return"; }
@@ -29,7 +29,7 @@ public class ReturnNode extends Node {
}
@Override public boolean isCFG() { return true; }
-
+
@Override
public Type compute() {
return Type.BOTTOM;
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/node/SubNode.java b/chapter02/src/main/java/com/seaofnodes/simple/node/SubNode.java
index 6eda4f11..d2e32c61 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/node/SubNode.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/node/SubNode.java
@@ -16,7 +16,7 @@ public class SubNode extends Node {
in(2)._print0(sb.append("-"));
return sb.append(")");
}
-
+
@Override
public Type compute() {
if (in(1)._type instanceof TypeInteger i0 &&
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/type/Type.java b/chapter02/src/main/java/com/seaofnodes/simple/type/Type.java
index 5bd51611..89f6c715 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/type/Type.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/type/Type.java
@@ -4,7 +4,7 @@ package com.seaofnodes.simple.type;
/**
* These types are part of a Monotone Analysis Framework,
* @see <a href="https://www.cse.psu.edu/~gxt29/teaching/cse597s21/slides/08monotoneFramework.pdf">see for example this set of slides</a>.
- * <p>
+ * <p>
* The types form a lattice; @see <a href="https://en.wikipedia.org/wiki/Lattice_(order)">a symmetric complete bounded (ranked) lattice.</a>
* <p>
* This wild lattice theory will be needed later to allow us to easily beef up
@@ -15,7 +15,7 @@ package com.seaofnodes.simple.type;
* actual implementation is darn near trivial and is generally really obvious
* what we're doing with it. Right now, it's just simple integer math to do
* simple constant folding e.g. 1+2 == 3 stuff.
- */
+ */
public class Type {
diff --git a/chapter02/src/main/java/com/seaofnodes/simple/type/TypeInteger.java b/chapter02/src/main/java/com/seaofnodes/simple/type/TypeInteger.java
index 69fb811c..13f816bf 100644
--- a/chapter02/src/main/java/com/seaofnodes/simple/type/TypeInteger.java
+++ b/chapter02/src/main/java/com/seaofnodes/simple/type/TypeInteger.java
@@ -6,16 +6,16 @@ package com.seaofnodes.simple.type;
public class TypeInteger extends Type {
public final static TypeInteger ZERO= new TypeInteger(0);
-
+
/**
* The constant value observed for this type
*/
private final long _con;
- public TypeInteger(long con) {
- super(TINT);
- _con = con;
- }
+ public TypeInteger(long con) {
+ super(TINT);
+ _con = con;
+ }
public static TypeInteger constant(long con) { return new TypeInteger(con); }
@@ -24,7 +24,7 @@ public class TypeInteger extends Type {
return _print(new StringBuilder()).toString();
}
- @Override
+ @Override
public StringBuilder _print(StringBuilder sb) { return sb.append(_con); }
@Override