Mercurial > repos > rhope
comparison nworker.rhope @ 19:90c20dc3f4e5
Initial work on compiling dataflow graphs to a backend
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 27 May 2009 21:29:15 +0000 |
parents | 73e978d590c7 |
children | b715532225c0 |
comparison
equal
deleted
inserted
replaced
18:ea991f95ae1f | 19:90c20dc3f4e5 |
---|---|
1 Import extendlib.rhope | 1 Import extendlib.rhope |
2 | |
3 Blueprint Range | |
4 { | |
5 Start | |
6 Stop | |
7 } | |
8 | |
9 Range[start,stop:out] | |
10 { | |
11 out <- [[Build["Range"]]Start <<[start]]Stop <<[stop] | |
12 } | |
13 | |
14 First@Range[range:first,none] | |
15 { | |
16 If[[[range]Start >>] < [[range]Stop >>]] | |
17 { | |
18 first <- [range]Start >> | |
19 }{ | |
20 none <- range | |
21 } | |
22 } | |
23 | |
24 Next@Range[range,current:next,none] | |
25 { | |
26 pnext <- [current]+[1] | |
27 If[[pnext] < [[range]Stop >>]] | |
28 { | |
29 next <- Val[pnext] | |
30 }{ | |
31 none <- range | |
32 } | |
33 } | |
34 | |
35 Index@Range[range,index:val,none] | |
36 { | |
37 val <- index | |
38 } | |
39 | 2 |
40 Set@Range[range,index,val:out] | 3 Set@Range[range,index,val:out] |
41 { | 4 { |
42 out <- [[()]Concatenate[range] | 5 out <- [[()]Concatenate[range] |
43 ]Set[index,val] | 6 ]Set[index,val] |
141 { | 104 { |
142 Convention | 105 Convention |
143 Nodes | 106 Nodes |
144 Inputs | 107 Inputs |
145 Outputs | 108 Outputs |
109 NodeResults | |
110 Free Temps | |
146 } | 111 } |
147 | 112 |
148 NWorker[convention:out] | 113 NWorker[convention:out] |
149 { | 114 { |
150 out <- [[[[Build["NWorker"]]Convention <<[convention]]Nodes <<[()]]Inputs <<[()]]Outputs <<[()] | 115 out <- [[[[Build["NWorker"]]Convention <<[convention]]Nodes <<[()]]Inputs <<[()]]Outputs <<[()] |
278 } | 243 } |
279 Dependency Groups@NWorker[worker:out] | 244 Dependency Groups@NWorker[worker:out] |
280 { | 245 { |
281 no deps <- [worker]No Dependencies | 246 no deps <- [worker]No Dependencies |
282 out <- [worker]_Dependency Groups[no deps, no deps, [()]Append[no deps]] | 247 out <- [worker]_Dependency Groups[no deps, no deps, [()]Append[no deps]] |
248 } | |
249 | |
250 Compile Node@NWorker[worker,program,func,nodes,current:out] | |
251 { | |
252 node <- [[worker]Nodes >>]Index[[nodes]Index[current]] | |
253 If[[[node]Type >>] = [""]] | |
254 { | |
255 nfunc <- [func]Call[[[node]Data >>]Name >>, ()] | |
256 }{ | |
257 nfunc <- Val[func] | |
258 } | |
259 [nodes]Next[current] | |
260 { | |
261 out <- [worker]Compile Node[program,func,nodes,~] | |
262 }{ | |
263 out <- Val[nfunc] | |
264 } | |
265 } | |
266 | |
267 Compile Group@NWorker[worker,program,func,groups,current:out] | |
268 { | |
269 nodes <- [groups]Index[current] | |
270 [nodes]First | |
271 { | |
272 nfunc <- [worker]Compile Node[program,func,nodes,~] | |
273 }{ | |
274 nfunc <- Val[func] | |
275 } | |
276 [groups]Next[current] | |
277 { | |
278 out <- [worker]Compile Group[program,func,groups,~] | |
279 }{ | |
280 out <- Val[nfunc] | |
281 } | |
282 } | |
283 | |
284 Compile Worker@NWorker[worker,program,name:out] | |
285 { | |
286 func <- [program]Create Function[name,[worker]Inputs >>, [worker]Outputs >>, [worker]Convention >>] | |
287 groups <- [worker]Dependency Groups | |
288 [groups]First | |
289 { | |
290 final func <- [worker]Compile Group[program,func,groups, ~] | |
291 }{ | |
292 final func <- Val[func] | |
293 } | |
294 out <- [program]Store Function[func] | |
283 } | 295 } |
284 | 296 |
285 Test[:out] | 297 Test[:out] |
286 { | 298 { |
287 ref+ <- Worker Ref["+","cdecl",2,1] | 299 ref+ <- Worker Ref["+","cdecl",2,1] |