Merge pull request #582 from visualfc/init.patch

fix pkg init hasPatch && patch io.pipe
This commit is contained in:
xushiwei
2024-07-28 21:13:50 +08:00
committed by GitHub
4 changed files with 211 additions and 211 deletions

View File

@@ -195,6 +195,9 @@ func (p *context) compileFuncDecl(pkg llssa.Package, f *ssa.Function) (llssa.Fun
isInit := (f.Name() == "init" && sig.Recv() == nil)
if isInit && state == pkgHasPatch {
name = initFnNameOfHasPatch(name)
// pkg.init$guard has been set, change ssa.if-cond
block := f.Blocks[0].Instrs[1].(*ssa.If).Block()
block.Succs[0], block.Succs[1] = block.Succs[1], block.Succs[0]
}
fn := pkg.FuncOf(name)