compileBlock bugfix: pyMod

This commit is contained in:
xushiwei
2024-05-13 00:41:42 +08:00
parent 46527f56ce
commit 31d5a8ac10
3 changed files with 15 additions and 13 deletions

View File

@@ -347,20 +347,22 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
if pyModInit = p.pyMod != ""; pyModInit {
last = len(instrs) - 1
instrs = instrs[:last]
} else {
// TODO(xsw): confirm pyMod don't need to call LoadPyModSyms
p.inits = append(p.inits, func() {
if objs := pkg.PyObjs(); len(objs) > 0 {
mods := make(map[string][]llssa.PyObjRef)
for name, obj := range objs {
modName := modOf(name)
mods[modName] = append(mods[modName], obj)
}
b.SetBlockEx(ret, llssa.AfterInit)
for modName, objs := range mods {
b.LoadPyModSyms(modName, objs...)
}
}
})
}
p.inits = append(p.inits, func() {
if objs := pkg.PyObjs(); len(objs) > 0 {
mods := make(map[string][]llssa.PyObjRef)
for name, obj := range objs {
modName := modOf(name)
mods[modName] = append(mods[modName], obj)
}
b.SetBlockEx(ret, llssa.AfterInit)
for modName, objs := range mods {
b.LoadPyModSyms(modName, objs...)
}
}
})
} else if doMainInit {
fn := p.fn
argc := pkg.NewVar("__llgo_argc", types.NewPointer(types.Typ[types.Int32]), llssa.InC)

Binary file not shown.

Binary file not shown.