From 0b227d990f56b3ea059d13584ff9102ee5039a0b Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 22 Aug 2022 23:55:57 +0000 Subject: Add flag to generate PCs markers when decompiling --- cmd/vm/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd/vm') diff --git a/cmd/vm/main.go b/cmd/vm/main.go index bb8f142..d58dae1 100644 --- a/cmd/vm/main.go +++ b/cmd/vm/main.go @@ -15,6 +15,7 @@ func main() { // Take the first argument as the path to the file to be parsed. compile := flag.String("c", "", "compile to file (if not bytecode)") decompile := flag.String("d", "", "decompile bytecode to file") + generatePCs := flag.Bool("p", false, "if decompiling, generate PC information") run := flag.Bool("r", false, "run") bytecode := flag.Bool("b", false, "interpret bytecode, without this flag the program will be interpreted in Lang VM text format.") @@ -36,6 +37,10 @@ func main() { exit("nothing to do, either -c, -d or -r is required") } + if *decompile == "" && *generatePCs { + exit("-p requires -d") + } + path := flag.Arg(0) if path == "" { exit("no file specified") @@ -75,7 +80,7 @@ func main() { bc = code.New(content, code.NewDebugInfo(path)) if *decompile != "" { - decomp := text.NewDecompiler(bc) + decomp := text.NewDecompiler(bc, *generatePCs) result := decomp.Decompile() output, err := os.Create(*decompile) -- cgit 1.4.1