llgo/ssa: builder.Alloc sizeof(t) bugfix

This commit is contained in:
xushiwei
2024-05-01 16:56:26 +08:00
parent e112d8277f
commit 62f6542ca9
8 changed files with 56 additions and 107 deletions

View File

@@ -20,7 +20,6 @@ import (
"unsafe"
"github.com/goplus/llgo/internal/abi"
"github.com/goplus/llgo/internal/runtime/c"
)
// -----------------------------------------------------------------------------
@@ -38,34 +37,29 @@ type Interface = iface
func MakeAnyInt(typ *Type, data uintptr) Interface {
tab := &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}}
return Interface{
tab: tab,
data: unsafe.Pointer(data),
tab: tab, data: unsafe.Pointer(data),
}
}
func MakeAnyString(data string) Interface {
typ := Basic(abi.String)
typ := basicTypes[abi.String]
tab := &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}}
c.Printf(c.Str("MakeAnyString(%p): %d, %d\n"), typ, int(typ.Kind_), abi.String)
return Interface{
tab: tab,
data: unsafe.Pointer(&data),
tab: tab, data: unsafe.Pointer(&data),
}
}
func MakeAny(typ *Type, data unsafe.Pointer) Interface {
tab := &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}}
return Interface{
tab: tab,
data: data,
tab: tab, data: data,
}
}
func MakeInterface(inter *InterfaceType, typ *Type, data unsafe.Pointer) Interface {
tab := &itab{inter: inter, _type: typ, hash: 0, fun: [1]uintptr{0}}
return Interface{
tab: tab,
data: data,
tab: tab, data: data,
}
}