summaryrefslogtreecommitdiff
path: root/chapter22
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 /chapter22
parent5b04bd29ca5dbbaf55786c03ef0d38b41eef579b (diff)
downloadSimple-aa31b718eb0643bd0aaec3487384c396f9ebe975.tar.gz
Simple-aa31b718eb0643bd0aaec3487384c396f9ebe975.zip
Series of minor fixes
Diffstat (limited to 'chapter22')
-rw-r--r--chapter22/README.md2
-rw-r--r--chapter22/src/test/java/com/seaofnodes/simple/Simple.java7
-rw-r--r--chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp20
3 files changed, 20 insertions, 9 deletions
diff --git a/chapter22/README.md b/chapter22/README.md
index 65625ecb..f31dcf19 100644
--- a/chapter22/README.md
+++ b/chapter22/README.md
@@ -29,7 +29,7 @@ Let's break it down.
pool*, and from there in an ELF file's RODATA section.
- You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linear-chapter22) 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-chapter21...linear-chapter22) it to the previous chapter.
+You can also read [this chapter](https://github.com/SeaOfNodes/Simple/tree/linear-chapter22) 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-chapter21...linear-chapter22) it to the previous chapter.
## Nested Types and Static Fields
diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Simple.java b/chapter22/src/test/java/com/seaofnodes/simple/Simple.java
index 1465aa6d..cc044b6f 100644
--- a/chapter22/src/test/java/com/seaofnodes/simple/Simple.java
+++ b/chapter22/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 {
diff --git a/chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp b/chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp
index fd3e7b9c..f7a5d202 100644
--- a/chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp
+++ b/chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp
@@ -1,6 +1,16 @@
// -*- mode: java; -*-
-// Should fold away sign extend
-struct Person { i8 age;};
-Person !p = new Person;
-p.age = (arg<<48)>>48;
-return 0;
+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);