Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg.NewFuncDecl doc #429

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions func.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (p *Func) End(cb *CodeBuilder, src ast.Node) {
}
}

// NewFuncDecl creates a new function without function body (declaration only).
func (p *Package) NewFuncDecl(pos token.Pos, name string, sig *types.Signature) *Func {
f, err := p.NewFuncWith(pos, name, sig, nil)
if err != nil {
Expand All @@ -142,7 +143,7 @@ func (p *Package) NewFuncDecl(pos token.Pos, name string, sig *types.Signature)
return f
}

// NewFunc func
// NewFunc creates a new function (should have a function body).
func (p *Package) NewFunc(recv *Param, name string, params, results *Tuple, variadic bool) *Func {
sig := types.NewSignatureType(recv, nil, nil, params, results, variadic)
f, err := p.NewFuncWith(token.NoPos, name, sig, nil)
Expand All @@ -159,7 +160,7 @@ func getRecv(recvTypePos func() token.Pos) token.Pos {
return token.NoPos
}

// NewFuncWith func
// NewFuncWith creates a new function (should have a function body).
func (p *Package) NewFuncWith(
pos token.Pos, name string, sig *types.Signature, recvTypePos func() token.Pos) (*Func, error) {
if name == "" {
Expand Down
Loading