MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / option

Function option

tests/all/component_model/func.rs:1992–2142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1990
1991#[test]
1992fn option() -> Result<()> {
1993 let component = format!(
1994 r#"(component
1995 (core module $m
1996 (memory (export "memory") 1)
1997 (func (export "pass1") (param i32 i32) (result i32)
1998 (local $base i32)
1999 (local.set $base
2000 (call $realloc
2001 (i32.const 0)
2002 (i32.const 0)
2003 (i32.const 4)
2004 (i32.const 8)))
2005
2006 (i32.store offset=0
2007 (local.get $base)
2008 (local.get 0))
2009 (i32.store offset=4
2010 (local.get $base)
2011 (local.get 1))
2012
2013 (local.get $base)
2014 )
2015 (func (export "pass2") (param i32 i32 i32) (result i32)
2016 (local $base i32)
2017 (local.set $base
2018 (call $realloc
2019 (i32.const 0)
2020 (i32.const 0)
2021 (i32.const 4)
2022 (i32.const 12)))
2023
2024 (i32.store offset=0
2025 (local.get $base)
2026 (local.get 0))
2027 (i32.store offset=4
2028 (local.get $base)
2029 (local.get 1))
2030 (i32.store offset=8
2031 (local.get $base)
2032 (local.get 2))
2033
2034 (local.get $base)
2035 )
2036
2037 {REALLOC_AND_FREE}
2038 )
2039 (core instance $i (instantiate $m))
2040
2041 (func (export "option-u8-to-tuple") (param "a" (option u8)) (result (tuple u32 u32))
2042 (canon lift (core func $i "pass1") (memory $i "memory"))
2043 )
2044 (func (export "option-u32-to-tuple") (param "a" (option u32)) (result (tuple u32 u32))
2045 (canon lift (core func $i "pass1") (memory $i "memory"))
2046 )
2047 (func (export "option-string-to-tuple") (param "a" (option string)) (result (tuple u32 string))
2048 (canon lift
2049 (core func $i "pass2")

Callers 2

lowerMethod · 0.85
storeMethod · 0.85

Calls 5

OkFunction · 0.85
engineFunction · 0.50
newFunction · 0.50
instantiateMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected