ssa: closure use specific struct field name { $f ftype, $data unsafe.pointer }

This commit is contained in:
visualfc
2024-12-21 21:37:46 +08:00
parent 070d64f365
commit a6a3c09c05
14 changed files with 238 additions and 190 deletions

View File

@@ -417,8 +417,9 @@ func (p Program) toLLVMStruct(raw *types.Struct) (ret llvm.Type, kind valueKind)
func isClosure(raw *types.Struct) bool {
n := raw.NumFields()
if n == 2 {
if _, ok := raw.Field(0).Type().(*types.Signature); ok {
return raw.Field(1).Type() == types.Typ[types.UnsafePointer]
f1, f2 := raw.Field(0), raw.Field(1)
if _, ok := f1.Type().(*types.Signature); ok && f1.Name() == "$f" {
return f2.Type() == types.Typ[types.UnsafePointer] && f2.Name() == "$data"
}
}
return false