-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (33 loc) · 819 Bytes
/
main.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
36
37
38
39
40
41
package main
import (
"flag"
"log"
"os"
"runtime/pprof"
"yolk/cli"
"yolk/vm"
)
var runFlag = flag.String("run", "", ".yolk file to exec")
var profilerFlag = flag.String("profiler", "", "start profiler and write the profile to the given path")
var debugFlag = flag.Bool("debug", false, "Show vm state after each instruction")
func main() {
flag.Parse()
if len(*profilerFlag) != 0 {
if f, err := os.Create(*profilerFlag); err != nil {
log.Fatalf("starting profiler: %v", err)
} else {
pprof.StartCPUProfile(f)
}
}
machine := vm.NewVM()
machine.MockExecutions = true
if len(*runFlag) == 0 {
log.Fatal("--run flag not spcified")
}
if err := cli.ExecuteYolkFile(&machine, *runFlag, *debugFlag); err != nil {
log.Fatal(err)
}
if len(*profilerFlag) != 0 {
pprof.StopCPUProfile()
}
}