Refactor.

This commit is contained in:
Nuno Cruces
2023-04-10 19:55:44 +01:00
parent 3a8cfd036d
commit 23ee4ccb0b
12 changed files with 204 additions and 258 deletions

View File

@@ -21,27 +21,6 @@ func View(mod api.Module, ptr uint32, size uint64) []byte {
return buf
}
func ReadUint8(mod api.Module, ptr uint32) uint8 {
if ptr == 0 {
panic(NilErr)
}
v, ok := mod.Memory().ReadByte(ptr)
if !ok {
panic(RangeErr)
}
return v
}
func WriteUint8(mod api.Module, ptr uint32, v uint8) {
if ptr == 0 {
panic(NilErr)
}
ok := mod.Memory().WriteByte(ptr, v)
if !ok {
panic(RangeErr)
}
}
func ReadUint32(mod api.Module, ptr uint32) uint32 {
if ptr == 0 {
panic(NilErr)
@@ -84,18 +63,6 @@ func WriteUint64(mod api.Module, ptr uint32, v uint64) {
}
}
func ReadBool8(mod api.Module, ptr uint32) bool {
return ReadUint8(mod, ptr) != 0
}
func WriteBool8(mod api.Module, ptr uint32, v bool) {
var b uint8
if v {
b = 1
}
WriteUint8(mod, ptr, b)
}
func ReadFloat64(mod api.Module, ptr uint32) float64 {
return math.Float64frombits(ReadUint64(mod, ptr))
}