runtime: TODO - error var; cl: link goVar

This commit is contained in:
xushiwei
2024-06-13 02:53:54 +08:00
parent 18eecbe9f4
commit 7235357ef5
7 changed files with 68 additions and 8 deletions

View File

@@ -192,7 +192,7 @@ func (p *context) compileMethods(pkg llssa.Package, typ types.Type) {
// Global variable.
func (p *context) compileGlobal(pkg llssa.Package, gbl *ssa.Global) {
typ := gbl.Type()
name, vtype := p.varName(gbl.Pkg.Pkg, gbl)
name, vtype, define := p.varName(gbl.Pkg.Pkg, gbl)
if vtype == pyVar || ignoreName(name) || checkCgo(gbl.Name()) {
return
}
@@ -200,7 +200,7 @@ func (p *context) compileGlobal(pkg llssa.Package, gbl *ssa.Global) {
log.Println("==> NewVar", name, typ)
}
g := pkg.NewVar(name, typ, llssa.Background(vtype))
if vtype == goVar {
if define {
g.Init(p.prog.Nil(g.Type))
}
}