ssa: binop equal(func,slice,array,struct) and buildConstStr

This commit is contained in:
visualfc
2024-06-13 09:40:41 +08:00
parent f3b6d25aaa
commit 0c321c8c98
27 changed files with 4226 additions and 3199 deletions

View File

@@ -338,7 +338,7 @@ func EfaceEqual(v, u eface) bool {
if v._type != u._type {
return false
}
if v._type.Kind_&abi.KindDirectIface != 0 {
if isDirectIface(v._type) {
return v.data == u.data
}
switch v.Kind() {
@@ -369,7 +369,11 @@ func EfaceEqual(v, u eface) bool {
case abi.Struct:
st := v._type.StructType()
field := func(data unsafe.Pointer, ft *abi.StructField) eface {
return eface{ft.Typ, c.Advance(data, int(ft.Offset))}
ptr := c.Advance(data, int(ft.Offset))
if isDirectIface(ft.Typ) {
ptr = *(*unsafe.Pointer)(ptr)
}
return eface{ft.Typ, ptr}
}
for _, ft := range st.Fields {
if !EfaceEqual(field(v.data, &ft), field(u.data, &ft)) {
@@ -405,7 +409,7 @@ func (v eface) Elem() eface {
return *(*eface)(unsafe.Pointer(&i))
case abi.Pointer:
ptr := v.data
if v._type.Kind_&abi.KindDirectIface != 0 {
if isDirectIface(v._type) {
ptr = *(*unsafe.Pointer)(ptr)
}
if ptr == nil {
@@ -416,4 +420,8 @@ func (v eface) Elem() eface {
panic("invalid eface elem")
}
func isDirectIface(t *_type) bool {
return t.Kind_&abi.KindDirectIface != 0
}
// -----------------------------------------------------------------------------