diff options
Diffstat (limited to 'cmd/vm')
| -rw-r--r-- | cmd/vm/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
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) |
