Fixes coverage on externref/uintptr (#543)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-05-11 16:35:55 +08:00
committed by GitHub
parent 05e7201698
commit da325eaf59
4 changed files with 78 additions and 32 deletions

View File

@@ -327,6 +327,18 @@ type Memory interface {
Write(ctx context.Context, offset uint32, v []byte) bool
}
// EncodeExternref encodes the input as a ValueTypeExternref.
// See DecodeExternref
func EncodeExternref(input uintptr) uint64 {
return uint64(input)
}
// DecodeExternref decodes the input as a ValueTypeExternref.
// See EncodeExternref
func DecodeExternref(input uint64) uintptr {
return uintptr(input)
}
// EncodeI32 encodes the input as a ValueTypeI32.
func EncodeI32(input int32) uint64 {
return uint64(uint32(input))
@@ -344,13 +356,13 @@ func EncodeF32(input float32) uint64 {
}
// DecodeF32 decodes the input as a ValueTypeF32.
// See DecodeF32
// See EncodeF32
func DecodeF32(input uint64) float32 {
return math.Float32frombits(uint32(input))
}
// EncodeF64 encodes the input as a ValueTypeF64.
// See DecodeF64
// See EncodeF32
func EncodeF64(input float64) uint64 {
return math.Float64bits(input)
}