-
-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathexpr.go
187 lines (160 loc) · 2.99 KB
/
expr.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package ast
import (
"reflect"
)
// Expr provides all of interfaces for expression.
type Expr interface {
Pos
}
// ExprImpl provide commonly implementations for Expr.
type ExprImpl struct {
PosImpl // PosImpl provide Pos() function.
}
// OpExpr provide operator expression.
type OpExpr struct {
ExprImpl
Op Operator
}
// LiteralExpr provide literal expression.
type LiteralExpr struct {
ExprImpl
Literal reflect.Value
}
// ArrayExpr provide Array expression.
type ArrayExpr struct {
ExprImpl
Exprs []Expr
TypeData *TypeStruct
}
// MapExpr provide Map expression.
type MapExpr struct {
ExprImpl
Keys []Expr
Values []Expr
TypeData *TypeStruct
}
// IdentExpr provide identity expression.
type IdentExpr struct {
ExprImpl
Lit string
}
// UnaryExpr provide unary minus expression. ex: -1, ^1, ~1.
type UnaryExpr struct {
ExprImpl
Operator string
Expr Expr
}
// AddrExpr provide referencing address expression.
type AddrExpr struct {
ExprImpl
Expr Expr
}
// DerefExpr provide dereferencing address expression.
type DerefExpr struct {
ExprImpl
Expr Expr
}
// ParenExpr provide parent block expression.
type ParenExpr struct {
ExprImpl
SubExpr Expr
}
// NilCoalescingOpExpr provide if invalid operator expression.
type NilCoalescingOpExpr struct {
ExprImpl
LHS Expr
RHS Expr
}
// TernaryOpExpr provide ternary operator expression.
type TernaryOpExpr struct {
ExprImpl
Expr Expr
LHS Expr
RHS Expr
}
// CallExpr provide calling expression.
type CallExpr struct {
ExprImpl
Func reflect.Value
Name string
SubExprs []Expr
VarArg bool
Go bool
}
// AnonCallExpr provide anonymous calling expression. ex: func(){}().
type AnonCallExpr struct {
ExprImpl
Expr Expr
SubExprs []Expr
VarArg bool
Go bool
}
// MemberExpr provide expression to refer member.
type MemberExpr struct {
ExprImpl
Expr Expr
Name string
}
// ItemExpr provide expression to refer Map/Array item.
type ItemExpr struct {
ExprImpl
Item Expr
Index Expr
}
// SliceExpr provide expression to refer slice of Array.
type SliceExpr struct {
ExprImpl
Item Expr
Begin Expr
End Expr
Cap Expr
}
// FuncExpr provide function expression.
type FuncExpr struct {
ExprImpl
Name string
Stmt Stmt
Params []string
VarArg bool
}
// LetsExpr provide multiple expression of let.
type LetsExpr struct {
ExprImpl
LHSS []Expr
RHSS []Expr
}
// ChanExpr provide chan expression.
type ChanExpr struct {
ExprImpl
LHS Expr
RHS Expr
}
// ImportExpr provide expression to import packages.
type ImportExpr struct {
ExprImpl
Name Expr
}
// MakeExpr provide expression to make instance.
type MakeExpr struct {
ExprImpl
TypeData *TypeStruct
LenExpr Expr
CapExpr Expr
}
// MakeTypeExpr provide expression to make type.
type MakeTypeExpr struct {
ExprImpl
Name string
Type Expr
}
// LenExpr provide expression to get length of array, map, etc.
type LenExpr struct {
ExprImpl
Expr Expr
}
// IncludeExpr provide in expression
type IncludeExpr struct {
ExprImpl
ItemExpr Expr
ListExpr Expr
}