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>
70 lines
1.7 KiB
Text
70 lines
1.7 KiB
Text
== CONSTANTS ==
|
|
k0 TEXT "Book"
|
|
k1 TEXT "Toy"
|
|
k2 TEXT "base"
|
|
k3 TEXT "Priced"
|
|
k4 TEXT "current_price"
|
|
k5 TEXT "quote"
|
|
k6 TEXT "main"
|
|
k7 INT 2
|
|
k8 INT 3
|
|
k9 INT 10
|
|
k10 INT 5
|
|
== CLASSES ==
|
|
c0 Book flags=- fields=[base:SCALAR]
|
|
c1 Toy flags=- fields=[base:SCALAR]
|
|
== INTERFACES ==
|
|
i0 Priced methods=1 slots=s0..s0
|
|
== VTABLES ==
|
|
c0 i0 slots s0.. -> [m0]
|
|
c1 i0 slots s0.. -> [m1]
|
|
== METHODS ==
|
|
m0 current_price args=1 regs=3 [class c0]
|
|
lines: 0->15
|
|
drops: (none)
|
|
0000 GETF r1, r0, f0
|
|
0001 LOADK r2, k7
|
|
0002 ADD r1, r1, r2
|
|
0003 RET r1
|
|
m1 current_price args=1 regs=3 [class c1]
|
|
lines: 0->23
|
|
drops: (none)
|
|
0000 GETF r1, r0, f0
|
|
0001 LOADK r2, k8
|
|
0002 MUL r1, r1, r2
|
|
0003 RET r1
|
|
m2 quote args=1 regs=2 [free fn]
|
|
lines: 0->28
|
|
drops: (none)
|
|
0000 MOVE r1, r0
|
|
0001 ICALL r1, s0
|
|
0002 RET r1
|
|
m3 main args=0 regs=4 [free fn] [ENTRY]
|
|
lines: 0->32 3->33 6->34 10->35 14->36 18->31
|
|
drops: pc 3 owned={r0} gc={}
|
|
drops: pc 6 owned={r0,r1} gc={}
|
|
drops: pc 19 owned={r0} gc={}
|
|
drops: pc 20 owned={} gc={}
|
|
0000 NEW r0, c0
|
|
0001 LOADK r1, k9
|
|
0002 SETF r0, f0, r1
|
|
0003 NEW r1, c1
|
|
0004 LOADK r2, k10
|
|
0005 SETF r1, f0, r2
|
|
0006 MOVE r3, r0
|
|
0007 CALL r3, m2
|
|
0008 MOVE r2, r3
|
|
0009 BUILTIN r2, r2, print_int
|
|
0010 MOVE r3, r1
|
|
0011 CALL r3, m2
|
|
0012 MOVE r2, r3
|
|
0013 BUILTIN r2, r2, print_int
|
|
0014 MOVE r3, r0
|
|
0015 CALL r3, m0
|
|
0016 MOVE r2, r3
|
|
0017 BUILTIN r2, r2, print_int
|
|
0018 DROP r1
|
|
0019 DROP r0
|
|
0020 RET0
|
|
== ENTRY ==
|
|
m3
|