-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtypes_func.go
60 lines (50 loc) · 902 Bytes
/
types_func.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package gotype
import (
"bytes"
)
type typeFunc struct {
typeBase
variadic bool
params types
results types
}
func (t *typeFunc) String() string {
buf := bytes.NewBuffer(nil)
buf.WriteString("func(")
for i, v := range t.params {
if i != 0 {
buf.WriteString(", ")
}
buf.WriteString(v.String())
}
if t.variadic {
buf.WriteString("...")
}
buf.WriteString(") (")
for i, v := range t.results {
if i != 0 {
buf.WriteString(", ")
}
buf.WriteString(v.String())
}
buf.WriteString(")")
return buf.String()
}
func (t *typeFunc) Kind() Kind {
return Func
}
func (t *typeFunc) NumOut() int {
return t.results.Len()
}
func (t *typeFunc) Out(i int) Type {
return t.results.Index(i)
}
func (t *typeFunc) NumIn() int {
return t.params.Len()
}
func (t *typeFunc) In(i int) Type {
return t.params.Index(i)
}
func (t *typeFunc) IsVariadic() bool {
return t.variadic
}