cl: after init check hasPatch

This commit is contained in:
visualfc
2024-07-27 21:18:33 +08:00
parent 5428730e7a
commit 4d14fbb1e7

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)