Commit 48014e9e
48014e9ed8ddMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 3 files · +1 added · ~2 modified
Description
feat: sp_RbHash — heterogeneous hash (string key -> sp_RbValue)
Add SPINEL_TYPE_RB_HASH for hash literals with mixed-type values (e.g., {name: "Alice", age: 30, active: true}). Existing sp_StrIntHash for homogeneous string->integer hashes remains unchanged.
Runtime: sp_RbHash with insertion-ordered linked list, hash-table lookup, new/set/get/length methods. Codegen detects heterogeneous values in PM_HASH_NODE and emits sp_RbHash instead of sp_StrIntHash. Supports h[:key] (returns sp_RbValue), h.length, and h.each |k, v| with k as string and v as sp_RbValue (POLY).
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 48014e9ed8dd
- Parent
- bb6f4a1ca326
examples/bm_poly_hash.rbaddedView file
# Test heterogeneous Hashh = {name: "Alice", age: 30, active: true}puts h[:name] # Aliceputs h[:age] # 30puts h[:active] # trueputs h.length # 3# Iterationh.each do |k, v| puts kend# name, age, activeputs "done"src/codegen.cmodifiedView file
Loading diff…
src/codegen.hmodifiedView file
Loading diff…