cl: initPyModule

This commit is contained in:
xushiwei
2024-05-11 10:07:46 +08:00
parent 2560a333b6
commit 427d87be68
8 changed files with 48 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ import (
"golang.org/x/tools/go/ssa"
)
// -----------------------------------------------------------------------------
type symInfo struct {
file string
fullName string
@@ -305,6 +307,7 @@ const (
ignoredFunc = iota
goFunc = int(llssa.InGo)
cFunc = int(llssa.InC)
pyFunc = int(llssa.InPython)
llgoInstr = -1
llgoInstrBase = 0x80
@@ -341,6 +344,9 @@ func (p *context) funcName(fn *ssa.Function, ignore bool) (*types.Package, strin
if strings.HasPrefix(v, "C.") {
return nil, v[2:], cFunc
}
if strings.HasPrefix(v, "py.") {
return nil, v[3:], pyFunc
}
if strings.HasPrefix(v, "llgo.") {
return nil, v[5:], llgoInstr
}
@@ -393,3 +399,13 @@ func pkgKindByPath(pkgPath string) int {
}
return PkgNormal
}
// -----------------------------------------------------------------------------
func (p *context) initPyModule() {
if kind, mod := pkgKindByScope(p.goTyps.Scope()); kind == PkgPyModule {
p.pyMod = mod
}
}
// -----------------------------------------------------------------------------