sx: step 6 — JS AdtValue + define-type + match
Mirror of OCaml Step 5 to the JavaScript host. Native ADT representation for define-type instances, with the same dict-shaped shim approach so spec-level match-pattern code in evaluator.sx works without changes. - platform.py typeOf: recognize ._adtv tag, return ._type (so (type-of (Just 42)) returns "Maybe" not "dict"). - platform.py adds makeAdtValue/isAdtValue helpers and registers PRIMITIVES["adt?"], "make-adt-value", "adt-value?". - platform.py inspect: format AdtValue as "(Ctor f1 f2 ...)" and register as a primitive (was missing entirely on JS). - fixups_js: hand-written define-type override that constructs AdtValue via makeAdtValue, with arity check, type/ctor predicates, and field accessors. Re-registered via registerSpecialForm so the CEK dispatch routes through it. - dict? unchanged: AdtValue still passes (no _adtv exclusion) so the existing (and (dict? v) (get v :_adt) ...) checks in spec predicates keep working. Tests: 2578 pass (was 2575), zero regressions. All 43 ADT tests pass on the JS host (was 40, the 3 new Step 5 tests for type-of / adt? / inspect are now green). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user