docs/examples/log-watcher (1285 lines, 7 files) now compiles clean: 0 diagnostics, a 35KB .wob written. corpus 71/0, woc runtest 565/0, every wovm unit gate green (both dispatch flavors). - .wob v2: each class row gains three u32 per-field arrays — the field's NAME constant, the CLASS it refers to (or the json-raw marker), and a container field's ELEMENT kinds. json is then a runtime service driven by metadata instead of per-type generated code. loader/emitter/disassembler/test assembler all read and write v2; field-name constants are interned with the rest of the pool (interning during serialization silently loses them) - runtime/src/json.c (new): encode by static kind + object headers + class table (nested records need no static knowledge); decode parses and BINDS straight into the target class — keys matched to field names, nested objects built as the field's class, arrays as a multi of the field's element kind, unknown keys skipped, absent keys nil. Malformed input is nil, never a trap - `as`: `json.decode(text) as T` is the one cast this language has (WO-E403 for any other `as`, and for a bare json.decode with no target type). Its result is `?T`, which is why the decode and the target are one instruction - json.Value: a reserved type name for a value the source does not inspect — the raw JSON slice, kind TEXT, re-emitted verbatim by encode - docs: 00-wob-format.md is now the v2 reference (class metadata, TRY/ENDTRY, the whole builtin surface, WO_T_IO); 08-builtin-surface.md documents the text/container builtins, the OS modules with their predeclared records, and json's two documented limits (Bool encodes 0/1, floats truncate) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
20 lines
886 B
C
20 lines
886 B
C
/* builtin.h — runtime services bytecode can't express (spec §3/§5):
|
|
* now/print/print_int/words plus the container bridge to cont.c. One
|
|
* dispatcher: takes the VM, the current frame's registers, and the
|
|
* instruction; 0 = ok, else a WO_T_* trap code with *msg set. */
|
|
#ifndef WO_BUILTIN_H
|
|
#define WO_BUILTIN_H
|
|
|
|
#include "vm.h"
|
|
|
|
int wo_builtin(wo_vm *vm, uint64_t *R, uint32_t ins, const char **msg);
|
|
|
|
/* The systems stdlib's OS half (runtime/src/sysio.c): same contract as
|
|
* wo_builtin above — 0 on success, a WO_T_* code with *msg set on failure.
|
|
* wo_builtin dispatches every id at or above WO_B_SYS_FIRST here. */
|
|
int wo_builtin_sys(wo_vm *vm, uint64_t *R, uint32_t ins, const char **msg);
|
|
|
|
/* json.encode / json.decode (runtime/src/json.c), same contract again. */
|
|
int wo_builtin_json(wo_vm *vm, uint64_t *R, uint32_t ins, const char **msg);
|
|
|
|
#endif /* WO_BUILTIN_H */
|