From 6852981f48f55b245fae6229c2930c3d09d9e45e Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 6 May 2025 13:44:10 -0700 Subject: README --- .../com/seaofnodes/simple/type/TypeConAryI.java | 2 +- .../java/com/seaofnodes/simple/Chapter22Test.java | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'chapter22/src') diff --git a/chapter22/src/main/java/com/seaofnodes/simple/type/TypeConAryI.java b/chapter22/src/main/java/com/seaofnodes/simple/type/TypeConAryI.java index 2a5900c7..f888a93d 100644 --- a/chapter22/src/main/java/com/seaofnodes/simple/type/TypeConAryI.java +++ b/chapter22/src/main/java/com/seaofnodes/simple/type/TypeConAryI.java @@ -9,7 +9,7 @@ public class TypeConAryI extends TypeConAry { private static final TypeConAryI I123 = make(new int[]{1,2,3}); public static void gather(ArrayList ts) { ts.add(I123); } @Override public String str() { return "[i32]"; } - @Override public int alignment() { return 3; } + @Override public int alignment() { return 2; } @Override boolean eq(Type t) { return Arrays.equals(_ary,((TypeConAryI)t)._ary); } @Override int hash() { return Arrays.hashCode(_ary); } } diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java index 3c228a5b..eddba242 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java @@ -32,7 +32,7 @@ public class Chapter22Test { } - @Test public void testJig1() throws IOException { + @Test public void testR5Load() throws IOException { EvalRisc5 R5 = TestRisc5.build("riscv_load", 0, 0, false); int trap = R5.step(100); assertEquals(0,trap); @@ -123,5 +123,25 @@ return cc.cz; assertEquals(0,arm.regs[0]); } + @Test + public void testFinalArray() { + String src = """ +int N=4; +i32[] !is = new i32[N]; +for( int i=0; i + int sum=0; + for( int i=0; i