compileGlobal: skip pyVar
This commit is contained in:
@@ -185,7 +185,7 @@ func (p *context) compileMethods(pkg llssa.Package, typ types.Type) {
|
||||
func (p *context) compileGlobal(pkg llssa.Package, gbl *ssa.Global) {
|
||||
typ := gbl.Type()
|
||||
name, vtype := p.varName(gbl.Pkg.Pkg, gbl)
|
||||
if ignoreName(name) || checkCgo(gbl.Name()) {
|
||||
if vtype == pyVar || ignoreName(name) || checkCgo(gbl.Name()) {
|
||||
return
|
||||
}
|
||||
if debugInstr {
|
||||
@@ -831,8 +831,7 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr {
|
||||
}
|
||||
return pyFn.Expr
|
||||
case *ssa.Global:
|
||||
g := p.varOf(v)
|
||||
return g.Expr
|
||||
return p.varOf(v)
|
||||
case *ssa.Const:
|
||||
t := types.Default(v.Type())
|
||||
return b.Const(v.Value, p.prog.Type(t, llssa.InGo))
|
||||
|
||||
14
cl/import.go
14
cl/import.go
@@ -359,24 +359,32 @@ const (
|
||||
ignoredVar = iota
|
||||
goVar = int(llssa.InGo)
|
||||
cVar = int(llssa.InC)
|
||||
pyVar = int(llssa.InPython)
|
||||
)
|
||||
|
||||
func (p *context) varName(pkg *types.Package, v *ssa.Global) (vName string, vtype int) {
|
||||
name := llssa.FullName(pkg, v.Name())
|
||||
if v, ok := p.link[name]; ok {
|
||||
if strings.HasPrefix(v, "py.") {
|
||||
return v[3:], pyVar
|
||||
}
|
||||
return v, cVar
|
||||
}
|
||||
return name, goVar
|
||||
}
|
||||
|
||||
func (p *context) varOf(v *ssa.Global) (ret llssa.Global) {
|
||||
func (p *context) varOf(v *ssa.Global) llssa.Expr {
|
||||
pkgTypes := p.ensureLoaded(v.Pkg.Pkg)
|
||||
pkg := p.pkg
|
||||
name, vtype := p.varName(pkgTypes, v)
|
||||
if ret = pkg.VarOf(name); ret == nil {
|
||||
if vtype == pyVar {
|
||||
panic("todo")
|
||||
}
|
||||
ret := pkg.VarOf(name)
|
||||
if ret == nil {
|
||||
ret = pkg.NewVar(name, v.Type(), llssa.Background(vtype))
|
||||
}
|
||||
return
|
||||
return ret.Expr
|
||||
}
|
||||
|
||||
func (p *context) ensureLoaded(pkgTypes *types.Package) *types.Package {
|
||||
|
||||
Reference in New Issue
Block a user