llgo/ssa: pkg.NewFunc bugfix

This commit is contained in:
xushiwei
2024-04-28 12:09:47 +08:00
parent eb4146d80d
commit 2cc1bdee19
12 changed files with 65 additions and 52 deletions

View File

@@ -35,11 +35,11 @@ const (
loadSyntax = loadTypes | packages.NeedSyntax | packages.NeedTypesInfo
)
func GenFromFile(inFile string) string {
func GenFrom(fileOrPkg string) string {
cfg := &packages.Config{
Mode: loadSyntax,
}
initial, err := packages.Load(cfg, inFile)
initial, err := packages.Load(cfg, fileOrPkg)
check(err)
_, pkgs := ssautil.AllPackages(initial, ssa.SanityCheckFunctions)
@@ -61,8 +61,8 @@ func GenFromFile(inFile string) string {
return ret.String()
}
func DoFile(inFile, outFile string) {
ret := GenFromFile(inFile)
func DoFile(fileOrPkg, outFile string) {
ret := GenFrom(fileOrPkg)
err := os.WriteFile(outFile, []byte(ret), 0644)
check(err)
}

View File

@@ -1,5 +0,0 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package runtime

View File

@@ -1,15 +0,0 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package runtime
import (
"unsafe"
)
type slice struct {
array unsafe.Pointer
len int
cap int
}

View File

@@ -16,8 +16,16 @@
package runtime
import (
"unsafe"
)
// Slice is the runtime representation of a slice.
type Slice = slice
type Slice struct {
array unsafe.Pointer
len int
cap int
}
// NilSlice returns a nil slice.
func NilSlice() Slice {