Add disasembler-ish - bytecode to instruction debug output

This commit is contained in:
lash
2023-04-02 15:00:56 +01:00
parent aec0564cea
commit ac4a2bac00
7 changed files with 258 additions and 5 deletions

27
go/dev/disasm/main.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"fmt"
"os"
"io/ioutil"
"git.defalsify.org/festive/vm"
)
func main() {
if (len(os.Args) < 2) {
os.Exit(1)
}
fp := os.Args[1]
v, err := ioutil.ReadFile(fp)
if err != nil {
fmt.Fprintf(os.Stderr, "read error: %v", err)
os.Exit(1)
}
r, err := vm.ToString(v)
if err != nil {
fmt.Fprintf(os.Stderr, "parse error: %v", err)
os.Exit(1)
}
fmt.Printf(r)
}