From 1c53304d03414890af0da7432d1aea87e754a14a Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Wed, 14 Oct 2026 08:29:46 +0330 Subject: 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, 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 --- tests/programs/types.zc | 51 ++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'tests/programs/types.zc') diff --git a/tests/programs/types.zc b/tests/programs/types.zc index 86488db..5eaa964 100644 --- a/tests/programs/types.zc +++ b/tests/programs/types.zc @@ -1,3 +1,6 @@ +namespace; +include rt, run; + struct point { int x, y; }; struct rect { point a, b; int tag; }; struct list { int len; T* items; }; @@ -5,14 +8,14 @@ struct node { int v; node* next; }; type num = int; int counter = 5; -[4]int squares; +int[4] squares; point origin; int area(rect* r) { return (r.b.x - r.a.x) * (r.b.y - r.a.y); } list*.u mklist(int cap) { - list* l = new(list); + list* l = rt.new(list); l.len = 0; - l.items = new(T, cap) as T*; + l.items = rt.new(T, cap) as T*; return u*l; } T first(list* l) { return l.items[0]; } @@ -21,35 +24,35 @@ int sum(node* n) { int s = 0; while (n) { s += n.v; n = n.next; } return s; } fn main() { rect r; r.a.x = 1; r.a.y = 2; r.b.x = 4; r.b.y = 6; - put_n(area(&r)); put_c(' '); - put_n(sizeof(rect)); put_c(' '); put_n(sizeof(point)); put_c(' '); put_n(sizeof([3]rect)); put_c(' '); - let p = new(point); // let infers *point + rt.put_n(area(&r)); rt.put_c(' '); + rt.put_n(sizeof(rect)); rt.put_c(' '); rt.put_n(sizeof(point)); rt.put_c(' '); rt.put_n(sizeof(rect[3])); rt.put_c(' '); + let p = rt.new(point); // let infers *point p.x = 7; p->y = 8; - put_n(p.x * p.y); put_c(' '); - free(d*p); + rt.put_n(p.x * p.y); rt.put_c(' '); + rt.free(d*p); list* l = mklist(4); l.items[0] = 42; l.len = 1; - put_n(first(l)); put_c(' '); - free(d*l); - node* a = new(node), b = new(node); + rt.put_n(first(l)); rt.put_c(' '); + rt.free(d*l); + node* a = rt.new(node), b = rt.new(node); a.v = 3; b.v = 4; a.next = b; - put_n(sum(a)); put_c(' '); - free(d*a); // b went with it: a.next = b made a its owner - [3]point pts; + rt.put_n(sum(a)); rt.put_c(' '); + rt.free(d*a); // b went with it: a.next = b made a its owner + point[3] pts; pts[2].y = 9; - put_n(pts[2].y + counter); put_c(' '); + rt.put_n(pts[2].y + counter); rt.put_c(' '); num k = 3; - put_n(k); put_c(10); + rt.put_n(k); rt.put_c(10); // reflection - tprint(typeof(r)); put_c(' '); tprint(typeof(&r)); put_c(' '); tprint(typeof(l)); put_c(' '); - tprint(sigof(mklist)); put_c(' '); tprint(sigof(first)); put_c(' '); tprint(sigofs("free")); put_c(10); + run.tprint(typeof(r)); rt.put_c(' '); run.tprint(typeof(&r)); rt.put_c(' '); run.tprint(typeof(l)); rt.put_c(' '); + run.tprint(run.sigof(mklist)); rt.put_c(' '); run.tprint(run.sigof(first)); rt.put_c(' '); run.tprint(run.sigofs("free")); rt.put_c(10); let t = typeof(r), i = 0; - while (i < tnfields(t)) { put_s(tfname(t, i)); put_c(':'); tprint(tftype(t, i)); put_c('@'); put_n(tfoff(t, i)); put_c(' '); i++; } - put_c(10); - point* q = new(point); - tprint(typeof_obj(q)); put_c(' '); put_n(typeof_obj(q) == typeof(point)); put_c(' '); put_n(tkind(typeof_obj(q)) == TY_STRUCT); - free(d*q); - put_c(10); + while (i < run.tnfields(t)) { rt.put_s(run.tfname(t, i)); rt.put_c(':'); run.tprint(run.tftype(t, i)); rt.put_c('@'); rt.put_n(run.tfoff(t, i)); rt.put_c(' '); i++; } + rt.put_c(10); + point* q = rt.new(point); + run.tprint(rt.typeof_obj(q)); rt.put_c(' '); rt.put_n(rt.typeof_obj(q) == typeof(point)); rt.put_c(' '); rt.put_n(run.tkind(rt.typeof_obj(q)) == run.TY_STRUCT); + rt.free(d*q); + rt.put_c(10); return 0; } -- cgit v1.2.3