nyar_wasm/wasi_values/record/
mod.rs

1use super::*;
2use crate::WasiRecordType;
3use indexmap::IndexMap;
4use std::sync::Arc;
5
6/// A [record]() value in WASI.
7pub struct RecordValue {
8    /// The type info of the record
9    pub r#type: WasiRecordType,
10    /// The override values of the record
11    pub values: IndexMap<Arc<str>, WasiValue>,
12}
13
14impl EmitConstant for RecordValue {
15    fn emit_constant<W: Write>(&self, w: &mut WastEncoder<W>) -> std::fmt::Result {
16        write!(w, "struct.new_default {}", self.r#type.symbol)?;
17        // local.set ...
18        w.stack.push(WasiType::Record(self.r#type.clone()));
19
20        // struct.set ...
21
22        Ok(())
23    }
24}