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>
66 lines
1.6 KiB
Text
66 lines
1.6 KiB
Text
== CONSTANTS ==
|
|
k0 TEXT "Item"
|
|
k1 TEXT "n"
|
|
k2 TEXT "consume"
|
|
k3 TEXT "twice"
|
|
k4 TEXT "main"
|
|
k5 INT 2
|
|
k6 INT 3
|
|
k7 INT 5
|
|
k8 INT 0
|
|
== CLASSES ==
|
|
c0 Item flags=- fields=[n:SCALAR]
|
|
== INTERFACES ==
|
|
== VTABLES ==
|
|
== METHODS ==
|
|
m0 consume args=1 regs=2 [free fn]
|
|
lines: 0->11
|
|
drops: pc 0 owned={r0} gc={}
|
|
drops: pc 2 owned={} gc={}
|
|
0000 GETF r1, r0, f0
|
|
0001 DROP r0
|
|
0002 RET r1
|
|
m1 twice args=2 regs=6 [free fn]
|
|
lines: 0->15 3->16 5->17 8->18 13->20
|
|
drops: pc 0 owned={r0} gc={}
|
|
drops: pc 3 owned={r0,r2} gc={}
|
|
drops: pc 8 owned={r0,r2,r3} gc={}
|
|
drops: pc 10 owned={r0,r2} gc={}
|
|
drops: pc 11 owned={r0} gc={}
|
|
drops: pc 12 owned={} gc={}
|
|
drops: pc 13 owned={r0,r2} gc={}
|
|
drops: pc 14 owned={r2} gc={}
|
|
drops: pc 19 owned={} gc={}
|
|
0000 NEW r2, c0
|
|
0001 LOADK r3, k5
|
|
0002 SETF r2, f0, r3
|
|
0003 MOVE r3, r1
|
|
0004 JZ r3, -> 0013
|
|
0005 NEW r3, c0
|
|
0006 LOADK r4, k6
|
|
0007 SETF r3, f0, r4
|
|
0008 GETF r4, r3, f0
|
|
0009 DROP r3
|
|
0010 DROP r2
|
|
0011 DROP r0
|
|
0012 RET r4
|
|
0013 MOVE r4, r0
|
|
0014 CALL r4, m0
|
|
0015 MOVE r3, r4
|
|
0016 GETF r5, r2, f0
|
|
0017 ADD r3, r3, r5
|
|
0018 DROP r2
|
|
0019 RET r3
|
|
m2 main args=0 regs=4 [free fn] [ENTRY]
|
|
lines: 0->24 7->23
|
|
drops: (none)
|
|
0000 NEW r1, c0
|
|
0001 LOADK r3, k7
|
|
0002 SETF r1, f0, r3
|
|
0003 LOADK r2, k8
|
|
0004 CALL r1, m1
|
|
0005 MOVE r0, r1
|
|
0006 BUILTIN r0, r0, print_int
|
|
0007 RET0
|
|
== ENTRY ==
|
|
m2
|