Mercurial > repos > rhope
comparison backendutils_c.rhope @ 178:ed322ae64738
Detect duplicates in conditions
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 15 Jun 2011 01:18:28 -0700 |
parents | fd06fb07762a |
children |
comparison
equal
deleted
inserted
replaced
177:e57c151f351e | 178:ed322ae64738 |
---|---|
11 }{ | 11 }{ |
12 out <- Val[escaped] | 12 out <- Val[escaped] |
13 } | 13 } |
14 } | 14 } |
15 | 15 |
16 Blueprint Make Op Res | |
17 { | |
18 Func | |
19 Val | |
20 } | |
21 | |
22 Make Op Res[func,val:out] | |
23 { | |
24 out <- [[Build[Make Op Res()]]Func <<[func]]Val <<[val] | |
25 } | |
26 | |
27 Make Op Mod[func,val:out func,out val] | |
28 { | |
29 nval <- [val]Make Op[func] | |
30 If[[Blueprint Of[nval]]=[Make Op Res()]] | |
31 { | |
32 out func <- Func >>[nval] | |
33 out val <- Val >>[nval] | |
34 }{ | |
35 out func <- func | |
36 out val <- Val[nval] | |
37 } | |
38 } | |
39 | |
16 Blueprint AddRef | 40 Blueprint AddRef |
17 { | 41 { |
18 Value | 42 Value |
19 } | 43 } |
20 | 44 |
31 Strip Addref@AddRef[op:out] | 55 Strip Addref@AddRef[op:out] |
32 { | 56 { |
33 out <- [[op]Value >>]Strip Addref | 57 out <- [[op]Value >>]Strip Addref |
34 } | 58 } |
35 | 59 |
60 =@AddRef[a,b(AddRef):out] | |
61 { | |
62 out <- [[a]Value >>]==[[b]Value >>] | |
63 } | |
64 | |
36 Make Op@String[string,func:out] | 65 Make Op@String[string,func:out] |
37 { | 66 { |
38 out <- [func]Resolve[string] | 67 out <- [func]Resolve[string] |
39 } | 68 } |
40 | 69 |
76 Get Type@String Slice[op,func:out] | 105 Get Type@String Slice[op,func:out] |
77 { | 106 { |
78 out <- [func]Get Var Type[op] | 107 out <- [func]Get Var Type[op] |
79 } | 108 } |
80 | 109 |
81 Make Op@Whole Number[num,func:out] | |
82 { | |
83 out <- num | |
84 } | |
85 | |
86 Strip Addref@Whole Number[op:out] | |
87 { | |
88 out <- op | |
89 } | |
90 | |
91 Make Op@Real Number[num,func:out] | |
92 { | |
93 out <- num | |
94 } | |
95 | |
96 Strip Addref@Real Number[op:out] | |
97 { | |
98 out <- op | |
99 } | |
100 | |
101 Blueprint Output | 110 Blueprint Output |
102 { | 111 { |
103 Name | 112 Name |
104 } | 113 } |
105 | 114 |
115 | 124 |
116 Strip Addref@Output[op:out] | 125 Strip Addref@Output[op:out] |
117 { | 126 { |
118 out <- op | 127 out <- op |
119 } | 128 } |
129 | |
130 =@Output[a,b(Output):out] | |
131 { | |
132 out <- [[a]Name >>]=[[b]Name >>] | |
133 } | |
134 | |
120 | 135 |
121 Blueprint Constant | 136 Blueprint Constant |
122 { | 137 { |
123 Value | 138 Value |
124 Need Addref | 139 Need Addref |
142 Strip Addref@Constant[op:out] | 157 Strip Addref@Constant[op:out] |
143 { | 158 { |
144 out <- [op]Need Addref <<[No] | 159 out <- [op]Need Addref <<[No] |
145 } | 160 } |
146 | 161 |
162 =@Constant[a,b(Constant):out] | |
163 { | |
164 out <- [[a]Value >>]=[[b]Value >>] | |
165 } | |
166 | |
147 Blueprint Result | 167 Blueprint Result |
148 { | 168 { |
149 Output Num | 169 Output Num |
150 } | 170 } |
151 | 171 |
160 } | 180 } |
161 | 181 |
162 Strip Addref@Result[op:out] | 182 Strip Addref@Result[op:out] |
163 { | 183 { |
164 out <- op | 184 out <- op |
185 } | |
186 | |
187 =@Result[a,b(Result):out] | |
188 { | |
189 out <- [[a]Output Num >>]=[[b]Output Num >>] | |
165 } | 190 } |
166 | 191 |
167 Blueprint Global Get | 192 Blueprint Global Get |
168 { | 193 { |
169 Store | 194 Store |
183 Strip Addref@Global Get[get:out] | 208 Strip Addref@Global Get[get:out] |
184 { | 209 { |
185 out <- get | 210 out <- get |
186 } | 211 } |
187 | 212 |
213 =@Global Get[a,b(Global Get):out] | |
214 { | |
215 ,out <- If[[[a]Store >>]=[[b]Store >>]] | |
216 { | |
217 out <- [[a]Var >>]=[[b]Var >>] | |
218 } | |
219 } | |
220 | |
188 Blueprint Check Result | 221 Blueprint Check Result |
189 { | 222 { |
190 Output Num | 223 Output Num |
191 } | 224 } |
192 | 225 |
211 { | 244 { |
212 out <- OrCond[Make Condition[[op]Left >>], Make Condition[[op]Right >>]] | 245 out <- OrCond[Make Condition[[op]Left >>], Make Condition[[op]Right >>]] |
213 }{ | 246 }{ |
214 out <- op | 247 out <- op |
215 } | 248 } |
249 } | |
250 | |
251 =@Check Result[a,b(Check Result):out] | |
252 { | |
253 out <- [[a]Output Num >>]=[[b]Output Num >>] | |
216 } | 254 } |
217 | 255 |
218 Blueprint OrValue | 256 Blueprint OrValue |
219 { | 257 { |
220 Left | 258 Left |
221 Right | 259 Right |
222 } | 260 } |
223 | 261 |
224 OrValue[left,right:out] | 262 OrValue[left,right:out] |
225 { | 263 { |
226 out <- [[Build[OrValue()]]Left <<[left]]Right <<[right] | 264 If[[left]==[right]] |
265 { | |
266 out <- left | |
267 }{ | |
268 out <- [[Build[OrValue()]]Left <<[left]]Right <<[right] | |
269 } | |
227 } | 270 } |
228 | 271 |
229 Make Op@OrValue[orval,func:out] | 272 Make Op@OrValue[orval,func:out] |
230 { | 273 { |
231 out <- [func]If Null Else[[orval]Left >>, [orval]Right >>] | 274 out <- [func]If Null Else[[orval]Left >>, [orval]Right >>] |
232 } | 275 } |
233 | 276 |
234 Strip Addref@OrValue[op:out] | 277 Strip Addref@OrValue[op:out] |
235 { | 278 { |
236 out <- [[op]Left <<[ [[op]Left >>]Strip Addref ]]Right <<[ [[op]Right >>]Strip Addref ] | 279 out <- [[op]Left <<[ [[op]Left >>]Strip Addref ]]Right <<[ [[op]Right >>]Strip Addref ] |
280 } | |
281 | |
282 =@OrValue[a,b(OrValue):out] | |
283 { | |
284 ,out <- If[[[a]Left >>]==[[b]Left >>]] | |
285 { | |
286 out <- [[a]Right >>]==[[b]Right >>] | |
287 } | |
237 } | 288 } |
238 | 289 |
239 Blueprint Cast | 290 Blueprint Cast |
240 { | 291 { |
241 Value | 292 Value |
255 Strip Addref@Cast[op:out] | 306 Strip Addref@Cast[op:out] |
256 { | 307 { |
257 out <- [op]Value <<[[[op]Value >>]Strip Addref] | 308 out <- [op]Value <<[[[op]Value >>]Strip Addref] |
258 } | 309 } |
259 | 310 |
311 =@Cast[a,b(Cast):out] | |
312 { | |
313 ,out <- If[[[a]Value >>] == [[b]Value >>]] | |
314 { | |
315 out <- [[a]Type >>]=[[b]Type >>] | |
316 } | |
317 } | |
318 | |
260 Blueprint NotCond | 319 Blueprint NotCond |
261 { | 320 { |
262 Condition | 321 Condition |
263 } | 322 } |
264 | 323 |
265 NotCond[cond:out] | 324 NotCond[cond:out] |
266 { | 325 { |
267 out <- [Build[NotCond()]]Condition <<[[cond]Strip Addref] | 326 If[[Blueprint Of[cond]]=[NotCond()]] |
327 { | |
328 out <- [cond]Condition >> | |
329 }{ | |
330 out <- [Build[NotCond()]]Condition <<[[cond]Strip Addref] | |
331 } | |
268 } | 332 } |
269 | 333 |
270 Make Op@NotCond[cond,func:out] | 334 Make Op@NotCond[cond,func:out] |
271 { | 335 { |
272 out <- ["!"]Append[[[cond]Condition >>]Make Op[func]] | 336 out <- ["!"]Append[[[cond]Condition >>]Make Op[func]] |
273 } | 337 } |
274 | 338 |
275 Strip Addref@NotCond[op:out] | 339 Strip Addref@NotCond[op:out] |
276 { | 340 { |
277 out <- op | 341 out <- op |
342 } | |
343 | |
344 =@NotCond[a,b(NotCond):out] | |
345 { | |
346 out <- [[a]Condition >>]==[[b]Condition >>] | |
278 } | 347 } |
279 | 348 |
280 Blueprint OrCond | 349 Blueprint OrCond |
281 { | 350 { |
282 Condition1 | 351 Condition1 |
283 Condition2 | 352 Condition2 |
284 } | 353 } |
285 | 354 |
286 OrCond[cond1,cond2:out] | 355 OrCond[cond1,cond2:out] |
287 { | 356 { |
288 out <- [[Build[OrCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] | 357 If[[cond1]==[cond2]] |
358 { | |
359 out <- cond1 | |
360 }{ | |
361 out <- [[Build[OrCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] | |
362 } | |
289 } | 363 } |
290 | 364 |
291 Make Op@OrCond[cond,func:out] | 365 Make Op@OrCond[cond,func:out] |
292 { | 366 { |
293 out <- ["("]Append[[[ [[cond]Condition1 >>]Make Op[func] ]Append[" || "]]Append[[ [[cond]Condition2 >>]Make Op[func] ]Append[")"]]] | 367 out <- ["("]Append[[[ [[cond]Condition1 >>]Make Op[func] ]Append[" || "]]Append[[ [[cond]Condition2 >>]Make Op[func] ]Append[")"]]] |
294 } | 368 } |
295 | 369 |
296 Strip Addref@OrCond[op:out] | 370 Strip Addref@OrCond[op:out] |
297 { | 371 { |
298 out <- op | 372 out <- op |
373 } | |
374 | |
375 =@OrCond[a,b(OrCond):out] | |
376 { | |
377 ,out <- If[[[a]Condition1 >>] == [[b]Condition1 >>]] | |
378 { | |
379 out <- [[a]Condition2 >>] == [[b]Condition2 >>] | |
380 } | |
299 } | 381 } |
300 | 382 |
301 Blueprint AndCond | 383 Blueprint AndCond |
302 { | 384 { |
303 Condition1 | 385 Condition1 |
304 Condition2 | 386 Condition2 |
305 } | 387 } |
306 | 388 |
307 AndCond[cond1,cond2:out] | 389 AndCond[cond1,cond2:out] |
308 { | 390 { |
309 out <- [[Build[AndCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] | 391 If[[cond1]==[cond2]] |
392 { | |
393 out <- cond1 | |
394 }{ | |
395 out <- [[Build[AndCond()]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] | |
396 } | |
310 } | 397 } |
311 | 398 |
312 Make Op@AndCond[cond,func:out] | 399 Make Op@AndCond[cond,func:out] |
313 { | 400 { |
314 out <- ["("]Append[[[ [[cond]Condition1 >>]Make Op[func] ]Append[" && "]]Append[[ [[cond]Condition2 >>]Make Op[func] ]Append[")"]]] | 401 out <- ["("]Append[[[ [[cond]Condition1 >>]Make Op[func] ]Append[" && "]]Append[[ [[cond]Condition2 >>]Make Op[func] ]Append[")"]]] |
315 } | 402 } |
316 | 403 |
317 Strip Addref@AndCond[op:out] | 404 Strip Addref@AndCond[op:out] |
318 { | 405 { |
319 out <- op | 406 out <- op |
407 } | |
408 | |
409 =@AndCond[a,b(AndCond):out] | |
410 { | |
411 ,out <- If[[[a]Condition1 >>] == [[b]Condition1 >>]] | |
412 { | |
413 out <- [[a]Condition2 >>] == [[b]Condition2 >>] | |
414 } | |
320 } | 415 } |
321 | 416 |
322 Blueprint Field Ref | 417 Blueprint Field Ref |
323 { | 418 { |
324 Variable | 419 Variable |
341 } | 436 } |
342 | 437 |
343 Strip Addref@Field Ref[op:out] | 438 Strip Addref@Field Ref[op:out] |
344 { | 439 { |
345 out <- op | 440 out <- op |
441 } | |
442 | |
443 =@Field Ref[a,b(Field Ref):out] | |
444 { | |
445 ,out <- If[[[a]Variable >>]==[[b]Variable >>]] | |
446 { | |
447 out <- [[a]Field >>]=[[b]Field >>] | |
448 } | |
346 } | 449 } |
347 | 450 |
348 Blueprint Type Instance | 451 Blueprint Type Instance |
349 { | 452 { |
350 Name | 453 Name |