From 809e8701e48bd92cf0570ce536dbb74b84fccd9a Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 5 May 2025 11:17:51 -0700 Subject: Printing a string Bug fix big constant ELF numbering cpool writing handles constant arrays casting an array to an int works, gives the array base as int; suitable for passing to FFI. Is not GC stable. Encode `ldi` ptrs. Types have a size, logsize, and alignment. Explicit struct layout --- chapter22/src/test/java/com/seaofnodes/simple/Chapter15Test.java | 4 ++-- chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java | 4 ++-- chapter22/src/test/java/com/seaofnodes/simple/progs/helloWorld.smp | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'chapter22/src/test/java/com/seaofnodes') diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter15Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter15Test.java index cebbf4a0..a98e62d8 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter15Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter15Test.java @@ -253,10 +253,10 @@ return new flt; public void testBad1() { CodeGen code = new CodeGen( """ -int is = new int[2]; +flt is = new int[2]; """); try { code.parse().opto(); fail(); } - catch( Exception e ) { assertEquals("Type *[int] is not of declared type int",e.getMessage()); } + catch( Exception e ) { assertEquals("Type *[int] is not of declared type flt",e.getMessage()); } } @Test diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java index b99a01a6..de9c35c7 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java @@ -33,7 +33,7 @@ public class Chapter22Test { @Test public void testJig1() throws IOException { - EvalRisc5 R5 = TestRisc5.build("riscv_load", 0, 0, true); + EvalRisc5 R5 = TestRisc5.build("riscv_load", 0, 0, false); int trap = R5.step(100); assertEquals(0,trap); // do assertEquals here @@ -108,7 +108,7 @@ return cc.cz; @Test @Ignore public void testHelloWorld() throws IOException { String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/helloWorld.smp")); - TestC.run(src,TestC.CALL_CONVENTION,null,null,"build/objs/helloWorld","","Hello, World!",13); + TestC.run(src,TestC.CALL_CONVENTION,null,null,"build/objs/helloWorld","","Hello, World!",0); } diff --git a/chapter22/src/test/java/com/seaofnodes/simple/progs/helloWorld.smp b/chapter22/src/test/java/com/seaofnodes/simple/progs/helloWorld.smp index 16ef4bc6..b83a055c 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/progs/helloWorld.smp +++ b/chapter22/src/test/java/com/seaofnodes/simple/progs/helloWorld.smp @@ -1,2 +1,4 @@ // -*- mode: java; -*- -return sys.libc.write(1,"Hello, World!",13); +i64 buf = "Hello, World!"; +sys.libc.write(1,buf,13); +return 0; -- cgit v1.2.3