diff nworker.rhope @ 48:a24eb366195c

Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
author Mike Pavone <pavone@retrodev.com>
date Tue, 02 Mar 2010 00:18:49 -0500
parents 6202b866d72c
children 3e20ed8959c4
line wrap: on
line diff
--- a/nworker.rhope	Tue Dec 22 01:22:09 2009 -0500
+++ b/nworker.rhope	Tue Mar 02 00:18:49 2010 -0500
@@ -11,12 +11,12 @@
 
 AndSet[:out]
 {
-	out <- [[[Build["Condition Set"]]Variables <<[New@Dictionary[]]]Subsets <<[New@Dictionary[]]]Condition Type <<["And"]
+	out <- [[[Build["Condition Set"]]Variables <<[Dictionary[]]]Subsets <<[Dictionary[]]]Condition Type <<["And"]
 }
 
 OrSet[:out]
 {
-	out <- [[[Build["Condition Set"]]Variables <<[New@Dictionary[]]]Subsets <<[New@Dictionary[]]]Condition Type <<["Or"]
+	out <- [[[Build["Condition Set"]]Variables <<[Dictionary[]]]Subsets <<[Dictionary[]]]Condition Type <<["Or"]
 }
 
 To String@Condition Set[set:out]
@@ -345,10 +345,8 @@
 		new type <- Val[type]
 		new count <- 1
 	}
-	new node <- [node]Input Types <<[  
-		[[()]Append[
-				[ [node]Input Types >> ]Set[ [dest]IO Num >>, new type ]
-		]]Append[new count] 
+	new node <- [node]Input Types <<[  		
+		[ [node]Input Types >> ]Set[ [dest]IO Num >>, [[()]Append[new type]]Append[new count] ]
 	]
 	out <- Infer Types Node[[nodelist]Set[[dest]Index >>, new node], new node, [dest]Index >>, prog, worker]
 }
@@ -454,8 +452,10 @@
 }
 
 Infer Types@NWorker[worker,prog:out]
-{
-	out <- [worker]Nodes <<[Fold[[["Infer Types Node"]Set Input[3, prog]]Set Input[4, worker], [worker]Nodes >>, [worker]Nodes >>]]
+{
+	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]
@@ -924,7 +924,7 @@
 
 NBlueprint[:out]
 {
-	out <- [[Build["NBlueprint"]]Fields <<[()]]Methods <<[New@Dictionary[]]
+	out <- [[Build["NBlueprint"]]Fields <<[()]]Methods <<[Dictionary[]]
 }
 
 Add Field@NBlueprint[bp,name,type:out]
@@ -1033,7 +1033,8 @@
 	{
 		getter <- [[start getter]Do AddRef[getref, "out"]]Release["obj"]
 	}{
-		getter <- [[start getter]Box[getref, "out", type]]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"]
@@ -1060,7 +1061,8 @@
 		,setref <- [begin setter]Write Field["obj", name]
 		{ 
 			setter <- [[~]Unbox["newval", setref]
-			]Move["obj", "out"]
+			]Move["obj", "out"]
+			{ Print ["got setter"] }
 		}
 	}
 	
@@ -1106,7 +1108,7 @@
 
 NProgram[:out]
 {
-	out <- [[[Build["NProgram"]]Blueprints <<[New@Dictionary[]]]Workers <<[New@Dictionary[]]]Worker Refs <<[New@Dictionary[]]
+	out <- [[[Build["NProgram"]]Blueprints <<[Dictionary[]]]Workers <<[Dictionary[]]]Worker Refs <<[Dictionary[]]
 }
 
 Bind Worker@NProgram[prog,name,worker:out]
@@ -1138,13 +1140,18 @@
 }
 
 _Compile Program[backend, worker, name:out]
-{
+{
+	Print["_Compile Program"]
 	out <- [worker]Compile Worker[backend, name]
 }
 
 Compile Program@NProgram[prog, backend:out]
-{
-	out <- Fold["_Compile Program", Fold["_Compile Program BP Special", Fold["_Compile Program BP", backend, [prog]Blueprints >>], [prog]Blueprints >>], Map[[prog]Workers >>, ["Infer Types"]Set Input[1, prog]] ]
+{
+	backend with bps <- 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]
 }
 
 Register Method@NProgram[prog, name, convention, inputs, outputs: out]
@@ -1171,77 +1178,12 @@
 
 Register Builtins@NProgram[prog:out]
 {
-	registered <- [[[[[[[[[[[prog]Register Worker["+@Int32", "rhope", 2, 1]
-	]Register Worker["-@Int32", "rhope", 2, 1]
-	]Register Worker["*@Int32", "rhope", 2, 1]
-	]Register Worker["/@Int32", "rhope", 2, 1]
-	]Register Worker["LShift@Int32", "rhope", 2, 1]
-	]Register Worker["RShift@Int32", "rhope", 2, 1]
-	]Register Worker["Print", "rhope", 1, 1]
+	registered <- [[[[prog]Register Worker["Print", "rhope", 1, 1]
 	]Register Worker["If@Boolean", "rhope", 1, 2]
-	]Register Worker["<@Int32", "rhope", 2, 1]
-	]Register Worker[">@Int32", "rhope", 2, 1]
-	]Register Worker["Build", "rhope", 1, 1]
+	]Register Worker["Build", "rhope", 1, 1]
+	]Register Number Methods
 	
-	out <- [[[[[[[[[[[[[registered]Bind Blueprint["Int32", NBlueprint[]]
-	]Bind Worker["+@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker["-@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker["*@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker["/@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker["LShift@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker["RShift@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker["<@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Worker[">@Int32", 
-		[[[[[NWorker["rhope"]
-		]Inputs <<[("left","right")]
-		]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ]
-		]Outputs <<[("out")]
-		]Output Types <<[ [()]Append[Type Instance["Int32"]] ]
-		]Builtin? <<[Yes]]
-	]Bind Blueprint["Boolean", NBlueprint[]]
-	]Bind Worker["If@Boolean",
+	out <- [[[registered]Bind Worker["If@Boolean",
 		[[[[[NWorker["rhope"]
 		]Inputs <<[("condition")]
 		]Input Types <<[ [()]Append[Type Instance["Boolean"]] ]