runtime.Struct: temp disable abi.NewName

This commit is contained in:
xushiwei
2024-05-24 10:30:56 +08:00
parent 937e55eb46
commit 9b4701fed7
4 changed files with 15 additions and 13 deletions

View File

@@ -6,7 +6,8 @@ import (
) )
func main() { func main() {
if x, ok := foo.Bar().(struct{ V int }); ok { bar := foo.Bar()
if x, ok := bar.(struct{ V int }); ok {
c.Printf(c.Str("%d\n"), x.V) c.Printf(c.Str("%d\n"), x.V)
} else { } else {
c.Printf(c.Str("Bar: not ok\n")) c.Printf(c.Str("Bar: not ok\n"))

View File

@@ -44,13 +44,13 @@ _llgo_0:
store ptr %1, ptr @__llgo_argv, align 8 store ptr %1, ptr @__llgo_argv, align 8
call void @"github.com/goplus/llgo/internal/runtime.init"() call void @"github.com/goplus/llgo/internal/runtime.init"()
call void @main.init() call void @main.init()
%2 = alloca { i64 }, align 8 %2 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"()
%3 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %2, i64 8) %3 = alloca { i64 }, align 8
%4 = call %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() %4 = call ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr %3, i64 8)
%5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 0 %5 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %2, 0
%6 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8 %6 = load ptr, ptr @"_llgo_struct$K-dZ9QotZfVPz2a0YdRa9vmZUuDXPTqZOlMShKEDJtk", align 8
%7 = icmp eq ptr %5, %6 %7 = icmp eq ptr %5, %6
%8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %4, 1 %8 = extractvalue %"github.com/goplus/llgo/internal/runtime.eface" %2, 1
%9 = ptrtoint ptr %8 to i64 %9 = ptrtoint ptr %8 to i64
%10 = alloca { i64 }, align 8 %10 = alloca { i64 }, align 8
%11 = getelementptr inbounds { i64 }, ptr %10, i32 0, i32 0 %11 = getelementptr inbounds { i64 }, ptr %10, i32 0, i32 0
@@ -70,12 +70,12 @@ _llgo_0:
%20 = load { { i64 }, i1 }, ptr %17, align 4 %20 = load { { i64 }, i1 }, ptr %17, align 4
%21 = select i1 %7, { { i64 }, i1 } %16, { { i64 }, i1 } %20 %21 = select i1 %7, { { i64 }, i1 } %16, { { i64 }, i1 } %20
%22 = extractvalue { { i64 }, i1 } %21, 0 %22 = extractvalue { { i64 }, i1 } %21, 0
store { i64 } %22, ptr %3, align 4 store { i64 } %22, ptr %4, align 4
%23 = extractvalue { { i64 }, i1 } %21, 1 %23 = extractvalue { { i64 }, i1 } %21, 1
br i1 %23, label %_llgo_1, label %_llgo_3 br i1 %23, label %_llgo_1, label %_llgo_3
_llgo_1: ; preds = %_llgo_0 _llgo_1: ; preds = %_llgo_0
%24 = getelementptr inbounds { i64 }, ptr %3, i32 0, i32 0 %24 = getelementptr inbounds { i64 }, ptr %4, i32 0, i32 0
%25 = load i64, ptr %24, align 4 %25 = load i64, ptr %24, align 4
%26 = call i32 (ptr, ...) @printf(ptr @0, i64 %25) %26 = call i32 (ptr, ...) @printf(ptr @0, i64 %25)
br label %_llgo_2 br label %_llgo_2
@@ -133,10 +133,10 @@ declare void @"github.com/goplus/llgo/cl/internal/foo.init"()
declare void @"github.com/goplus/llgo/internal/runtime.init"() declare void @"github.com/goplus/llgo/internal/runtime.init"()
declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)
declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"() declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.Bar"()
declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)
declare i32 @printf(ptr, ...) declare i32 @printf(ptr, ...)
declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"() declare %"github.com/goplus/llgo/internal/runtime.eface" @"github.com/goplus/llgo/cl/internal/foo.F"()

Binary file not shown.

View File

@@ -97,15 +97,16 @@ func StructField(name string, typ *Type, off uintptr, tag string, exported, embe
// Struct returns a struct type. // Struct returns a struct type.
func Struct(size uintptr, pkgPath string, fields ...abi.StructField) *Type { func Struct(size uintptr, pkgPath string, fields ...abi.StructField) *Type {
npkg := abi.NewName(pkgPath, "", false, false) // TODO(xsw): pkgPath
// npkg := abi.NewName(pkgPath, "", false, false)
ret := &abi.StructType{ ret := &abi.StructType{
Type: Type{ Type: Type{
Size_: size, Size_: size,
Hash: uint32(abi.Struct), // TODO(xsw): hash Hash: uint32(abi.Struct), // TODO(xsw): hash
Kind_: uint8(abi.Struct), Kind_: uint8(abi.Struct),
}, },
PkgPath: npkg, // PkgPath: npkg,
Fields: fields, Fields: fields,
} }
return &ret.Type return &ret.Type
} }