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) {
|
func (p *context) compileGlobal(pkg llssa.Package, gbl *ssa.Global) {
|
||||||
typ := gbl.Type()
|
typ := gbl.Type()
|
||||||
name, vtype := p.varName(gbl.Pkg.Pkg, gbl)
|
name, vtype := p.varName(gbl.Pkg.Pkg, gbl)
|
||||||
if ignoreName(name) || checkCgo(gbl.Name()) {
|
if vtype == pyVar || ignoreName(name) || checkCgo(gbl.Name()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if debugInstr {
|
if debugInstr {
|
||||||
@@ -831,8 +831,7 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr {
|
|||||||
}
|
}
|
||||||
return pyFn.Expr
|
return pyFn.Expr
|
||||||
case *ssa.Global:
|
case *ssa.Global:
|
||||||
g := p.varOf(v)
|
return p.varOf(v)
|
||||||
return g.Expr
|
|
||||||
case *ssa.Const:
|
case *ssa.Const:
|
||||||
t := types.Default(v.Type())
|
t := types.Default(v.Type())
|
||||||
return b.Const(v.Value, p.prog.Type(t, llssa.InGo))
|
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
|
ignoredVar = iota
|
||||||
goVar = int(llssa.InGo)
|
goVar = int(llssa.InGo)
|
||||||
cVar = int(llssa.InC)
|
cVar = int(llssa.InC)
|
||||||
|
pyVar = int(llssa.InPython)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *context) varName(pkg *types.Package, v *ssa.Global) (vName string, vtype int) {
|
func (p *context) varName(pkg *types.Package, v *ssa.Global) (vName string, vtype int) {
|
||||||
name := llssa.FullName(pkg, v.Name())
|
name := llssa.FullName(pkg, v.Name())
|
||||||
if v, ok := p.link[name]; ok {
|
if v, ok := p.link[name]; ok {
|
||||||
|
if strings.HasPrefix(v, "py.") {
|
||||||
|
return v[3:], pyVar
|
||||||
|
}
|
||||||
return v, cVar
|
return v, cVar
|
||||||
}
|
}
|
||||||
return name, goVar
|
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)
|
pkgTypes := p.ensureLoaded(v.Pkg.Pkg)
|
||||||
pkg := p.pkg
|
pkg := p.pkg
|
||||||
name, vtype := p.varName(pkgTypes, v)
|
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))
|
ret = pkg.NewVar(name, v.Type(), llssa.Background(vtype))
|
||||||
}
|
}
|
||||||
return
|
return ret.Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *context) ensureLoaded(pkgTypes *types.Package) *types.Package {
|
func (p *context) ensureLoaded(pkgTypes *types.Package) *types.Package {
|
||||||
|
|||||||
Reference in New Issue
Block a user