From dac097b61e847395a1526d4ecd593c25cdf5fd3c Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 10 May 2025 13:03:20 -0700 Subject: Remove some junk sign extends --- .../java/com/seaofnodes/simple/Chapter22Test.java | 4 +- .../test/java/com/seaofnodes/simple/progs/jig.smp | 92 ++-------------------- 2 files changed, 7 insertions(+), 89 deletions(-) (limited to 'chapter22/src/test') diff --git a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java index 4823dff8..bfb20705 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java +++ b/chapter22/src/test/java/com/seaofnodes/simple/Chapter22Test.java @@ -15,8 +15,8 @@ public class Chapter22Test { @Test @Ignore public void testJig() throws IOException { - //String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/jig.smp")); - String src = Files.readString(Path.of("docs/examples/BubbleSort.smp")); + String src = Files.readString(Path.of("src/test/java/com/seaofnodes/simple/progs/jig.smp")); + //String src = Files.readString(Path.of("docs/examples/BubbleSort.smp")); testCPU(src,"x86_64_v2", "Win64" ,-1,null); testCPU(src,"riscv" , "SystemV",-1,null); testCPU(src,"arm" , "SystemV",-1,null); 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 70f45717..fd3e7b9c 100644 --- a/chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp +++ b/chapter22/src/test/java/com/seaofnodes/simple/progs/jig.smp @@ -1,88 +1,6 @@ // -*- mode: java; -*- - -val _exit = { u8[~] msg -> - sys.io.p(msg); - sys.libc._exit(1); -}; -val usage = { -> _exit("stdin must look like [4, 3, 2, 1]"); }; - -// Scanner -struct Scan { - int !x; - u8[~] buf; -}; - -// Skip whitespace -val skip = { Scan s -> - while( s.buf[s.x] <= 32 ) - s.x++; -}; - -// Require specific syntax or usage -val require = { Scan s, u8 c -> - skip(s); - if( s.buf[s.x++] != c ) - usage(); -}; - -val peek = { Scan s, u8 c -> - skip(s); - if( s.buf[s.x] != c ) return false; - s.x++; - return true; -}; - -val number = { Scan s -> - skip(s); - i32 n = 0; - while( '0' <= s.buf[s.x] & s.buf[s.x] <= '9' ) - n = n*10 + (s.buf[s.x++] - '0'); - return n; -}; - - -// Read from stdin a line of the form "[ 4, 3, 2, 1]" and print it sorted. -val main = { -> - Scan !s = new Scan{ buf = sys.io.stdin(); }; - require(s,'['); - // Array of parsed results - int[] !ns = new int[16]; - i32 num = 0; - // Parse a list of numbers - if( !peek(s,']') ) { // Handle the empty list - // Parse "123, " until a something else - while( s.x < s.buf# ) { - int n = number(s); - i32 q=n; - ns[num++] = n; - if( !peek(s,',') ) - break; - }; - require(s,']'); // Close the list - } - - // Print a list of numbers - sys.io.p("[ "); - u8[] !buf = new u8[20]; - for( int i=0; i0 ) - { q/=10; log++; } - i32 raw=log; - sys.libc._exit(raw); - // for( int j=0, a=x; j>48; +return 0; -- cgit v1.2.3