cl: callRuntimeInit; runtime: TracePanic

This commit is contained in:
xushiwei
2024-05-01 11:03:52 +08:00
parent 673b9d9a5c
commit 666808b427
31 changed files with 330 additions and 102 deletions

View File

@@ -231,8 +231,9 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, doInit bo
ret := p.fn.Block(block.Index)
b.SetBlock(ret)
if doInit {
fn := p.pkg.FuncOf("main.init")
b.Call(fn.Expr)
pkg := p.pkg
callRuntimeInit(b, pkg)
b.Call(pkg.FuncOf("main.init").Expr)
}
for _, instr := range block.Instrs {
p.compileInstr(b, instr)
@@ -240,6 +241,15 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, doInit bo
return ret
}
const (
RuntimeInit = llssa.PkgRuntime + ".init"
)
func callRuntimeInit(b llssa.Builder, pkg llssa.Package) {
fn := pkg.NewFunc(RuntimeInit, types.NewSignatureType(nil, nil, nil, nil, nil, false))
b.Call(fn.Expr)
}
func isAny(t types.Type) bool {
if t, ok := t.(*types.Interface); ok {
return t.Empty()