mirror of
https://github.com/wader/fq.git
synced 2024-12-23 05:13:30 +03:00
wasm: define and use constants for some insturctions
This commit is contained in:
parent
abcc736653
commit
db8021c931
@ -577,14 +577,20 @@ func decodeWASMModule(d *decode.D) {
|
||||
|
||||
var instrMapOnce sync.Once
|
||||
|
||||
const (
|
||||
opcodeBlock Opcode = 0x02
|
||||
opcodeLoop Opcode = 0x03
|
||||
opcodeIf Opcode = 0x04
|
||||
)
|
||||
|
||||
func decodeWASM(d *decode.D, _ any) any {
|
||||
d.Endian = decode.LittleEndian
|
||||
|
||||
// delayed initialization to break initialization reference cycle
|
||||
instrMapOnce.Do(func() {
|
||||
instrMap[0x02] = instructionInfo{mnemonic: "block", f: decodeBlock}
|
||||
instrMap[0x03] = instructionInfo{mnemonic: "loop", f: decodeLoop}
|
||||
instrMap[0x04] = instructionInfo{mnemonic: "if", f: decodeIf}
|
||||
instrMap[opcodeBlock] = instructionInfo{mnemonic: "block", f: decodeBlock}
|
||||
instrMap[opcodeLoop] = instructionInfo{mnemonic: "loop", f: decodeLoop}
|
||||
instrMap[opcodeIf] = instructionInfo{mnemonic: "if", f: decodeIf}
|
||||
})
|
||||
|
||||
decodeWASMModule(d)
|
||||
|
Loading…
Reference in New Issue
Block a user