-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheei_debug_api.go
35 lines (27 loc) · 1.03 KB
/
eei_debug_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package tinywasm
import (
"fmt"
"github.com/tinychain/tiny-wasm/wagon/exec"
"github.com/tinychain/tinychain/common"
)
type eeiDebugApi struct{}
func (*eeiDebugApi) print32(p *exec.Process, w *WasmIntptr, value int32) {
fmt.Println(value)
}
func (*eeiDebugApi) print64(p *exec.Process, w *WasmIntptr, value int64) {
fmt.Println(value)
}
func (*eeiDebugApi) printMem(p *exec.Process, w *WasmIntptr, offset, len int32) {
fmt.Println(loadFromMem(p, offset, len))
}
func (*eeiDebugApi) printMemHex(p *exec.Process, w *WasmIntptr, offset, len int32) {
fmt.Println(common.Hex(loadFromMem(p, offset, len)))
}
func (*eeiDebugApi) printStorage(p *exec.Process, w *WasmIntptr, pathOffset int32) {
key := common.BytesToHash(loadFromMem(p, pathOffset, u256Len))
fmt.Println(w.StateDB().GetState(w.contract.Address(), key))
}
func (*eeiDebugApi) printStorageHex(p *exec.Process, w *WasmIntptr, pathOffset int32) {
key := common.BytesToHash(loadFromMem(p, pathOffset, u256Len))
fmt.Println(common.Hex(w.StateDB().GetState(w.contract.Address(), key)))
}