cl: callRuntimeInit; runtime: TracePanic
This commit is contained in:
@@ -19,6 +19,8 @@ package llgen
|
||||
import (
|
||||
"go/types"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/goplus/llgo/cl"
|
||||
"golang.org/x/tools/go/packages"
|
||||
@@ -66,3 +68,23 @@ func DoFile(fileOrPkg, outFile string) {
|
||||
err := os.WriteFile(outFile, []byte(ret), 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
func SmartDoFile(inFile string, pkgPath ...string) {
|
||||
dir, _ := filepath.Split(inFile)
|
||||
fname := "llgo_autogen.ll"
|
||||
if inCompilerDir(dir) {
|
||||
fname = "out.ll"
|
||||
}
|
||||
outFile := dir + fname
|
||||
|
||||
if len(pkgPath) > 0 {
|
||||
Do(pkgPath[0], inFile, outFile)
|
||||
} else {
|
||||
DoFile(inFile, outFile)
|
||||
}
|
||||
}
|
||||
|
||||
func inCompilerDir(dir string) bool {
|
||||
dir, _ = filepath.Abs(dir)
|
||||
return strings.Contains(filepath.ToSlash(dir), "/llgo/cl/")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user