-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUdependencies.go
204 lines (179 loc) · 7.02 KB
/
Udependencies.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package dLola
/*import (
"fmt"
)*/
func getUdependencies(stream InstStreamExpr, adjacencies []Adj, uExpr InstExpr) []InstStreamExpr {
r := make([]InstStreamExpr, 0)
if len(adjacencies) > 0 {
depen := make(map[InstStreamExpr]struct{})
uExpr.Udependencies(adjacencies, depen)
for stream, _ := range depen {
r = append(r, stream)
}
}
return r
}
//Simplify
func (this InstConstExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstLetExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstIfThenElseExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.If.Udependencies(adj, depen)
}
if len(adj) != len(depen) {
this.Then.Udependencies(adj, depen)
}
if len(adj) != len(depen) {
this.Else.Udependencies(adj, depen)
}
}
func (this InstStreamOffsetExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
this.SExpr.Udependencies(adj, depen)
}
func (this InstBooleanExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.BExpr.UdependenciesBool(adj, depen)
}
}
func (this InstNumericExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.NExpr.UdependenciesNum(adj, depen)
}
}
func (this InstStringExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.StExpr.UdependenciesStr(adj, depen)
}
}
//Boolean
func (this InstTruePredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstFalsePredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstNotPredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.Inner.UdependenciesBool(adj, depen)
}
}
func (this InstStreamOffsetExpr) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.SExpr.Udependencies(adj, depen)
}
}
func (this InstConstExpr) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstAndPredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpBoolDependencies(this.Left, this.Right, adj, depen)
}
func (this InstOrPredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpBoolDependencies(this.Left, this.Right, adj, depen)
}
/*func (this InstIfThenElsePredicate) InstantiateBoolExpr(tick, tlen int) InstBoolExpr {
return InstIfThenElsePredicate{this.If.Simplify(), this.Then.Simplify(), this.Else.Simplify()}
}*/
func (this InstNumComparisonPredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
this.Comp.UdependenciesNumComp(adj, depen)
}
func (this InstStrComparisonPredicate) UdependenciesBool(adj []Adj, depen map[InstStreamExpr]struct{}) {
this.Comp.UdependenciesStrComp(adj, depen)
}
//Stream
func (this InstStreamFetchExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
depen[this] = struct{}{}
}
}
//Num
func (this InstNumLess) UdependenciesNumComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumLessEq) UdependenciesNumComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumGreater) UdependenciesNumComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumGreaterEq) UdependenciesNumComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumEq) UdependenciesNumComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumNotEq) UdependenciesNumComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstIntLiteralExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstFloatLiteralExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstNumMulExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumDivExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumPlusExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstNumMinusExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpNumDependencies(this.Left, this.Right, adj, depen)
}
func (this InstStreamOffsetExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
this.SExpr.Udependencies(adj, depen)
}
func (this InstConstExpr) UdependenciesNum(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
//String
func (this InstStringLiteralExpr) UdependenciesStr(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstStrConcatExpr) UdependenciesStr(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpStrDependencies(this.Left, this.Right, adj, depen)
}
func (this InstStreamOffsetExpr) UdependenciesStr(adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
this.SExpr.Udependencies(adj, depen)
}
}
func (this InstConstExpr) UdependenciesStr(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstStrEqExpr) UdependenciesStrComp(adj []Adj, depen map[InstStreamExpr]struct{}) {
binaryOpStrDependencies(this.Left, this.Right, adj, depen)
}
//Literals need to implement InstExpr to compile, implementation of Simplify (should not be needed at runtime)
//will be used as the result value of the expression, note they are InstExpr, not the corresponding subtype
func (this InstTruePredicate) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstFalsePredicate) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstIntLiteralExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstFloatLiteralExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func (this InstStringLiteralExpr) Udependencies(adj []Adj, depen map[InstStreamExpr]struct{}) {
}
func binaryOpBoolDependencies(l, r InstBoolExpr, adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
l.UdependenciesBool(adj, depen)
}
if len(adj) != len(depen) {
r.UdependenciesBool(adj, depen)
}
}
func binaryOpNumDependencies(l, r InstNumExpr, adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
l.UdependenciesNum(adj, depen)
}
if len(adj) != len(depen) {
r.UdependenciesNum(adj, depen)
}
}
func binaryOpStrDependencies(l, r InstStrExpr, adj []Adj, depen map[InstStreamExpr]struct{}) {
if len(adj) != len(depen) {
l.UdependenciesStr(adj, depen)
}
if len(adj) != len(depen) {
r.UdependenciesStr(adj, depen)
}
}