compileValue ssa.Function fix: v.Pkg == nil: means auto generated function?
This commit is contained in:
@@ -4,6 +4,15 @@ import (
|
||||
"github.com/goplus/llgo/internal/runtime/c"
|
||||
)
|
||||
|
||||
type generator struct {
|
||||
val c.Int
|
||||
}
|
||||
|
||||
func (g *generator) next() c.Int {
|
||||
g.val++
|
||||
return g.val
|
||||
}
|
||||
|
||||
func genInts(n int, gen func() c.Int) []c.Int {
|
||||
a := make([]c.Int, n)
|
||||
for i := range a {
|
||||
@@ -25,4 +34,8 @@ func main() {
|
||||
for _, v := range b {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
g := &generator{val: 1}
|
||||
for _, v := range genInts(5, g.next) {
|
||||
c.Printf(c.Str("%d\n"), v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,7 +645,8 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr {
|
||||
}
|
||||
}
|
||||
case *ssa.Function:
|
||||
if v.Pkg == p.goPkg { // function in this package
|
||||
// v.Pkg == nil: means auto generated function?
|
||||
if v.Pkg == p.goPkg || v.Pkg == nil { // function in this package
|
||||
fn := p.compileFunc(p.pkg, p.goTyps, v)
|
||||
return fn.Expr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user