Wasmtime: C++
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
wasmtime::Val Class Reference

Representation of a generic WebAssembly value. More...

#include <wasmtime.hh>

Public Member Functions

 Val (int32_t i32)
 Creates a new i32 WebAssembly value.
 
 Val (int64_t i64)
 Creates a new i64 WebAssembly value.
 
 Val (float f32)
 Creates a new f32 WebAssembly value.
 
 Val (double f64)
 Creates a new f64 WebAssembly value.
 
 Val (const V128 &v128)
 Creates a new v128 WebAssembly value.
 
 Val (std::optional< Func > func)
 Creates a new funcref WebAssembly value.
 
 Val (Func func)
 Creates a new funcref WebAssembly value which is not ref.null func.
 
 Val (std::optional< ExternRef > ptr)
 Creates a new externref value.
 
 Val (ExternRef ptr)
 
ValKind kind () const
 Returns the kind of value that this value has.
 
int32_t i32 () const
 
int64_t i64 () const
 
float f32 () const
 
double f64 () const
 
V128 v128 () const
 
std::optional< ExternRefexternref (Store::Context cx) const
 
std::optional< Funcfuncref () const
 
void unroot (Store::Context cx)
 Unroots any GC references this Val points to within the cx provided.
 

Detailed Description

Representation of a generic WebAssembly value.

This is roughly equivalent to a tagged union of all possible WebAssembly values. This is later used as an argument with functions, globals, tables, etc.

Note that a Val can represent owned GC pointers. In this case the unroot method must be used to ensure that they can later be garbage-collected.

Constructor & Destructor Documentation

◆ Val()

wasmtime::Val::Val ( ExternRef  ptr)
inline

Creates a new externref WebAssembly value which is not ref.null extern.

Member Function Documentation

◆ externref()

std::optional< ExternRef > wasmtime::Val::externref ( Store::Context  cx) const
inline

Returns the underlying externref, requires kind() == KindExternRef or aborts the process.

Note that externref is a nullable reference, hence the optional return value.

Examples
externref.cc.

◆ f32()

float wasmtime::Val::f32 ( ) const
inline

Returns the underlying f32, requires kind() == KindF32 or aborts the process.

◆ f64()

double wasmtime::Val::f64 ( ) const
inline

Returns the underlying f64, requires kind() == KindF64 or aborts the process.

◆ funcref()

std::optional< Func > wasmtime::Val::funcref ( ) const
inline

Returns the underlying funcref, requires kind() == KindFuncRef or aborts the process.

Note that funcref is a nullable reference, hence the optional return value.

◆ i32()

int32_t wasmtime::Val::i32 ( ) const
inline

Returns the underlying i32, requires kind() == KindI32 or aborts the process.

◆ i64()

int64_t wasmtime::Val::i64 ( ) const
inline

Returns the underlying i64, requires kind() == KindI64 or aborts the process.

◆ v128()

V128 wasmtime::Val::v128 ( ) const
inline

Returns the underlying v128, requires kind() == KindV128 or aborts the process.


The documentation for this class was generated from the following file: