MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / eval_size_const

Method eval_size_const

crates/tinywasm/src/store/mod.rs:525–537  ·  view source on GitHub ↗

Evaluate a constant expression that's either a i32 or a i64 as a global or a const instruction

(
        &self,
        const_instrs: &[tinywasm_types::ConstInstruction],
        module_global_addrs: &[Addr],
        module_func_addrs: &[FuncAddr],
    )

Source from the content-addressed store, hash-verified

523
524 /// Evaluate a constant expression that's either a i32 or a i64 as a global or a const instruction
525 fn eval_size_const(
526 &self,
527 const_instrs: &[tinywasm_types::ConstInstruction],
528 module_global_addrs: &[Addr],
529 module_func_addrs: &[FuncAddr],
530 ) -> Result<i64> {
531 let value = self.eval_const(const_instrs, module_global_addrs, module_func_addrs)?;
532 match value {
533 TinyWasmValue::Value32(i) => Ok(i64::from(i)),
534 TinyWasmValue::Value64(i) => Ok(i as i64),
535 other => Err(Error::Other(format!("expected i32 or i64, got {other:?}"))),
536 }
537 }
538
539 /// Evaluate a constant expression
540 fn eval_const(

Callers 2

init_elementsMethod · 0.80
init_dataMethod · 0.80

Calls 1

eval_constMethod · 0.80

Tested by

no test coverage detected