changeset 173:e769b2e0facc

Syntactic sugar for calling a value
author Mike Pavone <pavone@retrodev.com>
date Tue, 17 May 2011 23:17:42 -0700
parents 926b56a43f47
children 0c7c5671fcd3
files parser_old_c.rhope
diffstat 1 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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]
 			}