Wasmtime
extern.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_TYPES_EXTERN_HH
6#define WASMTIME_TYPES_EXTERN_HH
7
8#include <variant>
9#include <wasm.h>
16
17namespace wasmtime {
18
23 friend class ExportType;
24 friend class ImportType;
25
26public:
33 typedef std::variant<FuncType::Ref, GlobalType::Ref, TableType::Ref,
36
39 // TODO: this would ideally be some sort of implicit constructor, unsure how
40 // to do that though...
41 return ref_from_c(ty.raw_type());
42 }
43
46 // TODO: this would ideally be some sort of implicit constructor, unsure how
47 // to do that though...
48 return ref_from_c(ty.raw_type());
49 }
50
51private:
52 static Ref ref_from_c(const wasm_externtype_t *ptr) {
53 switch (wasm_externtype_kind(ptr)) {
54 case WASM_EXTERN_FUNC:
56 case WASM_EXTERN_GLOBAL:
58 case WASM_EXTERN_TABLE:
60 case WASM_EXTERN_MEMORY:
62 }
63 std::abort();
64 }
65};
66
67}; // namespace wasmtime
68
69#endif // WASMTIME_TYPES_EXTERN_HH
Non-owning reference to an ExportType.
Definition: export.hh:22
Type information about a WebAssembly export.
Definition: export.hh:16
Generic type of a WebAssembly item.
Definition: extern.hh:22
static Ref from_import(ImportType::Ref ty)
Extract the type of the item imported by the provided type.
Definition: extern.hh:38
std::variant< FuncType::Ref, GlobalType::Ref, TableType::Ref, MemoryType::Ref > Ref
Non-owning reference to an item's type.
Definition: extern.hh:35
static Ref from_export(ExportType::Ref ty)
Extract the type of the item exported by the provided type.
Definition: extern.hh:45
Definition: func.hh:28
Definition: global.hh:27
Definition: import.hh:20
Type information about a WebAssembly import.
Definition: import.hh:16
Non-owning reference to a MemoryType, must not be used after the original owner has been deleted.
Definition: memory.hh:30
Definition: table.hh:28
An opaque object representing the type of a external value. Can be seen as a superclass of wasm_funct...
const wasm_functype_t * wasm_externtype_as_functype_const(const wasm_externtype_t *)
Attempts to convert a wasm_externtype_t to a wasm_functype_t.
const wasm_globaltype_t * wasm_externtype_as_globaltype_const(const wasm_externtype_t *)
Attempts to convert a wasm_externtype_t to a wasm_globaltype_t.
const wasm_tabletype_t * wasm_externtype_as_tabletype_const(const wasm_externtype_t *)
Attempts to convert a wasm_externtype_t to a wasm_tabletype_t.
wasm_externkind_t wasm_externtype_kind(const wasm_externtype_t *)
Returns the kind of external item this type represents.
const wasm_memorytype_t * wasm_externtype_as_memorytype_const(const wasm_externtype_t *)
Attempts to convert a wasm_externtype_t to a wasm_memorytype_t.