// Licensing scope: see ../../LICENSE and this directory's LICENSE and NOTICE.
// Potentially incorporated Binaryen expression retains Apache-2.0 terms.
// Original Starshine contributions use the scoped MIT grant in ../../LICENSE.
// Modified for Starshine through 2026: implementation and validation use
// Starshine's representations and APIs; this is not an unchanged upstream file.
// Conservative notice retention does not establish copying or independence.
///|
// The interner never removes keys. Numeric defaults therefore retain their
// first interned identity throughout this one analysis, including explicit
// zero writes. Preserve the original key and ID assignment on the first query.
fn cl_default_identity(
interner : CLValueInterner,
ty : @lib.ValType,
formats~ : Array[Int32]? = None,
) -> Int32 {
let slot = if ty == @lib.ValType::i32() {
0
} else if ty == @lib.ValType::i64() {
1
} else if ty == @lib.ValType::f32() {
2
} else if ty == @lib.ValType::f64() {
3
} else if ty == @lib.ValType::v128() {
4
} else {
-1
}
let cache = if slot < 0 {
None
} else {
match interner.numeric_defaults {
Some(cache) => Some(cache)
None => {
let cache = Array::make(5, -1)
interner.numeric_defaults = Some(cache)
Some(cache)
}
}
}
if cache is Some(values) && values[slot] >= 0 {
return values[slot]
}
match formats {
Some(count) => count[0] += 1
None => ()
}
let value = interner.intern("default:\{@debug.to_string(ty)}")
match cache {
Some(values) => values[slot] = value
None => ()
}
value
}