Merge pull request #146 from xushiwei/q

LLGoPackage: PkgPyModule
This commit is contained in:
xushiwei
2024-05-11 06:47:25 +08:00
committed by GitHub
4 changed files with 8 additions and 2 deletions

View File

@@ -123,6 +123,7 @@ type instrOrValue interface {
const ( const (
PkgNormal = iota PkgNormal = iota
PkgLLGo PkgLLGo
PkgPyModule // py.<module>
PkgNoInit // noinit: a package that don't need to be initialized PkgNoInit // noinit: a package that don't need to be initialized
PkgDeclOnly // decl: a package that only have declarations PkgDeclOnly // decl: a package that only have declarations
PkgLinkIR // link llvm ir (.ll) PkgLinkIR // link llvm ir (.ll)

View File

@@ -101,6 +101,8 @@ func pkgKind(v string) (int, string) {
// return PkgLinkBitCode // return PkgLinkBitCode
if strings.HasPrefix(v, "link:") { // "link: <libpath>" if strings.HasPrefix(v, "link:") { // "link: <libpath>"
return PkgLinkExtern, v[5:] return PkgLinkExtern, v[5:]
} else if strings.HasPrefix(v, "py.") { // "py.<module>"
return PkgPyModule, v[3:]
} }
} }
return PkgLLGo, "" return PkgLLGo, ""

View File

@@ -172,7 +172,7 @@ func buildAllPkgs(prog llssa.Program, initial []*packages.Package, mode Mode, ve
// skip packages that only contain declarations // skip packages that only contain declarations
// and set no export file // and set no export file
pkg.ExportFile = "" pkg.ExportFile = ""
case cl.PkgLinkIR: case cl.PkgLinkIR, cl.PkgPyModule:
// skip packages that don't need to be compiled but need to be linked // skip packages that don't need to be compiled but need to be linked
pkgPath := pkg.PkgPath pkgPath := pkg.PkgPath
if isPkgInLLGo(pkgPath) { if isPkgInLLGo(pkgPath) {

View File

@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
// llgo:import py.math
package math package math
import ( import (
@@ -23,5 +22,9 @@ import (
"github.com/goplus/llgo/py" "github.com/goplus/llgo/py"
) )
const (
LLGoPackage = "py.math"
)
//go:linkname Sqrt py.sqrt //go:linkname Sqrt py.sqrt
func Sqrt(x *py.Object) *py.Object func Sqrt(x *py.Object) *py.Object