# HG changeset patch # User Mike Pavone # Date 1305699462 25200 # Node ID e769b2e0faccc066629afed33fe548f77cf8e0aa # Parent 926b56a43f47192986104908ddc6d6c8fa13445a Syntactic sugar for calling a value diff -r 926b56a43f47 -r e769b2e0facc parser_old_c.rhope --- a/parser_old_c.rhope Sun May 15 23:31:58 2011 -0700 +++ b/parser_old_c.rhope Tue May 17 23:17:42 2011 -0700 @@ -182,11 +182,12 @@ Uses Stores Input Types Output Types + Assigned } Parse Worker[name,inputs,outputs,intypes,outtypes,line:out] { - out <- [[[[[[[[Build[Parse Worker()]]Name <<[name]]Inputs <<[inputs]]Outputs <<[outputs]]Line Number <<[line]]Trees <<[()]]Uses Stores <<[()]]Input Types <<[intypes]]Output Types <<[outtypes] + out <- [[[[[[[[[Build[Parse Worker()]]Name <<[name]]Inputs <<[inputs]]Outputs <<[outputs]]Line Number <<[line]]Trees <<[()]]Uses Stores <<[()]]Input Types <<[intypes]]Output Types <<[outtypes]]Assigned <<[Dictionary[]] } Blueprint Worker Node @@ -203,6 +204,17 @@ out <- [[[[Build[Worker Node()]]Name <<[name]]Params <<[params]]Assignments <<[()]]Blocks <<[()] } +_Get Assigned Pipes[pipe dict,node:out] +{ + out <- [node]Get Assigned Pipes[pipe dict] +} + +Get Assigned Pipes[node,pipe dict:out] +{ + Fold[Set[?,?,Yes], pipe dict, [node]Assignments >>] + { out <- Fold[Fold[_Get Assigned Pipes[?], ?], ~, [node]Blocks >>] } +} + Add List Helper[inlist,worker,program,key,parse worker,refs:out list,out worker,out refs] { ,nextworker,nextrefs <- [[inlist]Index[key]]Add to Worker[worker, program, parse worker, refs] @@ -271,7 +283,18 @@ } } }{ - Print[["Error: Could not find a worker named "]Append[[node]Name >>]] + make call <- [[parse worker]Assigned >>]Index[[node]Name >>] {} + { + make call <- [[parse worker]Inputs >>]Find[=[?,[node]Name >>]] {} + { + Print[["Error: Could not find a worker named "]Append[[node]Name >>]] + } + } + Val[make call] + { + new params <- Fold[Append[?], [()]Append[Named Pipe Node[[node]Name >>]], [node]Params >>] + out node, out worker, out refs <- [[[node]Params <<[new params]]Name <<["Call"]]Add to Worker[worker, program, parse worker, refs] + } } } @@ -1537,7 +1560,8 @@ ]Library <<[ [[worker]Trees >>]Name >> ] }{ - trees, nworker, refs <- Add List to Worker[[worker]Trees >>, [[NWorker["rhope"]]Uses[[worker]Uses Stores >>]]Outputs <<[ [worker]Outputs >> ], prog, worker, Dictionary[]] + assigned <- Fold[_Get Assigned Pipes[?], Dictionary[], [worker]Trees >>] + trees, nworker, refs <- Add List to Worker[[worker]Trees >>, [[NWorker["rhope"]]Uses[[worker]Uses Stores >>]]Outputs <<[ [worker]Outputs >> ], prog, [worker]Assigned <<[assigned], Dictionary[]] { final nworker <- Fold[Add Wires Helper[?, ?, ?, worker, refs], nworker, trees] }