-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtypes_declaration.go
More file actions
46 lines (39 loc) · 810 Bytes
/
types_declaration.go
File metadata and controls
46 lines (39 loc) · 810 Bytes
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
package gotype
func newDeclaration(name string, typ Type) Type {
return &typeDeclaration{
name: name,
declaration: typ,
}
}
type typeDeclaration struct {
typeBase
declaration Type
name string
}
func (t *typeDeclaration) String() string {
if t.declaration.NumTypeParam() > 0 {
// Build string with type parameters
s := t.name + "["
for i := 0; i < t.declaration.NumTypeParam(); i++ {
if i > 0 {
s += ", "
}
s += t.declaration.TypeParam(i).String()
}
s += "]"
return s
}
return t.name
}
func (t *typeDeclaration) Name() string {
return t.name
}
func (t *typeDeclaration) Kind() Kind {
return Declaration
}
func (t *typeDeclaration) Declaration() Type {
return t.declaration
}
func (t *typeDeclaration) Value() string {
return t.declaration.Value()
}