From be8852537d2ee4f0509f3661c3b24e62d993900b Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Fri, 15 Dec 2023 11:05:35 +1000 Subject: [PATCH] The D param appears to be added to the end --- compiler/function.go | 14 +++++++------- compiler/testdata/coroutine_durable.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/function.go b/compiler/function.go index 4a962b4..75ed118 100644 --- a/compiler/function.go +++ b/compiler/function.go @@ -178,13 +178,6 @@ func collectFunctypes(p *packages.Package, name string, fn ast.Node, scope *func Names: []*ast.Ident{ast.NewIdent("F")}, }, } - if g != nil { - // Append a field for the dictionary. - fields = append(fields, &ast.Field{ - Type: ast.NewIdent("uintptr"), - Names: []*ast.Ident{ast.NewIdent("D")}, - }) - } for i, freeVar := range freeVars { fieldName := ast.NewIdent(fmt.Sprintf("X%d", i)) fieldType := freeVar.typ @@ -204,6 +197,13 @@ func collectFunctypes(p *packages.Package, name string, fn ast.Node, scope *func Names: []*ast.Ident{fieldName}, }) } + if g != nil { + // Append a field for the dictionary. + fields = append(fields, &ast.Field{ + Type: ast.NewIdent("uintptr"), + Names: []*ast.Ident{ast.NewIdent("D")}, + }) + } functype.closure = &ast.StructType{ Fields: &ast.FieldList{List: fields}, } diff --git a/compiler/testdata/coroutine_durable.go b/compiler/testdata/coroutine_durable.go index 16db274..ae33652 100644 --- a/compiler/testdata/coroutine_durable.go +++ b/compiler/testdata/coroutine_durable.go @@ -3574,12 +3574,12 @@ func init() { _types.RegisterFunc[func(_fn1 int) (_ func(int))]("github.com/stealthrocket/coroutine/compiler/testdata.(*IdentityGenericStruct[go.shape.int]).Closure") _types.RegisterClosure[func(_fn0 int), struct { F uintptr - D uintptr X0 *struct { IP int X0 *IdentityGenericStruct[int] X1 int } + D uintptr }]("github.com/stealthrocket/coroutine/compiler/testdata.(*IdentityGenericStruct[go.shape.int]).Closure.func2") _types.RegisterFunc[func()]("github.com/stealthrocket/coroutine/compiler/testdata.(*IdentityGenericStruct[go.shape.int]).Run") _types.RegisterFunc[func(_fn1 int)]("github.com/stealthrocket/coroutine/compiler/testdata.(*MethodGeneratorState).MethodGenerator") @@ -3721,8 +3721,8 @@ func init() { _types.RegisterFunc[func(n int) func()]("github.com/stealthrocket/coroutine/compiler/testdata.buildClosure[go.shape.int]") _types.RegisterClosure[func(), struct { F uintptr - D uintptr X0 int + D uintptr }]("github.com/stealthrocket/coroutine/compiler/testdata.buildClosure[go.shape.int].func1") _types.RegisterFunc[func(_fn0 ...int)]("github.com/stealthrocket/coroutine/compiler/testdata.varArgs") }