diff nworker.rhope @ 110:336da6ce8174

Merge
author Mike Pavone <pavone@retrodev.com>
date Wed, 06 Oct 2010 23:48:32 +0000
parents 43cc42df26cc
children
line wrap: on
line diff
--- a/nworker.rhope	Wed Oct 06 23:47:26 2010 +0000
+++ b/nworker.rhope	Wed Oct 06 23:48:32 2010 +0000
@@ -492,9 +492,27 @@
 	out,node index <- [worker]Add Typed Input[name,number,Type Instance["Any Type"]]
 }
 
+Add Anon Input@NWorker[worker,number:out]
+{
+	If[[number]>[Length[[worker]Inputs >>]]]
+	{
+		prepped <- [worker]Add Anon Input[[number]-[1]]
+	}{
+		prepped <- Val[worker]
+	}
+	out <- out <- [[prepped]Inputs <<[[[prepped]Inputs >>]Set[number,[" unnamed"]Append[number]]]
+		]Input Types <<[[[prepped]Input Types >>]Set[number,Type Instance["Any Type"]]]
+}
+
 Add Typed Input@NWorker[worker,name,number,type:out,node index]
 {
-	,node index <- [worker]Add Node["input",number,0,1]
+	If[[number]>[Length[[worker]Inputs >>]]]
+	{
+		prepped <- [worker]Add Anon Input[[number]-[1]]
+	}{
+		prepped <- Val[worker]
+	}
+	,node index <- [prepped]Add Node["input",number,0,1]
 	{ 
 		out <- [[~]Inputs <<[[[~]Inputs >>]Set[number,name]]
 		]Input Types <<[[[~]Input Types >>]Set[number,type]]
@@ -873,7 +891,7 @@
 				[conditions]For Backend
 				{
 					stream <- [[withconst]Instruction Stream
-						]Move[Constant[constname], [[["__result_"]Append[node index]]Append["_"]]Append[0]]
+						]Move[Strip Addref[Constant[constname]], [[["__result_"]Append[node index]]Append["_"]]Append[0]]
 					nfunc <- [withconst]Do If[~, stream]
 				}{
 					nfunc <- Val[withconst]
@@ -943,8 +961,7 @@
 
 Release Var@NWorker[worker,func,name:out]
 {
-	//_result_index_ionum
-	Print[["Release Var@NWorker: "]Append[name]]
+	//__result_index_ionum
 	parts <- [name]Split["_"]
 	index <- <String@Whole Number[ [parts]Index[3] ]
 	io num <- <String@Whole Number[ [parts]Index[4] ]
@@ -954,25 +971,27 @@
 		Print["oops"]
 		{ Pretty Print[node, ""] 
 		{ Pretty Print[parts, ""]}} }
-	If[[[dests]Length] = [1]]
-	{
-		Print["Single dest, maybe release"]
-		{ Print[["Dest index: "]Append[dest index]] }
-		dest index <- [[dests]Index[0]]Index >>
-		dest node <- [[worker]Nodes >>]Index[dest index]
-		{ Print["got dest node"] }
-		
-		[[dest node]Conditions >>]For Backend
+	,normal <- If[[[dests]Length] = [1]]
+	{	
+		dest ionum <- [[dests]Index[0]]IO Num >>
+		If[[[[dests]Index[0]]IO Num >>]=[-1]]
 		{
-			Print["dest has conditions"]
-			out <- [func]Do If[AndCond[NotCond[~], name],  [[func]Instruction Stream]Release[name]]
-			{ Print["got output"] }
+			normal <- Yes
 		}{
-			Print["No conditions on dest, no release needed"]
-			out <- func
+			dest index <- [[dests]Index[0]]Index >>
+			dest node <- [[worker]Nodes >>]Index[dest index]
+		
+			[[dest node]Conditions >>]For Backend
+			{
+				out <- [func]Do If[AndCond[NotCond[~], name],  [[func]Instruction Stream]Release[name]]
+			}{
+				out <- func
+			}
 		}
-	}{
-		Print["Multiple (or zero) dests, definitely release"]
+	}
+	
+	Val[normal]
+	{
 		do if <- If[[[node]Outputs >>] > [1]] {}
 		{
 			do if <- [[node]Conditions >>]Empty? {}
@@ -1079,6 +1098,27 @@
 	}
 }
 
+Release Raw Inputs[func,input type,index,inputs,outputs:out]
+{
+	If[[[input type]Variant >>] = ["Raw Pointer"]]
+	{
+		name <- [inputs]Index[index]
+		If[[input type]Mutable? >>]
+		{
+			[outputs]Find[[inputs]Index[index]]
+			{
+				out <- func
+			}{
+				out <- [func]Release[name]	
+			}
+		}{
+			out <- [func]Release[name]
+		}
+	}{
+		out <- func
+	}
+}
+
 FParams[input:out]
 {
 	iname <- [input]Index[0]
@@ -1161,8 +1201,9 @@
 	
 	Fold[["FInputs"]Set Input[3, [worker]Inputs >>], rfunc, [worker]Input Types >>]
 	{ [~]Call Foreign[name, [worker]Convention >>, Map[Zip[[worker]Inputs >>, [worker]Input Types >>], "FParams"], rparam]
+	{ Fold[[["Release Raw Inputs"]Set Input[3, [worker]Inputs >>]]Set Input[4, [worker]Outputs >>], ~, [worker]Input Types >>]
 	{ Fold[[[["Save Foreign Result"]Set Input[3, [worker]Output Types >>]]Set Input[4, [worker]Inputs >>]]Set Input[5, [worker]Input Types >>], ~, [worker]Outputs >>]
-	{ out <- [program]Store Function[~] }}}
+	{ out <- [program]Store Function[~] }}}}
 }		
 
 Compile Worker@NWorker[worker,program,name:out]