Skip to content

Commit

Permalink
Merge pull request #68 from pigpigyyy/closure-name
Browse files Browse the repository at this point in the history
Fixed issue #67.
  • Loading branch information
chai2010 authored Dec 30, 2024
2 parents 00c578d + 1d28498 commit 9023cfa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/backends/compiler_wat/wir/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ func GetFnMangleName(v interface{}, mainPkg string) (internal string, external s
exported := true
switch f := v.(type) {
case *ssa.Function:
if recv := f.Signature.Recv(); recv != nil {
recv := f.Signature.Recv()
if recv == nil && f.Anonymous() && f.Parent().Signature != nil {
recv = f.Parent().Signature.Recv()
}
if recv != nil {
//if recv.Pkg().Path() != mainPkg {
// exported = false
//} else {
Expand Down
1 change: 1 addition & 0 deletions internal/ssa/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value {
Pkg: fn.Pkg,
Prog: fn.Prog,
syntax: e,
anonymous: true,
}
fn.AnonFuncs = append(fn.AnonFuncs, fn2)
b.buildFunction(fn2)
Expand Down
2 changes: 2 additions & 0 deletions internal/ssa/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ type Function struct {
namedResults []*Alloc // tuple of named results
targets *targets // linked stack of branch targets
lblocks map[*ast.Object]*lblock // labelled blocks
anonymous bool // true if this function is anonymous
}

// BasicBlock represents an SSA basic block.
Expand Down Expand Up @@ -1373,6 +1374,7 @@ func (v *Global) ForceRegister() bool {
return info.ForceRegister
}

func (v *Function) Anonymous() bool { return v.anonymous }
func (v *Function) Name() string { return v.name }
func (v *Function) Type() types.Type { return v.Signature }
func (v *Function) Pos() token.Pos { return v.pos }
Expand Down
1 change: 1 addition & 0 deletions wca/check-cla.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var wcaMap = map[string]bool{
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
"[email protected]": true,
}

func main() {
Expand Down

0 comments on commit 9023cfa

Please sign in to comment.