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/drivers/analysis_cache_test.js | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/drivers/analysis_cache_test.js (limited to 'tests/drivers/analysis_cache_test.js') diff --git a/tests/drivers/analysis_cache_test.js b/tests/drivers/analysis_cache_test.js new file mode 100644 index 0000000..3ffde33 --- /dev/null +++ b/tests/drivers/analysis_cache_test.js @@ -0,0 +1,45 @@ +// Repeated replies use cached results; edits, include updates and reopen invalidate them. +const assert = require('assert'), cp = require('child_process'), path = require('path'); +const uri = 'file:///cache/main.zc', text = 'include "dep.zc";\nfn main() { int n = 7; return n + value(); }'; +const msgs = []; let id = 1; +const request = (method, params = {}) => { const rid = id++; msgs.push({ id: rid, method, params }); return rid; }; +const note = (method, params) => msgs.push({ method, params }); +const stats = () => request('zc/cacheStats'); +const hover = () => request('textDocument/hover', { textDocument: { uri }, position: { line: 1, character: 30 } }); +request('initialize'); note('zc/file', { path: '/cache/dep.zc', text: 'int value() { return 1; }' }); +note('textDocument/didOpen', { textDocument: { uri, version: 1, text } }); +const a = hover(), before = stats(), b = hover(), after = stats(); +const methods = ['textDocument/semanticTokens/full', 'textDocument/definition', 'textDocument/references', 'textDocument/completion']; +const pairs = methods.map(method => [request(method, { textDocument: { uri }, position: { line: 1, character: 30 } }), request(method, { textDocument: { uri }, position: { line: 1, character: 30 } })]); +const all = stats(); +note('textDocument/didChange', { textDocument: { uri, version: 2 }, contentChanges: [{ text: text.replace('= 7', '= 9') }] }); +const changed = hover(), editStats = stats(); +note('zc/file', { path: '/cache/dep.zc', text: 'int value() { return 2; }' }); +hover(); const includeStats = stats(); +note('textDocument/didClose', { textDocument: { uri } }); +note('textDocument/didOpen', { textDocument: { uri, version: 1, text } }); +const reopened = hover(), reopenStats = stats(); note('exit', {}); +const frame = m => { const b = Buffer.from(JSON.stringify({ jsonrpc: '2.0', ...m })); return Buffer.concat([Buffer.from(`Content-Length: ${b.length}\r\n\r\n`), b]); }; +let out; +if (process.argv[2] === '--wasm' || process.argv[2] === '--vm') { + const wasm = process.argv[2] === '--wasm', host = require(path.resolve('editors/vscode/client', wasm ? 'wasmproc.js' : 'vmproc.js')); + const p = (wasm ? host.wasmProcess : host.vmProcess)(path.resolve(process.argv[3]), { log: () => {} }); + const chunks = []; p.stdout.on('data', d => chunks.push(d)); msgs.forEach(m => p.stdin.write(frame(m))); out = Buffer.concat(chunks); +} else { + const r = cp.spawnSync(process.argv[2], process.argv.slice(3), { input: Buffer.concat(msgs.map(frame)), timeout: 60000, maxBuffer: 16 << 20 }); + assert.strictEqual(r.status, 0, String(r.stderr)); out = r.stdout; +} +const replies = new Map(); +while (out.length) { const e = out.indexOf('\r\n\r\n'), n = Number(/Content-Length:\s*(\d+)/i.exec(out.subarray(0, e).toString())[1]); const m = JSON.parse(out.subarray(e + 4, e + 4 + n)); replies.set(m.id, m.result); out = out.subarray(e + 4 + n); } +assert.deepStrictEqual(replies.get(a), replies.get(b)); +assert.ok(replies.get(a)?.contents.value.includes('7'), 'first hover has value'); +assert.strictEqual(replies.get(after).hits, replies.get(before).hits + 1); +assert.strictEqual(replies.get(after).checks, replies.get(before).checks); +pairs.forEach(([x, y]) => assert.deepStrictEqual(replies.get(x), replies.get(y))); +assert.strictEqual(replies.get(all).hits, replies.get(after).hits + methods.length); +assert.ok(replies.get(changed)?.contents.value.includes('9'), 'edit invalidates value'); +assert.strictEqual(replies.get(editStats).misses, replies.get(all).misses + 1); +assert.strictEqual(replies.get(includeStats).misses, replies.get(editStats).misses + 1); +assert.ok(replies.get(reopened)?.contents.value.includes('7'), 'reopen invalidates value'); +assert.strictEqual(replies.get(reopenStats).misses, replies.get(includeStats).misses + 1); +console.log('ok analysis cache reuses all request types and invalidates on edits, includes and reopen'); -- cgit v1.2.3