cl: build initAfter
This commit is contained in:
@@ -98,8 +98,9 @@ type context struct {
|
|||||||
patches Patches
|
patches Patches
|
||||||
blkInfos []blocks.Info
|
blkInfos []blocks.Info
|
||||||
|
|
||||||
inits []func()
|
inits []func()
|
||||||
phis []func()
|
phis []func()
|
||||||
|
initAfter func()
|
||||||
|
|
||||||
state pkgState
|
state pkgState
|
||||||
inCFunc bool
|
inCFunc bool
|
||||||
@@ -292,9 +293,9 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
|
|||||||
instrs = instrs[:last]
|
instrs = instrs[:last]
|
||||||
} else if p.state != pkgHasPatch {
|
} else if p.state != pkgHasPatch {
|
||||||
// TODO(xsw): confirm pyMod don't need to call AfterInit
|
// TODO(xsw): confirm pyMod don't need to call AfterInit
|
||||||
p.inits = append(p.inits, func() {
|
p.initAfter = func() {
|
||||||
pkg.AfterInit(b, ret)
|
pkg.AfterInit(b, ret)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
} else if doMainInit {
|
} else if doMainInit {
|
||||||
argc := pkg.NewVar("__llgo_argc", types.NewPointer(types.Typ[types.Int32]), llssa.InC)
|
argc := pkg.NewVar("__llgo_argc", types.NewPointer(types.Typ[types.Int32]), llssa.InC)
|
||||||
@@ -837,6 +838,10 @@ func NewPackageEx(prog llssa.Program, patches Patches, pkg *ssa.Package, files [
|
|||||||
ini()
|
ini()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if fn := ctx.initAfter; fn != nil {
|
||||||
|
ctx.initAfter = nil
|
||||||
|
fn()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user