Mercurial > repos > rhope
diff 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 |
line wrap: on
line diff
--- a/nworker.rhope Wed May 27 04:49:32 2009 -0400 +++ b/nworker.rhope Wed May 27 21:29:15 2009 +0000 @@ -1,42 +1,5 @@ Import extendlib.rhope -Blueprint Range -{ - Start - Stop -} - -Range[start,stop:out] -{ - out <- [[Build["Range"]]Start <<[start]]Stop <<[stop] -} - -First@Range[range:first,none] -{ - If[[[range]Start >>] < [[range]Stop >>]] - { - first <- [range]Start >> - }{ - none <- range - } -} - -Next@Range[range,current:next,none] -{ - pnext <- [current]+[1] - If[[pnext] < [[range]Stop >>]] - { - next <- Val[pnext] - }{ - none <- range - } -} - -Index@Range[range,index:val,none] -{ - val <- index -} - Set@Range[range,index,val:out] { out <- [[()]Concatenate[range] @@ -143,6 +106,8 @@ Nodes Inputs Outputs + NodeResults + Free Temps } NWorker[convention:out] @@ -282,6 +247,53 @@ out <- [worker]_Dependency Groups[no deps, no deps, [()]Append[no deps]] } +Compile Node@NWorker[worker,program,func,nodes,current:out] +{ + node <- [[worker]Nodes >>]Index[[nodes]Index[current]] + If[[[node]Type >>] = [""]] + { + nfunc <- [func]Call[[[node]Data >>]Name >>, ()] + }{ + nfunc <- Val[func] + } + [nodes]Next[current] + { + out <- [worker]Compile Node[program,func,nodes,~] + }{ + out <- Val[nfunc] + } +} + +Compile Group@NWorker[worker,program,func,groups,current:out] +{ + nodes <- [groups]Index[current] + [nodes]First + { + nfunc <- [worker]Compile Node[program,func,nodes,~] + }{ + nfunc <- Val[func] + } + [groups]Next[current] + { + out <- [worker]Compile Group[program,func,groups,~] + }{ + out <- Val[nfunc] + } +} + +Compile Worker@NWorker[worker,program,name:out] +{ + func <- [program]Create Function[name,[worker]Inputs >>, [worker]Outputs >>, [worker]Convention >>] + groups <- [worker]Dependency Groups + [groups]First + { + final func <- [worker]Compile Group[program,func,groups, ~] + }{ + final func <- Val[func] + } + out <- [program]Store Function[func] +} + Test[:out] { ref+ <- Worker Ref["+","cdecl",2,1] @@ -299,4 +311,4 @@ ]Add Wire[c,0,call*,1] ]Add Wire[call*,0,outref,0] }}}}}} -} \ No newline at end of file +}