llgo/ssa: AfterInit/SliceLit/InterfaceData, unsafe.Slice; ssa/abi: Basic/Struct
This commit is contained in:
18
cl/_testgo/strucintf/in.go
Normal file
18
cl/_testgo/strucintf/in.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/_demo/interf/foo"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if x, ok := foo.Bar().(struct{ V int }); ok {
|
||||
println(x.V)
|
||||
} else {
|
||||
println("Bar: not ok")
|
||||
}
|
||||
if x, ok := foo.F().(struct{ v int }); ok {
|
||||
println(x.v)
|
||||
} else {
|
||||
println("F: not ok")
|
||||
}
|
||||
}
|
||||
0
cl/_testgo/strucintf/out.ll
Normal file
0
cl/_testgo/strucintf/out.ll
Normal file
@@ -352,9 +352,9 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
|
||||
last = len(instrs) - 1
|
||||
instrs = instrs[:last]
|
||||
} else {
|
||||
// TODO(xsw): confirm pyMod don't need to call LoadPyModSyms
|
||||
// TODO(xsw): confirm pyMod don't need to call AfterInit
|
||||
p.inits = append(p.inits, func() {
|
||||
pkg.PyLoadModSyms(b, ret)
|
||||
pkg.AfterInit(b, ret)
|
||||
})
|
||||
}
|
||||
} else if doMainInit {
|
||||
|
||||
@@ -28,11 +28,9 @@ func testCompile(t *testing.T, src, expected string) {
|
||||
cltest.TestCompileEx(t, src, "foo.go", expected)
|
||||
}
|
||||
|
||||
/*
|
||||
func TestFromTestgo(t *testing.T) {
|
||||
cltest.FromDir(t, "strucintf", "./_testgo", false)
|
||||
}
|
||||
*/
|
||||
|
||||
func TestFromTestpy(t *testing.T) {
|
||||
cltest.FromDir(t, "", "./_testpy", false)
|
||||
|
||||
9
cl/internal/foo/foo.go
Normal file
9
cl/internal/foo/foo.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
func Bar() any {
|
||||
return struct{ V int }{1}
|
||||
}
|
||||
|
||||
func F() any {
|
||||
return struct{ v int }{1}
|
||||
}
|
||||
Reference in New Issue
Block a user