...
1
2
3
4
5 package syntax
6
7 import "go/constant"
8
9
10
11
12
13
14 type Type interface {
15
16
17
18
19 Underlying() Type
20
21
22 String() string
23 }
24
25
26
27
28
29 type typeInfo interface {
30 SetTypeInfo(TypeAndValue)
31 GetTypeInfo() TypeAndValue
32 }
33
34
35
36
37
38
39 type TypeAndValue struct {
40 Type Type
41 Value constant.Value
42 exprFlags
43 }
44
45 type exprFlags uint16
46
47 func (f exprFlags) IsVoid() bool { return f&1 != 0 }
48 func (f exprFlags) IsType() bool { return f&2 != 0 }
49 func (f exprFlags) IsBuiltin() bool { return f&4 != 0 }
50 func (f exprFlags) IsValue() bool { return f&8 != 0 }
51 func (f exprFlags) IsNil() bool { return f&16 != 0 }
52 func (f exprFlags) Addressable() bool { return f&32 != 0 }
53 func (f exprFlags) Assignable() bool { return f&64 != 0 }
54 func (f exprFlags) HasOk() bool { return f&128 != 0 }
55 func (f exprFlags) IsRuntimeHelper() bool { return f&256 != 0 }
56
57 func (f *exprFlags) SetIsVoid() { *f |= 1 }
58 func (f *exprFlags) SetIsType() { *f |= 2 }
59 func (f *exprFlags) SetIsBuiltin() { *f |= 4 }
60 func (f *exprFlags) SetIsValue() { *f |= 8 }
61 func (f *exprFlags) SetIsNil() { *f |= 16 }
62 func (f *exprFlags) SetAddressable() { *f |= 32 }
63 func (f *exprFlags) SetAssignable() { *f |= 64 }
64 func (f *exprFlags) SetHasOk() { *f |= 128 }
65 func (f *exprFlags) SetIsRuntimeHelper() { *f |= 256 }
66
67
68
69 type typeAndValue struct {
70 tv TypeAndValue
71 }
72
73 func (x *typeAndValue) SetTypeInfo(tv TypeAndValue) {
74 x.tv = tv
75 }
76 func (x *typeAndValue) GetTypeInfo() TypeAndValue {
77 return x.tv
78 }
79
View as plain text