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

Method default_value

crates/wasmtime/src/runtime/types.rs:375–390  ·  view source on GitHub ↗

Construct a default value. Returns None for non-nullable Ref types, which have no default.

(&self)

Source from the content-addressed store, hash-verified

373 }
374 /// Construct a default value. Returns None for non-nullable Ref types, which have no default.
375 pub fn default_value(&self) -> Option<Val> {
376 match self {
377 ValType::I32 => Some(Val::I32(0)),
378 ValType::I64 => Some(Val::I64(0)),
379 ValType::F32 => Some(Val::F32(0)),
380 ValType::F64 => Some(Val::F64(0)),
381 ValType::V128 => Some(Val::V128(0.into())),
382 ValType::Ref(r) => {
383 if r.is_nullable() {
384 Some(Val::null_ref(r.heap_type()))
385 } else {
386 None
387 }
388 }
389 }
390 }
391
392 pub(crate) fn into_registered_type(self) -> Option<RegisteredType> {
393 match self {

Callers 9

serializeMethod · 0.45
call_asyncFunction · 0.45
dummy_linkerFunction · 0.45
dummy_table_importFunction · 0.45
dummy_global_importFunction · 0.45
dummy_memory_importFunction · 0.45
dummy_function_importFunction · 0.45
make_api_callsFunction · 0.45

Calls 15

OkFunction · 0.85
is_nullableMethod · 0.80
heap_typeMethod · 0.80
ref_Method · 0.80
V128Class · 0.70
SharedMemoryClass · 0.70
MemoryClass · 0.70
newFunction · 0.50
try_newFunction · 0.50
mapMethod · 0.45
resultsMethod · 0.45
pushMethod · 0.45

Tested by 4

dummy_table_importFunction · 0.36
dummy_global_importFunction · 0.36
dummy_memory_importFunction · 0.36
dummy_function_importFunction · 0.36