summaryrefslogtreecommitdiff
path: root/chapter31/src/main/smp/sys/aryu8.smp
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-11-13 16:17:13 -0800
committerCliff Click <cliffc@acm.org>2026-11-13 16:17:13 -0800
commitafcf96444366fb4b7c83f938763013cbc360aade (patch)
tree67eb69ac6cc58322549020550d48aceb8f2f5ff8 /chapter31/src/main/smp/sys/aryu8.smp
parentd2c59dbe9d6cc8dc4ff4d1e7949bfeddd8bef5d0 (diff)
downloadSimple-afcf96444366fb4b7c83f938763013cbc360aade.tar.gz
Simple-afcf96444366fb4b7c83f938763013cbc360aade.zip
Array init syntax
New array init syntax; used in a bunch of places. Allows e.g. read-only arrays with not-null entries. Fix bug x86 encoding of mem/cmp/fp compares
Diffstat (limited to 'chapter31/src/main/smp/sys/aryu8.smp')
-rw-r--r--chapter31/src/main/smp/sys/aryu8.smp11
1 files changed, 4 insertions, 7 deletions
diff --git a/chapter31/src/main/smp/sys/aryu8.smp b/chapter31/src/main/smp/sys/aryu8.smp
index 88574522..76d47ec5 100644
--- a/chapter31/src/main/smp/sys/aryu8.smp
+++ b/chapter31/src/main/smp/sys/aryu8.smp
@@ -69,10 +69,7 @@ val atoi = { u8[~] str ->
// Zero-terminate a string for libc, reserving one array element for the zero.
{ u8[~] -> u8[] } str0 = { u8[~] str ->
- if( str# == sys.integer.MAX_U32 ) libc._exit(1);
- u8[] !strz = new u8[str#+1];
- u32 len=str#;
- ary.copy(strz,0,str,0,len);
- strz[str#] = '\0';
- strz;
-};
+ if( str# == sys.integer.MAX_U32 ) libc._exit(1);
+ // Copy, terminate and return
+ return new u8[str#+1]{i64 i -> i<str# ? str[i] : '\0'; };
+}; \ No newline at end of file