fromWasmKind static method

WasmValueKind fromWasmKind(
  1. int kind
)

Decodes a WASM_* / wasm_valkind_t discriminant.

The numbers are the values of wasm_valkind_t in wasm.h; they cannot be written as switch patterns from the generated enum because Dart requires patterns to be compile time constants and enum fields are not.

Implementation

static WasmValueKind fromWasmKind(int kind) => switch (kind) {
  0 => i32, // WASM_I32
  1 => i64, // WASM_I64
  2 => f32, // WASM_F32
  3 => f64, // WASM_F64
  4 => v128, // wasmtime's extension
  128 => externRef, // WASM_EXTERNREF
  129 => funcRef, // WASM_FUNCREF
  _ => throw UnsupportedError('Unknown wasm value kind $kind'),
};