diff nworker.rhope @ 69:d0ce696786cc

Clean up debug print statements a bit. Fix bug that prevented workers that took no inputs from working. Remove workaround in Array for said bug.
author Mike Pavone <pavone@retrodev.com>
date Wed, 16 Jun 2010 04:36:08 +0000
parents d4b44ae2e34a
children 6a1a7d5cc2d9
line wrap: on
line diff
--- a/nworker.rhope	Mon Jun 07 15:36:04 2010 -0400
+++ b/nworker.rhope	Wed Jun 16 04:36:08 2010 +0000
@@ -57,18 +57,12 @@
 
 _For Backend Subset[current,subset,type:out]
 {
-	Print["Calling For Backend on subset"]
-	{
 	[subset]For Backend
 	{
-		Print["Got output from for backend"]
 		out <- [[<String@Worker[[type]Append["Cond"]]]Do[ [[()]Append[current]]Append[~] ]]Index[0]
-		{ Print["done _For Backend Subset with condition"] }
 	}{
-		Print["none output from for backend"]
 		out <- current
 	}
-	}
 }
 
 Empty?@Condition Set[set:not empty,empty]
@@ -115,37 +109,26 @@
 
 For Backend@Condition Set[set:out,none]
 {
-	Print["For Backend"]
 	firstvar <- [[set]Variables >>]First
 	{
-		Print["At least one var"]
 		[[set]Variables >>]Next[~]
 		{
-			Print["at least two vars"]
 			vars <- _Fold[[set]Variables >>, ~, firstvar, ["_For Backend Var"]Set Input[3, [set]Condition Type >>]]
 		}{
-			Print["just one var"]
 			vars <- Val[firstvar]
 		}
 		out <- Fold[["_For Backend Subset"]Set Input[2, [set]Condition Type >>], vars, [set]Subsets >>]
-		{ Print["done For Backend, with vars"] }
 	}{
-		Print["no vars"]
 		[[set]Subsets >>]First Non-empty Set
 		{
-			Print[["At least one non-empty subset: "]Append[~]]
 			firstsub <- [[[set]Subsets >>]Index[~]]For Backend
 			[[set]Subsets >>]Next[~]
 			{
-				Print["at least two subsets"]
 				out <- _Fold[[set]Subsets >>, ~, firstsub, ["_For Backend Subset"]Set Input[2, [set]Condition Type >>]]
-				{ Print["done with subsets, but no vars"] }
 			}{
 				out <- Val[firstsub]
-				{ Pretty Print[~, "1s:\t"] }
 			}
 		}{
-			Print["done with none"]
 			none <- Yes
 		}
 	}
@@ -464,9 +447,7 @@
 
 Infer Types@NWorker[worker,prog:out]
 {
-	Print[["Start inference: "]Append[[worker]Name >>]]
 	out <- [worker]Nodes <<[Fold[[["Infer Types Node"]Set Input[3, prog]]Set Input[4, worker], [worker]Nodes >>, [worker]Nodes >>]]
-	{ Print[["End inference: "]Append[[worker]Name >>]] }
 }
 
 Add Worker Call@NWorker[worker,tocall:out,node index]
@@ -519,17 +500,10 @@
 
 Add Wire@NWorker[worker,from,output,to,input:out]
 {
-	Print[[[[[[[[["Add Wire@NWorker["]Append[from]]Append[","]]Append[output]]Append[","]]Append[to]]Append[","]]Append[input]]Append["]"]]
-	{
 	fromw <- [[[worker]Nodes >>]Index[from]]Wire From[to,input,output]
-	{ Print["fromw"] }
 	tow <- [[[worker]Nodes >>]Index[to]]Wire To[from,output,input]
-	{ Print["tow"] }
 	nodes <- [[[worker]Nodes >>]Set[from, fromw]]Set[to, tow]
-	{ Print["nodes"] }
 	out <- [worker]Nodes <<[nodes]
-	{ Print["Add Wire@NWorker done"] }
-	}
 }
 
 Uses@NWorker[worker,uses:out]
@@ -714,18 +688,12 @@
 
 Collect Conditions@NWorker[worker,node:out]
 {
-	Print["Collect Conditions"]
-	{
 	out <- Fold[["Collect Condition"]Set Input[0, worker], AndSet[], [node]Wires To>>]
-	{ Print["done Collect Conditions"] }
-	}
 }
 
 Save Result[func,num,node index:out]
 {
-	Print["Save Result"]
 	out var <- [[["__result_"]Append[node index]]Append["_"]]Append[num]
-	Print[out var]
 	/*out <- [[func]Allocate Var[out var, "Any Type"]
 		]Move[Result[num], out var]
 	*/
@@ -742,21 +710,11 @@
 		{
 			with call <- [func]Set Field Call[[node]Data >>, [inputs]Index[0], [inputs]Index[1]]
 		}{
-			Print[["Call: "]Append[[[node]Data >>]Name >>]]
-			{
 			[program]Method?[[[node]Data >>]Name >>]
 			{
-				Print["Method!"]
 				with call <- [func]Method Call[[[node]Data >>]Name >>, inputs]
-				{ Print["Method Call done"] }
 			}{
-				Print["Function!"]
-				{
-					Pretty Print[inputs, ""]
-					{ with call <- [func]Call[[[node]Data >>]Name >>, inputs]}
-				}
-				
-			}
+				with call <- [func]Call[[[node]Data >>]Name >>, inputs]
 			}
 		}
 	}
@@ -765,7 +723,6 @@
 
 Compile Node@NWorker[worker,program,func,nodes,current:out,out worker]
 {
-	Print[["Compile Node: "]Append[[node]Type >>]]
 	node index <- [nodes]Index[current]
 	node <- [[worker]Nodes >>]Index[node index]
 	conditions <- [worker]Collect Conditions[node]
@@ -774,11 +731,9 @@
 		inputs <- [worker]Collect Inputs[node]
 		[conditions]For Backend
 		{
-			Print["Conditional execution, do if"]
 			stream <- [func]Instruction Stream
 			nfunc <- [func]Do If[~, nstream]
 		}{
-			Print["No conditions, full steam ahead"]
 			stream <- Val[func]
 			nfunc <- Val[nstream]
 		}
@@ -786,15 +741,12 @@
 	}{
 		If[[[node]Type >>] = ["output"]]
 		{
-			Print["Compiling output node"]
 			inputs <- [worker]Collect Inputs[node]
 			[conditions]For Backend
 			{
-				Print["has conditions"]
 				stream <- [func]Instruction Stream
 				nfunc <- [func]Do If[~, nstream]
 			}{
-				Print["no conditions"]
 				stream <- Val[func]
 				nfunc <- Val[nstream]
 			}
@@ -910,9 +862,6 @@
 {	
 	func <- [ifunc]Set Input Type[Make Basic Type[input type], index]
 	name <- [inputs]Index[index]
-	Print[["FInputs: "]Append[index]]
-	Pretty Print[input type, ""]
-	{
 	If[[[input type]Variant >>] = ["Naked"]]
 	{
 		
@@ -946,7 +895,6 @@
 			out <- Val[copied]
 		}
 	}
-	}
 }
 
 FParams[input:out]
@@ -963,7 +911,6 @@
 }
 _Return Param[outputs, inputs, input types, index:out,none]
 {
-	Print[["_Return Param: "]Append[output]]
 	output <- [outputs]Index[index]
 	[inputs]Find[output]
 	{
@@ -983,7 +930,6 @@
 
 Return Param[outputs, inputs, input types:out,none]
 {
-	Print["Return Param"]
 	,none <- [outputs]First
 	{ out,none <- _Return Param[outputs, inputs, input types, ~] }
 	
@@ -1012,7 +958,6 @@
 
 Compile Foreign Stub[worker,program,name:out]
 {
-	Print[["Compiling FFI stub for "]Append[name]]
 	ifunc <- [[program]Create Function[name, [worker]Inputs >>, [worker]Outputs >>, "rhope"]
 	]Output Types <<[Map[[worker]Output Types >>, "Make Basic Type"]]
 	
@@ -1046,8 +991,6 @@
 	}{
 		If[[[worker]Library >>] = [""]]
 		{	
-			Print[["Compiling: "]Append[name]]
-			{
 			ifunc <- Fold["Set Output Type", Fold["Set Input Type", [program]Create Function[name,[worker]Inputs >>, [worker]Outputs >>, [worker]Convention >>], [worker]Input Types >>], [worker]Output Types >>]
 			
 			res vars <- [worker]Result Vars
@@ -1061,7 +1004,6 @@
 				final func <- Val[func]
 			}
 			out <- [program]Store Function[Fold["Release", Fold[["Release Var"]Set Input[0, worker], final func, res vars], [worker]Inputs >>]]
-			}
 		}{
 			out <- Compile Foreign Stub[worker,[program]Link[[worker]Convention >>, [worker]Library >> ],name]
 		}
@@ -1140,13 +1082,10 @@
 Make Init[func,field:out]
 {
 	name <- [field]Index[0]
-	Print[["Field: "]Append[name]]
-	{ Print[["  Variant: "]Append[variant]] }
 	variant <- [[field]Index[1]]Variant >>
 	If[[variant] = ["Boxed"]]
 	{
 		out <- [func]Set Field Null["obj", name]
-		{ Print["done"] }
 	}{
 		out <- func
 	}
@@ -1188,7 +1127,6 @@
 
 Make Special@NBlueprint[bp,backend,func name,bp name,pop worker:out]
 {
-	Print[[["Make Special: "]Append[func name]]Append[bp name]]
 	func <- [[backend]Create Function[func name,("obj"),(),"cdecl"]
 		]Set Input Type[Type Instance[bp name], 0]
 	out <- [backend]Store Function[Fold[pop worker, func, [bp]Fields >>]]
@@ -1197,7 +1135,6 @@
 Getters Setters[backend,field,type name:out]
 {
 	//TODO: Throw an exception or something if we read a field that is empty
-	Print[["Getters Setters: "]Append[name]]
 	name <- [field]Index[0]
 	type <- [field]Index[1]
 	mytype <- Type Instance[type name]
@@ -1210,7 +1147,6 @@
 		getter <- [[start getter]Do AddRef[getref, "out"]]Release["obj"]
 	}{
 		getter <- [[start getter]Box[getref, "out", type]]Release["obj"]
-		{ Print["Got getter"] }
 	}
 		
 	begin setter <- [[[[[backend]Create Function[ [[[name]Append[" <<"]]Append["@"]]Append[type name], ("obj","newval"), ("out"), "rhope"]
@@ -1230,7 +1166,6 @@
 			{
 				setter <- [[~]Move["newval", setref]
 				]Move["obj", "out"]
-				{ Print["got setter"] }
 			}
 		}
 	}{
@@ -1238,7 +1173,6 @@
 		{ 
 			setter <- [[~]Unbox["newval", setref]
 			]Move["obj", "out"]
-			{ Print ["got setter"] }
 		}
 	}
 	
@@ -1248,7 +1182,6 @@
 
 Compile Blueprint@NBlueprint[bp,backend,name:out]
 {
-	Print[["Compiling blueprint: "]Append[name]]
 	//Rhope identifiers can't start with spaces, so we can use identifiers that start with spaces for special functions
 	init name <- [" init "]Append[name]
 	copy name <- [" copy "]Append[name]
@@ -1257,7 +1190,6 @@
 	]Init <<[init name]
 	]Copy <<[copy name]
 	]Cleanup <<[cleanup name]
-	{ Print["Created type on backend"] }
 	
 	out <- [backend]Register Type[type]
 }
@@ -1303,7 +1235,6 @@
 
 Bind Blueprint@NProgram[prog,name,blueprint:out]
 {
-	Print[["Bind blueprint: "]Append[name]]
 	out <- [prog]Blueprints << [ [[prog]Blueprints >>]Set[name, blueprint] ]
 }
 
@@ -1319,16 +1250,13 @@
 
 _Compile Program[backend, worker, name:out]
 {
-	Print["_Compile Program"]
 	out <- [worker]Compile Worker[backend, name]
 }
 
 Compile Program@NProgram[prog, backend:out]
 {
 	backend with bps <- Generate Boolean Methods[Generate Number Methods[Fold["_Compile Program BP Special", Fold["_Compile Program BP", backend, [prog]Blueprints >>], [prog]Blueprints >>]]]
-	{ Print["All blueprints added"] }
 	workers with infer <- SMap[[prog]Workers >>, ["Infer Types"]Set Input[1, prog]]
-	{ Print["Type inference complete"] }
 	out <- Fold["_Compile Program", backend with bps,  workers with infer]
 }
 
@@ -1339,7 +1267,6 @@
 
 Register Worker@NProgram[prog, name, convention, inputs, outputs: out]
 {
-	Print[["Register Worker "]Append[name]]
 	after reg <- [prog]Worker Refs <<[ 
 		[ [prog]Worker Refs >> ]Set[name, 
 			Worker Ref[name, convention, inputs, outputs, No]
@@ -1394,7 +1321,6 @@
 
 Find Worker@NProgram[prog, name:out,notfound]
 {
-	Print[ ["Find Worker@NProgram: "]Append[name] ]
 	out,notfound <- [[prog]Worker Refs >>]Index[name]
 }