writeonce/compiler/test/golden/bc/elision.expected
shoney.arickathil ebf82ca9c0 feat: json encode/decode + as, .wob v2 class metadata — log-watcher compiles
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>
2026-08-14 17:08:46 +02:00

52 lines
1.2 KiB
Text

== CONSTANTS ==
k0 TEXT "Cache"
k1 TEXT "Holder"
k2 TEXT "hits"
k3 TEXT "cache"
k4 TEXT "read"
k5 TEXT "proven"
k6 TEXT "main"
k7 INT 41
k8 INT 1
== CLASSES ==
c0 Cache flags=gc fields=[hits:SCALAR]
c1 Holder flags=- fields=[cache:GCREF]
== INTERFACES ==
== VTABLES ==
== METHODS ==
m0 read args=1 regs=2 [free fn]
lines: 0->20
drops: (none)
0000 GETF r1, r0, f0
0001 RET r1
m1 proven args=1 regs=3 [free fn]
lines: 0->24 1->25
drops: pc 1 owned={} gc={r1}
0000 GETF r1, r0, f0
0001 MOVE r2, r1
0002 CALL r2, m0
0003 RET r2
m2 main args=0 regs=6 [free fn] [ENTRY]
lines: 0->29 3->30 7->31 13->28
drops: pc 3 owned={} gc={r0}
drops: pc 7 owned={r1} gc={r0}
drops: pc 14 owned={} gc={r0}
drops: pc 15 owned={} gc={}
0000 NEW r0, c0
0001 LOADK r1, k7
0002 SETF r0, f0, r1
0003 NEW r1, c1
0004 MOVE r2, r0
0005 RC_INC r2
0006 SETF r1, f0, r2
0007 MOVE r4, r1
0008 CALL r4, m1
0009 MOVE r3, r4
0010 LOADK r5, k8
0011 ADD r2, r3, r5
0012 BUILTIN r2, r2, print_int
0013 DROP r1
0014 RC_DEC r0
0015 RET0
== ENTRY ==
m2