This commit is contained in:
parent
fe3212506d
commit
ed6ae1d306
4 changed files with 37 additions and 32 deletions
|
@ -9,18 +9,20 @@ import (
|
|||
|
||||
// Function is the smallest unit of code.
|
||||
type Function struct {
|
||||
name string
|
||||
file *fs.File
|
||||
Input []*Parameter
|
||||
Output []*Parameter
|
||||
Body token.List
|
||||
Name string
|
||||
UniqueName string
|
||||
File *fs.File
|
||||
Input []*Parameter
|
||||
Output []*Parameter
|
||||
Body token.List
|
||||
}
|
||||
|
||||
// NewFunction creates a new function.
|
||||
func NewFunction(name string, file *fs.File) *Function {
|
||||
return &Function{
|
||||
name: name,
|
||||
file: file,
|
||||
Name: name,
|
||||
File: file,
|
||||
UniqueName: fmt.Sprintf("%s.%s", file.Package, name),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,16 +31,7 @@ func (f *Function) IsExtern() bool {
|
|||
return f.Body == nil
|
||||
}
|
||||
|
||||
// ResolveTypes parses the input and output types.
|
||||
func (f *Function) ResolveTypes() error {
|
||||
for _, param := range f.Input {
|
||||
param.name = param.tokens[0].String(f.file.Bytes)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// String returns the package and function name.
|
||||
// String returns the unique name.
|
||||
func (f *Function) String() string {
|
||||
return fmt.Sprintf("%s.%s", f.file.Package, f.name)
|
||||
return f.UniqueName
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue