runtime: MakeAnyString

This commit is contained in:
xushiwei
2024-04-28 10:29:06 +08:00
parent 7039cb3bc2
commit 0d68066086
4 changed files with 27 additions and 16 deletions

View File

@@ -37,6 +37,13 @@ func MakeAnyInt(typ *Type, data uintptr) Interface {
}
}
func MakeAnyString(data string) Interface {
return Interface{
tab: &itab{inter: TyAny, _type: Basic(abi.String), hash: 0, fun: [1]uintptr{0}},
data: unsafe.Pointer(&data),
}
}
func MakeAny(typ *Type, data unsafe.Pointer) Interface {
return Interface{
tab: &itab{inter: TyAny, _type: typ, hash: 0, fun: [1]uintptr{0}},

View File

@@ -47,6 +47,7 @@ var (
abi.Float64: basicType(abi.Float64),
abi.Complex64: basicType(abi.Complex64),
abi.Complex128: basicType(abi.Complex128),
abi.String: basicType(abi.String),
}
)
@@ -68,6 +69,7 @@ var (
abi.Float64: 8,
abi.Complex64: 8,
abi.Complex128: 16,
abi.String: unsafe.Sizeof(String{}),
}
)