Mercurial > repos > rhope
comparison nworker.rhope @ 47:6202b866d72c
Cleaned up constructor names and merged some other changes in to support the Rhope website
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 22 Dec 2009 01:22:09 -0500 |
parents | a7c79ac22efc |
children | a24eb366195c |
comparison
equal
deleted
inserted
replaced
46:429b5f441381 | 47:6202b866d72c |
---|---|
170 Is Method? | 170 Is Method? |
171 } | 171 } |
172 | 172 |
173 Worker Ref[name,convention,inputs,outputs,ismethod?:out] | 173 Worker Ref[name,convention,inputs,outputs,ismethod?:out] |
174 { | 174 { |
175 out <- [[[[[Build["Worker Ref"]]Name <<[name]]Convention <<[convention]]Inputs <<[inputs]]Outputs <<[outputs]]Is Method ? <<[ismethod?] | 175 out <- [[[[[Build["Worker Ref"]]Name <<[name]]Convention <<[convention]]Inputs <<[inputs]]Outputs <<[outputs]]Is Method? <<[ismethod?] |
176 } | 176 } |
177 | 177 |
178 Blueprint Node Ref | 178 Blueprint Node Ref |
179 { | 179 { |
180 Index | 180 Index |
298 Builtin? | 298 Builtin? |
299 } | 299 } |
300 | 300 |
301 NWorker[convention:out] | 301 NWorker[convention:out] |
302 { | 302 { |
303 out <- [[[[[[[[Build["NWorker"]]Convention <<[convention]]Nodes <<[()]]Inputs <<[()]]Outputs <<[()]]Input Types <<[()]]Output Types <<[()]]Name <<["Anonymous"]]Builtin <<[No] | 303 out <- [[[[[[[[Build["NWorker"]]Convention <<[convention]]Nodes <<[()]]Inputs <<[()]]Outputs <<[()]]Input Types <<[()]]Output Types <<[()]]Name <<["Anonymous"]]Builtin? <<[No] |
304 } | 304 } |
305 | 305 |
306 Add Node@NWorker[worker,type,data,inputs,outputs:out,node index] | 306 Add Node@NWorker[worker,type,data,inputs,outputs:out,node index] |
307 { | 307 { |
308 out <- [worker]Nodes <<[[[worker]Nodes >>]Append[NWorker Node[type,data,inputs,outputs]]] | 308 out <- [worker]Nodes <<[[[worker]Nodes >>]Append[NWorker Node[type,data,inputs,outputs]]] |
343 } | 343 } |
344 }{ | 344 }{ |
345 new type <- Val[type] | 345 new type <- Val[type] |
346 new count <- 1 | 346 new count <- 1 |
347 } | 347 } |
348 new node <- [node]Input Types <<[ [[node]Input Types >>]Set[[dest]IO Num >>, new type] ] | 348 new node <- [node]Input Types <<[ |
349 [[()]Append[ | |
350 [ [node]Input Types >> ]Set[ [dest]IO Num >>, new type ] | |
351 ]]Append[new count] | |
352 ] | |
349 out <- Infer Types Node[[nodelist]Set[[dest]Index >>, new node], new node, [dest]Index >>, prog, worker] | 353 out <- Infer Types Node[[nodelist]Set[[dest]Index >>, new node], new node, [dest]Index >>, prog, worker] |
350 } | 354 } |
351 | 355 |
352 Propagate Types[nodelist,dests,output num,prog,worker,source node:out] | 356 Propagate Types[nodelist,dests,output num,prog,worker,source node:out] |
353 { | 357 { |
359 If[[[node]Type >>] = ["const"]] | 363 If[[[node]Type >>] = ["const"]] |
360 { | 364 { |
361 //Temporary hack | 365 //Temporary hack |
362 If[[Type Of[[node]Data >>]] = ["Whole Number"]] | 366 If[[Type Of[[node]Data >>]] = ["Whole Number"]] |
363 { | 367 { |
364 outtype <- Type Instance["Whole Number"] | 368 outtype <- Type Instance["Int32"] |
365 }{ | 369 }{ |
366 outtype <- Type Instance[Type Of[[node]Data >>]] | 370 If[[Type Of[[node]Data >>]] = ["Type Instance"]] |
371 { | |
372 outtype <- Type Instance["Blueprint"] | |
373 }{ | |
374 outtype <- Type Instance[Type Of[[node]Data >>]] | |
375 } | |
367 } | 376 } |
368 nextnode <- [node]Output Types <<[ [()]Append[outtype] ] | 377 nextnode <- [node]Output Types <<[ [()]Append[outtype] ] |
369 | 378 |
370 }{ | 379 }{ |
371 If[[[node]Type >>] = ["input"]] | 380 If[[[node]Type >>] = ["input"]] |
1133 out <- [worker]Compile Worker[backend, name] | 1142 out <- [worker]Compile Worker[backend, name] |
1134 } | 1143 } |
1135 | 1144 |
1136 Compile Program@NProgram[prog, backend:out] | 1145 Compile Program@NProgram[prog, backend:out] |
1137 { | 1146 { |
1138 out <- Fold["_Compile Program", Fold["_Compile Program BP Special", Fold["_Compile Program BP", backend, [prog]Blueprints >>], [prog]Blueprints >>], [prog]Workers >>] | 1147 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]] ] |
1139 } | 1148 } |
1140 | 1149 |
1141 Register Method@NProgram[prog, name, convention, inputs, outputs: out] | 1150 Register Method@NProgram[prog, name, convention, inputs, outputs: out] |
1142 { | 1151 { |
1143 out <- [prog]Worker Refs <<[ [[prog]Worker Refs >>]Set[name, Worker Ref[name, convention, inputs, outputs, Yes]]] | 1152 out <- [prog]Worker Refs <<[ [[prog]Worker Refs >>]Set[name, Worker Ref[name, convention, inputs, outputs, Yes]]] |
1144 } | 1153 } |
1145 | 1154 |
1146 Register Worker@NProgram[prog, name, convention, inputs, outputs: out] | 1155 Register Worker@NProgram[prog, name, convention, inputs, outputs: out] |
1147 { | 1156 { |
1148 Print[["Register Worker "]Append[name]] | 1157 Print[["Register Worker "]Append[name]] |
1149 after reg <- [prog]Worker Refs <<[ [[prog]Worker Refs >>]Set[name, Worker Ref[name, convention, inputs, outputs, No]]] | 1158 after reg <- [prog]Worker Refs <<[ |
1150 parts <- [name]Split["@"] | 1159 [ [prog]Worker Refs >> ]Set[name, |
1151 [parts]Index[1] | 1160 Worker Ref[name, convention, inputs, outputs, No] |
1152 { | 1161 ] |
1153 out <- [after reg]Register Method[[parts]Index[0], convention, inputs, outputs] | 1162 ] |
1154 }{ | 1163 parts <- [name]Split["@"] |
1155 out <- Val[after reg] | 1164 [parts]Index[1] |
1156 } | 1165 { |
1166 out <- [after reg]Register Method@NProgram[[parts]Index[0], convention, inputs, outputs] | |
1167 }{ | |
1168 out <- Val[after reg] | |
1169 } | |
1157 } | 1170 } |
1158 | 1171 |
1159 Register Builtins@NProgram[prog:out] | 1172 Register Builtins@NProgram[prog:out] |
1160 { | 1173 { |
1161 registered <- [[[[[[[[[[[prog]Register Worker["+@Int32", "rhope", 2, 1] | 1174 registered <- [[[[[[[[[[[prog]Register Worker["+@Int32", "rhope", 2, 1] |
1172 | 1185 |
1173 out <- [[[[[[[[[[[[[registered]Bind Blueprint["Int32", NBlueprint[]] | 1186 out <- [[[[[[[[[[[[[registered]Bind Blueprint["Int32", NBlueprint[]] |
1174 ]Bind Worker["+@Int32", | 1187 ]Bind Worker["+@Int32", |
1175 [[[[[NWorker["rhope"] | 1188 [[[[[NWorker["rhope"] |
1176 ]Inputs <<[("left","right")] | 1189 ]Inputs <<[("left","right")] |
1177 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1190 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1178 ]Outputs <<[("out")] | 1191 ]Outputs <<[("out")] |
1179 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1192 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1180 ]Builin? <<[Yes]] | 1193 ]Builtin? <<[Yes]] |
1181 ]Bind Worker["-@Int32", | 1194 ]Bind Worker["-@Int32", |
1182 [[[[[NWorker["rhope"] | 1195 [[[[[NWorker["rhope"] |
1183 ]Inputs <<[("left","right")] | 1196 ]Inputs <<[("left","right")] |
1184 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1197 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1185 ]Outputs <<[("out")] | 1198 ]Outputs <<[("out")] |
1186 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1199 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1187 ]Builin? <<[Yes]] | 1200 ]Builtin? <<[Yes]] |
1188 ]Bind Worker["*@Int32", | 1201 ]Bind Worker["*@Int32", |
1189 [[[[[NWorker["rhope"] | 1202 [[[[[NWorker["rhope"] |
1190 ]Inputs <<[("left","right")] | 1203 ]Inputs <<[("left","right")] |
1191 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1204 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1192 ]Outputs <<[("out")] | 1205 ]Outputs <<[("out")] |
1193 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1206 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1194 ]Builin? <<[Yes]] | 1207 ]Builtin? <<[Yes]] |
1195 ]Bind Worker["/@Int32", | 1208 ]Bind Worker["/@Int32", |
1196 [[[[[NWorker["rhope"] | 1209 [[[[[NWorker["rhope"] |
1197 ]Inputs <<[("left","right")] | 1210 ]Inputs <<[("left","right")] |
1198 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1211 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1199 ]Outputs <<[("out")] | 1212 ]Outputs <<[("out")] |
1200 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1213 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1201 ]Builin? <<[Yes]] | 1214 ]Builtin? <<[Yes]] |
1202 ]Bind Worker["LShift@Int32", | 1215 ]Bind Worker["LShift@Int32", |
1203 [[[[[NWorker["rhope"] | 1216 [[[[[NWorker["rhope"] |
1204 ]Inputs <<[("left","right")] | 1217 ]Inputs <<[("left","right")] |
1205 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1218 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1206 ]Outputs <<[("out")] | 1219 ]Outputs <<[("out")] |
1207 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1220 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1208 ]Builin? <<[Yes]] | 1221 ]Builtin? <<[Yes]] |
1209 ]Bind Worker["RShift@Int32", | 1222 ]Bind Worker["RShift@Int32", |
1210 [[[[[NWorker["rhope"] | 1223 [[[[[NWorker["rhope"] |
1211 ]Inputs <<[("left","right")] | 1224 ]Inputs <<[("left","right")] |
1212 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1225 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1213 ]Outputs <<[("out")] | 1226 ]Outputs <<[("out")] |
1214 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1227 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1215 ]Builin? <<[Yes]] | 1228 ]Builtin? <<[Yes]] |
1216 ]Bind Worker["<@Int32", | 1229 ]Bind Worker["<@Int32", |
1217 [[[[[NWorker["rhope"] | 1230 [[[[[NWorker["rhope"] |
1218 ]Inputs <<[("left","right")] | 1231 ]Inputs <<[("left","right")] |
1219 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1232 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1220 ]Outputs <<[("out")] | 1233 ]Outputs <<[("out")] |
1221 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1234 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1222 ]Builin? <<[Yes]] | 1235 ]Builtin? <<[Yes]] |
1223 ]Bind Worker[">@Int32", | 1236 ]Bind Worker[">@Int32", |
1224 [[[[[NWorker["rhope"] | 1237 [[[[[NWorker["rhope"] |
1225 ]Inputs <<[("left","right")] | 1238 ]Inputs <<[("left","right")] |
1226 ]Input Types <<[ [[()]Append[Type Instance["Int32"]]]Type Instance["Int32"] ] | 1239 ]Input Types <<[ [[()]Append[ Type Instance["Int32"]]]Append[Type Instance["Int32"]] ] |
1227 ]Outputs <<[("out")] | 1240 ]Outputs <<[("out")] |
1228 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1241 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1229 ]Builin? <<[Yes]] | 1242 ]Builtin? <<[Yes]] |
1230 ]Bind Blueprint["Boolean", NBlueprint[]] | 1243 ]Bind Blueprint["Boolean", NBlueprint[]] |
1231 ]Bind Worker["If@Boolean", | 1244 ]Bind Worker["If@Boolean", |
1232 [[[[[NWorker["rhope"] | 1245 [[[[[NWorker["rhope"] |
1233 ]Inputs <<[("condition")] | 1246 ]Inputs <<[("condition")] |
1234 ]Input Types <<[ [()]Append[Type Instance["Boolean"]] ] | 1247 ]Input Types <<[ [()]Append[Type Instance["Boolean"]] ] |
1235 ]Outputs <<[("isyes","isno")] | 1248 ]Outputs <<[("isyes","isno")] |
1236 ]Output types <<[ [[()]Append[Type Instance["Boolean"]]]Append[Type Instance["Boolean"]] ] | 1249 ]Output Types <<[ [[()]Append[Type Instance["Boolean"]]]Append[Type Instance["Boolean"]] ] |
1237 ]Builin? <<[Yes]] | 1250 ]Builtin? <<[Yes]] |
1238 ]Bind Worker["Print", | 1251 ]Bind Worker["Print", |
1239 [[[[[NWorker["rhope"] | 1252 [[[[[NWorker["rhope"] |
1240 ]Inputs <<[("value")] | 1253 ]Inputs <<[("value")] |
1241 ]Input Types <<[ [()]Append[Type Instance["Any Type"]] ] | 1254 ]Input Types <<[ [()]Append[Type Instance["Any Type"]] ] |
1242 ]Outputs <<[("out")] | 1255 ]Outputs <<[("out")] |
1243 ]Output types <<[ [()]Append[Type Instance["Int32"]] ] | 1256 ]Output Types <<[ [()]Append[Type Instance["Int32"]] ] |
1244 ]Builin? <<[Yes]] | 1257 ]Builtin? <<[Yes]] |
1245 ]Bind Worker["Build", | 1258 ]Bind Worker["Build", |
1246 [[[[[NWorker["rhope"] | 1259 [[[[[NWorker["rhope"] |
1247 ]Inputs <<[("type")] | 1260 ]Inputs <<[("type")] |
1248 ]Input Types <<[ [()]Append[Type Instance["Blueprint"]] ] | 1261 ]Input Types <<[ [()]Append[Type Instance["Blueprint"]] ] |
1249 ]Outputs <<[("out")] | 1262 ]Outputs <<[("out")] |
1250 ]Output types <<[ [()]Append[Type Instance["Any Type"]] ] | 1263 ]Output Types <<[ [()]Append[Type Instance["Any Type"]] ] |
1251 ]Builin? <<[Yes]] | 1264 ]Builtin? <<[Yes]] |
1252 } | 1265 } |
1253 | 1266 |
1254 Find Worker@NProgram[prog, name:out,notfound] | 1267 Find Worker@NProgram[prog, name:out,notfound] |
1255 { | 1268 { |
1256 Print[ ["Find Worker@NProgram: "]Append[name] ] | 1269 Print[ ["Find Worker@NProgram: "]Append[name] ] |