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