Merge pull request #580 from visualfc/afterinit

cl: after init check hasPatch
This commit is contained in:
xushiwei
2024-07-28 09:17:59 +08:00
committed by GitHub

View File

@@ -25,6 +25,7 @@ import (
"log"
"os"
"sort"
"strings"
"github.com/goplus/llgo/cl/blocks"
"github.com/goplus/llgo/internal/typepatch"
@@ -288,9 +289,14 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
instrs = instrs[:last]
} else {
// TODO(xsw): confirm pyMod don't need to call AfterInit
p.inits = append(p.inits, func() {
after := func() {
pkg.AfterInit(b, ret)
})
}
if strings.HasSuffix(fn.Name(), "$hasPatch") {
p.inits[len(p.inits)-1] = after
} else {
p.inits = append(p.inits, after)
}
}
} else if doMainInit {
argc := pkg.NewVar("__llgo_argc", types.NewPointer(types.Typ[types.Int32]), llssa.InC)