This commit is contained in:
parent
3717a61414
commit
320e023d74
9 changed files with 45 additions and 21 deletions
|
@ -12,9 +12,14 @@ func TestFunction(t *testing.T) {
|
|||
b := build.New("../../examples/hello")
|
||||
env, err := compiler.Compile(b)
|
||||
assert.Nil(t, err)
|
||||
|
||||
main, exists := env.Functions["main.main"]
|
||||
assert.True(t, exists)
|
||||
assert.False(t, main.IsExtern())
|
||||
assert.Equal(t, main.UniqueName, "main.main")
|
||||
assert.Equal(t, main.String(), main.UniqueName)
|
||||
|
||||
write, exists := env.Functions["io.write"]
|
||||
assert.True(t, exists)
|
||||
write.Output[0].Type()
|
||||
}
|
|
@ -7,22 +7,12 @@ import (
|
|||
|
||||
// Parameter is an input or output parameter in a function.
|
||||
type Parameter struct {
|
||||
name string
|
||||
typ types.Type
|
||||
tokens token.List
|
||||
Name string
|
||||
TypeTokens token.List
|
||||
typ types.Type
|
||||
}
|
||||
|
||||
// NewParameter creates a new parameter with the given list of tokens.
|
||||
func NewParameter(tokens token.List) *Parameter {
|
||||
return &Parameter{tokens: tokens}
|
||||
}
|
||||
|
||||
// Name returns the name of the parameter.
|
||||
func (p *Parameter) Name() string {
|
||||
return p.name
|
||||
}
|
||||
|
||||
// Type returns the type of the parameter.
|
||||
// Type returns the data type of the parameter.
|
||||
func (p *Parameter) Type() types.Type {
|
||||
return p.typ
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue