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

1+# Test heterogeneous Hash
2+
3+h = {name: "Alice", age: 30, active: true}
4+puts h[:name] # Alice
5+puts h[:age] # 30
6+puts h[:active] # true
7+puts h.length # 3
8+
9+# Iteration
10+h.each do |k, v|
11+ puts k
12+end
13+# name, age, active
14+
15+puts "done"