diff options
| author | 2026-10-14 08:29:46 +0330 | |
|---|---|---|
| committer | 2026-10-14 08:29:46 +0330 | |
| commit | 1c53304d03414890af0da7432d1aea87e754a14a (patch) | |
| tree | 97190d86cf548c9bc63f68c86a4d2a4f09809713 /tests/programs/sized.zc | |
| parent | a (diff) | |
feat: grow memory limits, add icon/actor libraries, overhaul LSP diagnostics
Compiler and VM
- make every memory map limit dynamic and adjustable at both build time and
runtime, including compiler tables, stacks, and every execution region
- reserve and grow tables, operand and return stacks, frame segments, and
image-building output without relocating live code or globals
- rename i/o and string helpers consistently (puts -> put_s, putn -> put_n,
scat -> cat_s) across compiler, runtime, examples, tests, and docs
- recast and consume values assigned to globals from inside functions
- allow fixed and const together, add typed closure returns (fn:t(...)),
multi-include syntax (include rt, run, core;), and recurse type inference
- never infer string literals as word, anywhere, as argument, variable, or
return type
- draft docs/BORROW.md: a borrow checker less intrusive than Rust's but more
intelligent
LSP and editor integration
- require explicit includes and give every toolchain area its own namespace
(rt, lsp, run, core)
- hover for built-in types, inferred types, values known at hover time, array
and pointer lifetime/size, library names in include statements, and inferred
lifetimes with explanations
- honor /* */ comments as documentation for variables and arguments, and stop
misattributing section headers or trailing comments as variable hints
- stream diagnostics and cancel stale requests on change
- jump to definition and references, including cross-file
- quick fixes with automatic library import, and namespace completion
Hints and diagnostics
- render hints as blue squigglies by default, with hints on/small/off per file
- suppress magic-number hints via a preceding /* */ comment, and say so
- warn on unused arguments; allow multiple _ discards in parameters, pattern
matching, and tagged enums, warning if a _ is actually used
- rewrite hint and comment prose in professional compiler-doc register
Libraries
- add icon.zc: run-time self-modification, find/replace syntax, type and block
edits, and step-through inspection of locals and globals
- add actor.zc: async actors with Actor<I,O>, implicit this, spawn/recv/send,
injected into the compiler machinery at include time rather than built in
Tooling and docs
- reorganize sources, tests, and designs into subdirectories
- unify windows entry points in tinyvm.bat and add a matching tinyvm.sh
- add --help across the toolchain
- polish the learning guide, stdlib docs, and design notes
Tests
- add accept, reject, and regression coverage across the compiler, LSP,
- runtime, icon, actors, threads, formatting, and the toolchain contracts,
plus fuzzers and property tests
Diffstat (limited to 'tests/programs/sized.zc')
| -rw-r--r-- | tests/programs/sized.zc | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/tests/programs/sized.zc b/tests/programs/sized.zc index 0a18467..1be0b31 100644 --- a/tests/programs/sized.zc +++ b/tests/programs/sized.zc @@ -1,9 +1,12 @@ +namespace; +include rt, run; + // sized integers: scalars wrap to their size, arrays and pointers of them are packed -struct pix { u8 r, g, b, a; i16 dx; [4]u8 tag; }; +struct pix { u8 r, g, b, a; i16 dx; u8[4] tag; }; u8 gbyte = 300; i8 gneg = 200; u16 gword[5]; -[10]u8 gbuf; +u8[10] run.gbuf; u8 add8(u8 a, u8 b) { return a + b; } @@ -12,13 +15,13 @@ fn scalars() { i8 s = 100; i16 h = 32767; u32 w = 4294967295; - a = a + 10; put_n(a); put_c(' '); // 4 - s = s + 100; put_n(s); put_c(' '); // -56 - h++; put_n(h); put_c(' '); // -32768 - w++; put_n(w); put_c(' '); // 0 - put_n(gbyte); put_c(' '); put_n(gneg); put_c(' '); // 44 -56 - put_n(add8(200, 100)); put_c(' '); // 44 - put_n((i8)200); put_c(' '); put_n(300 as u8); put_c(10); // -56 44 + a = a + 10; rt.put_n(a); rt.put_c(' '); // 4 + s = s + 100; rt.put_n(s); rt.put_c(' '); // -56 + h++; rt.put_n(h); rt.put_c(' '); // -32768 + w++; rt.put_n(w); rt.put_c(' '); // 0 + rt.put_n(gbyte); rt.put_c(' '); rt.put_n(gneg); rt.put_c(' '); // 44 -56 + rt.put_n(add8(200, 100)); rt.put_c(' '); // 44 + rt.put_n((i8)200); rt.put_c(' '); rt.put_n(300 as u8); rt.put_c(10); // -56 44 return 0; } fn arrays() { @@ -29,36 +32,36 @@ fn arrays() { int i = 0, sum = 0; while (i < 20) { buf[i] = i * 20; i++; } // wraps past 255 i = 0; while (i < 20) { sum = sum + buf[i]; i++; } - put_n(sum); put_c(' '); // 1250 - sh[3] = 40000; put_n(sh[3]); put_c(' '); // -25536 - sh[3] += 30000; put_n(sh[3]); put_c(' '); // 4464 - ws[1] = 5000000000; put_n(ws[1]); put_c(' '); // 705032704 - sb[8] = 127; sb[8]++; put_n(sb[8]); put_c(' '); // -128 - sb[0] = 200; put_n(sb[0] < 0); put_c(' '); // 1: -56 is negative - ws[0] = 4000000000; put_n(ws[0] + ws[0]); put_c(' '); // arithmetic is done in int: 8000000000 - put_n(sizeof(buf)); put_c(' '); // 3 words - put_n(sizeof(sh)); put_c(10); // 2 words + rt.put_n(sum); rt.put_c(' '); // 1250 + sh[3] = 40000; rt.put_n(sh[3]); rt.put_c(' '); // -25536 + sh[3] += 30000; rt.put_n(sh[3]); rt.put_c(' '); // 4464 + ws[1] = 5000000000; rt.put_n(ws[1]); rt.put_c(' '); // 705032704 + sb[8] = 127; sb[8]++; rt.put_n(sb[8]); rt.put_c(' '); // -128 + sb[0] = 200; rt.put_n(sb[0] < 0); rt.put_c(' '); // 1: -56 is negative + ws[0] = 4000000000; rt.put_n(ws[0] + ws[0]); rt.put_c(' '); // arithmetic is done in int: 8000000000 + rt.put_n(sizeof(buf)); rt.put_c(' '); // 3 words + rt.put_n(sizeof(sh)); rt.put_c(10); // 2 words return 0; } fn heap() { - u8* p = new(u8, 1000); + u8* p = rt.new(u8, 1000); int i = 0, sum = 0; while (i < 1000) { p[i] = i; i++; } i = 0; while (i < 1000) { sum = sum + p[i]; i++; } - put_n(sum); put_c(' '); // 1000 bytes of 0..255: 3 * 32640 + 28 * ... = 127.. - put_n(osize(p) < 256); put_c(32); // 125 words plus the header, not 1000 - *p = 77; put_n(p[0]); put_c(' '); - free(d*p); - gbuf[9] = 255; gword[4] = 65535; gword[4]++; - put_n(gbuf[9]); put_c(' '); put_n(gword[4]); put_c(10); + rt.put_n(sum); rt.put_c(' '); // 1000 bytes of 0..255: 3 * 32640 + 28 * ... = 127.. + rt.put_n(rt.osize(p) < 256); rt.put_c(32); // 125 words plus the header, not 1000 + *p = 77; rt.put_n(p[0]); rt.put_c(' '); + rt.free(d*p); + run.gbuf[9] = 255; gword[4] = 65535; gword[4]++; + rt.put_n(run.gbuf[9]); rt.put_c(' '); rt.put_n(gword[4]); rt.put_c(10); return 0; } fn fields() { - pix* q = new(pix); + pix* q = rt.new(pix); q.r = 255; q.g = 256; q.dx = 65535; q.tag[2] = 7; q.tag[3] = 300; - put_n(q.r); put_c(' '); put_n(q.g); put_c(' '); put_n(q.dx); put_c(' '); - put_n(q.tag[2]); put_c(' '); put_n(q.tag[3]); put_c(' '); put_n(sizeof(pix)); put_c(10); - free(d*q); + rt.put_n(q.r); rt.put_c(' '); rt.put_n(q.g); rt.put_c(' '); rt.put_n(q.dx); rt.put_c(' '); + rt.put_n(q.tag[2]); rt.put_c(' '); rt.put_n(q.tag[3]); rt.put_c(' '); rt.put_n(sizeof(pix)); rt.put_c(10); + rt.free(d*q); return 0; } o3 fn checksum(u8* p, int n) { @@ -67,11 +70,11 @@ o3 fn checksum(u8* p, int n) { return b * 256 + a; } fn o3run() { - u8* p = new(u8, 5000); + u8* p = rt.new(u8, 5000); int i = 0; while (i < 5000) { p[i] = i * 7; i++; } - put_n(checksum(p, 5000)); put_c(10); - free(d*p); + rt.put_n(checksum(p, 5000)); rt.put_c(10); + rt.free(d*p); return 0; } fn main() { |
