github.com/moontrade/wavm-go@v0.3.2-0.20220316110326-d229dd66ad65/val_type.go (about) 1 package wavm 2 3 // #include <stdlib.h> 4 // #include "wavm-c.h" 5 import "C" 6 7 type ValType C.wasm_valtype_t 8 9 func NewValType(kind ValKind) *ValType { 10 return (*ValType)(C.wasm_valtype_new((C.wasm_valkind_t)(kind))) 11 } 12 13 func (v *ValType) Delete() { 14 C.wasm_valtype_delete((*C.wasm_valtype_t)(v)) 15 } 16 17 func (v *ValType) Kind() ValKind { 18 return ValKind(C.wasm_valtype_kind((*C.wasm_valtype_t)(v))) 19 } 20 21 func (t *ValType) IsNum() bool { 22 return t.Kind().IsNum() 23 } 24 25 func (t *ValType) IsRef() bool { 26 return t.Kind().IsRef() 27 } 28 29 func ValTypeI32() *ValType { 30 return NewValType(I32) 31 } 32 33 func ValTypeI64() *ValType { 34 return NewValType(I64) 35 } 36 37 func ValTypeF32() *ValType { 38 return NewValType(F32) 39 } 40 41 func ValTypeF64() *ValType { 42 return NewValType(F64) 43 } 44 45 func ValTypeV128() *ValType { 46 return NewValType(V128) 47 } 48 49 func ValTypeAnyref() *ValType { 50 return NewValType(ANYREF) 51 } 52 53 func ValTypeFuncref() *ValType { 54 return NewValType(FUNCREF) 55 }