globalType: support typepatch

This commit is contained in:
xushiwei
2024-06-18 00:06:40 +08:00
parent edaba44c87
commit 3b2e97a729
4 changed files with 16 additions and 3 deletions

View File

@@ -139,7 +139,7 @@ func (p *context) compileMethods(pkg llssa.Package, typ types.Type) {
// Global variable.
func (p *context) compileGlobal(pkg llssa.Package, gbl *ssa.Global) {
typ := gbl.Type()
typ := globalType(gbl)
name, vtype, define := p.varName(gbl.Pkg.Pkg, gbl)
if vtype == pyVar || ignoreName(name) || checkCgo(gbl.Name()) {
return
@@ -803,4 +803,15 @@ func processPkg(ctx *context, ret llssa.Package, pkg *ssa.Package) {
}
}
func globalType(gbl *ssa.Global) types.Type {
t := gbl.Type()
if t, ok := t.(*types.Named); ok {
o := t.Obj()
if pkg := o.Pkg(); typepatch.IsPatched(pkg) {
return gbl.Pkg.Pkg.Scope().Lookup(o.Name()).Type()
}
}
return t
}
// -----------------------------------------------------------------------------