From c63a1978cb873df0a9505a8fbffe524a44fb46b0 Mon Sep 17 00:00:00 2001 From: visualfc Date: Sun, 28 Jul 2024 11:29:22 +0800 Subject: [PATCH] cl: afterInit skip pkgHasPatch --- cl/compile.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cl/compile.go b/cl/compile.go index 91694861..e50eb478 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -25,7 +25,6 @@ import ( "log" "os" "sort" - "strings" "github.com/goplus/llgo/cl/blocks" "github.com/goplus/llgo/internal/typepatch" @@ -287,16 +286,11 @@ 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 { + } else if p.state != pkgHasPatch { // TODO(xsw): confirm pyMod don't need to call AfterInit - after := func() { + p.inits = append(p.inits, 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)