summaryrefslogtreecommitdiff
path: root/chapter24
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-07-03 14:14:43 -0700
committerCliff Click <cliffc@acm.org>2026-07-03 14:14:43 -0700
commitaa31b718eb0643bd0aaec3487384c396f9ebe975 (patch)
tree532a2fa1b499bce5f66e57e5496bc31991d3be0b /chapter24
parent5b04bd29ca5dbbaf55786c03ef0d38b41eef579b (diff)
downloadSimple-aa31b718eb0643bd0aaec3487384c396f9ebe975.tar.gz
Simple-aa31b718eb0643bd0aaec3487384c396f9ebe975.zip
Series of minor fixes
Diffstat (limited to 'chapter24')
-rw-r--r--chapter24/README.md2
-rw-r--r--chapter24/pom.xml4
-rw-r--r--chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java37
-rw-r--r--chapter24/src/test/java/com/seaofnodes/simple/Simple.java7
4 files changed, 25 insertions, 25 deletions
diff --git a/chapter24/README.md b/chapter24/README.md
index cd5693d4..22fda399 100644
--- a/chapter24/README.md
+++ b/chapter24/README.md
@@ -7,7 +7,7 @@ We also present an Interprocedural Sparse Conditional Constant Propagation
algorithm.
-You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linear-chapter23) in a linear Git revision history on the [linear](https://github.com/SeaOfNodes/Simple/tree/linear) branch and [compare](https://github.com/SeaOfNodes/Simple/compare/linear-chapter22...linear-chapter23) it to the previous chapter.
+You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linear-chapter24) in a linear Git revision history on the [linear](https://github.com/SeaOfNodes/Simple/tree/linear) branch and [compare](https://github.com/SeaOfNodes/Simple/compare/linear-chapter23...linear-chapter24) it to the previous chapter.
## Chaining Relational Tests
diff --git a/chapter24/pom.xml b/chapter24/pom.xml
index 6a59188f..4f0f80b1 100644
--- a/chapter24/pom.xml
+++ b/chapter24/pom.xml
@@ -8,7 +8,7 @@
<artifactId>simple</artifactId>
<version>1.0</version>
</parent>
- <artifactId>chapter23</artifactId>
+ <artifactId>chapter24</artifactId>
<packaging>jar</packaging>
- <name>Chapter 23</name>
+ <name>Chapter 24</name>
</project>
diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java
index 9e230bcd..78b9e7a1 100644
--- a/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java
+++ b/chapter24/src/test/java/com/seaofnodes/simple/Chapter22Test.java
@@ -16,24 +16,23 @@ public class Chapter22Test {
@Test
public void testJig() throws IOException {
String src =
- """
- struct s0 {
- bool v1;
- i16 v2;
- int v3;
- i8 v4;
- byte v5;
- };
- while(new s0.v3)
- while(new s0.v5<<new s0.v4) {}
- if(0) {
- if(0) {
- flt !P5ZUD4=new s0.v2;
- }
- while(0) {}
- }
- return new s0.v1;
- """;
+"""
+val fib = {int n ->
+ int temp=0;
+ int f1=1;
+ int f2=1;
+ int i=n;
+ while( i>1 ){
+ temp = f1+f2;
+ f1=f2;
+ f2=temp;
+ i=i-1;
+ }
+ return f2;
+};
+
+fib(10);
+""";
testCPU(src,"x86_64_v2", "Win64" ,-1,null);
testCPU(src,"riscv" , "SystemV",-1,null);
testCPU(src,"arm" , "SystemV",-1,null);
@@ -138,7 +137,7 @@ struct Person {
val fcn = { Person?[] ps, int x ->
if( ps[x] )
ps[x].age++;
-};
+};
""";
String person = "6\n";
TestC.run(src, "person", null, person, 0);
diff --git a/chapter24/src/test/java/com/seaofnodes/simple/Simple.java b/chapter24/src/test/java/com/seaofnodes/simple/Simple.java
index 8b275389..be582a64 100644
--- a/chapter24/src/test/java/com/seaofnodes/simple/Simple.java
+++ b/chapter24/src/test/java/com/seaofnodes/simple/Simple.java
@@ -143,9 +143,10 @@ Options:
System.out.printf( "TOTAL COMPILATION TIME: %.3f sec%n", total);
}
- static String getInput() {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- return reader.lines().collect(Collectors.joining("\n"));
+ static String getInput() throws IOException {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
+ return reader.lines().collect(Collectors.joining("\n"));
+ }
}
public static void main(String[] args) throws Exception {