llgo/ssa.SetRuntime: prevent multiple loading of runtime
This commit is contained in:
@@ -465,6 +465,9 @@ func NewPackage(prog llssa.Program, pkg *ssa.Package, files []*ast.File) (ret ll
|
||||
pkgProg := pkg.Prog
|
||||
pkgTypes := pkg.Pkg
|
||||
pkgName, pkgPath := pkgTypes.Name(), llssa.PathOf(pkgTypes)
|
||||
if pkgPath == llssa.PkgRuntime {
|
||||
prog.SetRuntime(pkgTypes)
|
||||
}
|
||||
ret = prog.NewPackage(pkgName, pkgPath)
|
||||
|
||||
ctx := &context{
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/goplus/llgo/cl/cltest"
|
||||
"github.com/goplus/llgo/ssa"
|
||||
)
|
||||
|
||||
func testCompile(t *testing.T, src, expected string) {
|
||||
@@ -36,7 +37,7 @@ func TestFromTestdata(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntime(t *testing.T) {
|
||||
cltest.Pkg(t, "github.com/goplus/llgo/internal/runtime", "../internal/runtime/llgo_autogen.ll")
|
||||
cltest.Pkg(t, ssa.PkgRuntime, "../internal/runtime/llgo_autogen.ll")
|
||||
}
|
||||
|
||||
func TestVar(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user