1
2
3
4
5 package types2
6
7
8 type BasicKind int
9
10 const (
11 Invalid BasicKind = iota
12
13
14 Bool
15 Int
16 Int8
17 Int16
18 Int32
19 Int64
20 Uint
21 Uint8
22 Uint16
23 Uint32
24 Uint64
25 Uintptr
26 Float32
27 Float64
28 Complex64
29 Complex128
30 String
31 UnsafePointer
32
33
34 UntypedBool
35 UntypedInt
36 UntypedRune
37 UntypedFloat
38 UntypedComplex
39 UntypedString
40 UntypedNil
41
42
43 Byte = Uint8
44 Rune = Int32
45 )
46
47
48 type BasicInfo int
49
50
51 const (
52 IsBoolean BasicInfo = 1 << iota
53 IsInteger
54 IsUnsigned
55 IsFloat
56 IsComplex
57 IsString
58 IsUntyped
59
60 IsOrdered = IsInteger | IsFloat | IsString
61 IsNumeric = IsInteger | IsFloat | IsComplex
62 IsConstType = IsBoolean | IsNumeric | IsString
63 )
64
65
66 type Basic struct {
67 kind BasicKind
68 info BasicInfo
69 name string
70 }
71
72
73 func (b *Basic) Kind() BasicKind { return b.kind }
74
75
76 func (b *Basic) Info() BasicInfo { return b.info }
77
78
79 func (b *Basic) Name() string { return b.name }
80
81 func (b *Basic) Underlying() Type { return b }
82 func (b *Basic) String() string { return TypeString(b, nil) }
83
View as plain text