comparison 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
comparison
equal deleted inserted replaced
68:38d9cd036d49 69:d0ce696786cc
55 out <- [[<String@Worker[[type]Append["Cond"]]]Do[ [[()]Append[current]]Append[variable] ]]Index[0] 55 out <- [[<String@Worker[[type]Append["Cond"]]]Do[ [[()]Append[current]]Append[variable] ]]Index[0]
56 } 56 }
57 57
58 _For Backend Subset[current,subset,type:out] 58 _For Backend Subset[current,subset,type:out]
59 { 59 {
60 Print["Calling For Backend on subset"]
61 {
62 [subset]For Backend 60 [subset]For Backend
63 { 61 {
64 Print["Got output from for backend"]
65 out <- [[<String@Worker[[type]Append["Cond"]]]Do[ [[()]Append[current]]Append[~] ]]Index[0] 62 out <- [[<String@Worker[[type]Append["Cond"]]]Do[ [[()]Append[current]]Append[~] ]]Index[0]
66 { Print["done _For Backend Subset with condition"] } 63 }{
67 }{
68 Print["none output from for backend"]
69 out <- current 64 out <- current
70 }
71 } 65 }
72 } 66 }
73 67
74 Empty?@Condition Set[set:not empty,empty] 68 Empty?@Condition Set[set:not empty,empty]
75 { 69 {
113 } 107 }
114 } 108 }
115 109
116 For Backend@Condition Set[set:out,none] 110 For Backend@Condition Set[set:out,none]
117 { 111 {
118 Print["For Backend"]
119 firstvar <- [[set]Variables >>]First 112 firstvar <- [[set]Variables >>]First
120 { 113 {
121 Print["At least one var"]
122 [[set]Variables >>]Next[~] 114 [[set]Variables >>]Next[~]
123 { 115 {
124 Print["at least two vars"]
125 vars <- _Fold[[set]Variables >>, ~, firstvar, ["_For Backend Var"]Set Input[3, [set]Condition Type >>]] 116 vars <- _Fold[[set]Variables >>, ~, firstvar, ["_For Backend Var"]Set Input[3, [set]Condition Type >>]]
126 }{ 117 }{
127 Print["just one var"]
128 vars <- Val[firstvar] 118 vars <- Val[firstvar]
129 } 119 }
130 out <- Fold[["_For Backend Subset"]Set Input[2, [set]Condition Type >>], vars, [set]Subsets >>] 120 out <- Fold[["_For Backend Subset"]Set Input[2, [set]Condition Type >>], vars, [set]Subsets >>]
131 { Print["done For Backend, with vars"] } 121 }{
132 }{
133 Print["no vars"]
134 [[set]Subsets >>]First Non-empty Set 122 [[set]Subsets >>]First Non-empty Set
135 { 123 {
136 Print[["At least one non-empty subset: "]Append[~]]
137 firstsub <- [[[set]Subsets >>]Index[~]]For Backend 124 firstsub <- [[[set]Subsets >>]Index[~]]For Backend
138 [[set]Subsets >>]Next[~] 125 [[set]Subsets >>]Next[~]
139 { 126 {
140 Print["at least two subsets"]
141 out <- _Fold[[set]Subsets >>, ~, firstsub, ["_For Backend Subset"]Set Input[2, [set]Condition Type >>]] 127 out <- _Fold[[set]Subsets >>, ~, firstsub, ["_For Backend Subset"]Set Input[2, [set]Condition Type >>]]
142 { Print["done with subsets, but no vars"] }
143 }{ 128 }{
144 out <- Val[firstsub] 129 out <- Val[firstsub]
145 { Pretty Print[~, "1s:\t"] }
146 } 130 }
147 }{ 131 }{
148 Print["done with none"]
149 none <- Yes 132 none <- Yes
150 } 133 }
151 } 134 }
152 } 135 }
153 136
462 } 445 }
463 } 446 }
464 447
465 Infer Types@NWorker[worker,prog:out] 448 Infer Types@NWorker[worker,prog:out]
466 { 449 {
467 Print[["Start inference: "]Append[[worker]Name >>]]
468 out <- [worker]Nodes <<[Fold[[["Infer Types Node"]Set Input[3, prog]]Set Input[4, worker], [worker]Nodes >>, [worker]Nodes >>]] 450 out <- [worker]Nodes <<[Fold[[["Infer Types Node"]Set Input[3, prog]]Set Input[4, worker], [worker]Nodes >>, [worker]Nodes >>]]
469 { Print[["End inference: "]Append[[worker]Name >>]] }
470 } 451 }
471 452
472 Add Worker Call@NWorker[worker,tocall:out,node index] 453 Add Worker Call@NWorker[worker,tocall:out,node index]
473 { 454 {
474 out, node index <- [worker]Add Node["call",tocall,[tocall]Inputs >>,[tocall]Outputs >>] 455 out, node index <- [worker]Add Node["call",tocall,[tocall]Inputs >>,[tocall]Outputs >>]
517 out, node index <- [worker]Add Node["setfield",fieldname,2,1] 498 out, node index <- [worker]Add Node["setfield",fieldname,2,1]
518 } 499 }
519 500
520 Add Wire@NWorker[worker,from,output,to,input:out] 501 Add Wire@NWorker[worker,from,output,to,input:out]
521 { 502 {
522 Print[[[[[[[[["Add Wire@NWorker["]Append[from]]Append[","]]Append[output]]Append[","]]Append[to]]Append[","]]Append[input]]Append["]"]]
523 {
524 fromw <- [[[worker]Nodes >>]Index[from]]Wire From[to,input,output] 503 fromw <- [[[worker]Nodes >>]Index[from]]Wire From[to,input,output]
525 { Print["fromw"] }
526 tow <- [[[worker]Nodes >>]Index[to]]Wire To[from,output,input] 504 tow <- [[[worker]Nodes >>]Index[to]]Wire To[from,output,input]
527 { Print["tow"] }
528 nodes <- [[[worker]Nodes >>]Set[from, fromw]]Set[to, tow] 505 nodes <- [[[worker]Nodes >>]Set[from, fromw]]Set[to, tow]
529 { Print["nodes"] }
530 out <- [worker]Nodes <<[nodes] 506 out <- [worker]Nodes <<[nodes]
531 { Print["Add Wire@NWorker done"] }
532 }
533 } 507 }
534 508
535 Uses@NWorker[worker,uses:out] 509 Uses@NWorker[worker,uses:out]
536 { 510 {
537 out <- [worker]Uses <<[uses] 511 out <- [worker]Uses <<[uses]
712 out <- [set]Add Condition[Fold[["Collect Input Condition"]Set Input[0, worker], OrSet[], nodeinput]] 686 out <- [set]Add Condition[Fold[["Collect Input Condition"]Set Input[0, worker], OrSet[], nodeinput]]
713 } 687 }
714 688
715 Collect Conditions@NWorker[worker,node:out] 689 Collect Conditions@NWorker[worker,node:out]
716 { 690 {
717 Print["Collect Conditions"]
718 {
719 out <- Fold[["Collect Condition"]Set Input[0, worker], AndSet[], [node]Wires To>>] 691 out <- Fold[["Collect Condition"]Set Input[0, worker], AndSet[], [node]Wires To>>]
720 { Print["done Collect Conditions"] }
721 }
722 } 692 }
723 693
724 Save Result[func,num,node index:out] 694 Save Result[func,num,node index:out]
725 { 695 {
726 Print["Save Result"]
727 out var <- [[["__result_"]Append[node index]]Append["_"]]Append[num] 696 out var <- [[["__result_"]Append[node index]]Append["_"]]Append[num]
728 Print[out var]
729 /*out <- [[func]Allocate Var[out var, "Any Type"] 697 /*out <- [[func]Allocate Var[out var, "Any Type"]
730 ]Move[Result[num], out var] 698 ]Move[Result[num], out var]
731 */ 699 */
732 out <- [func]Move[Result[num], out var] 700 out <- [func]Move[Result[num], out var]
733 } 701 }
740 }{ 708 }{
741 If[[[node]Type >>] = ["setfield"]] 709 If[[[node]Type >>] = ["setfield"]]
742 { 710 {
743 with call <- [func]Set Field Call[[node]Data >>, [inputs]Index[0], [inputs]Index[1]] 711 with call <- [func]Set Field Call[[node]Data >>, [inputs]Index[0], [inputs]Index[1]]
744 }{ 712 }{
745 Print[["Call: "]Append[[[node]Data >>]Name >>]]
746 {
747 [program]Method?[[[node]Data >>]Name >>] 713 [program]Method?[[[node]Data >>]Name >>]
748 { 714 {
749 Print["Method!"]
750 with call <- [func]Method Call[[[node]Data >>]Name >>, inputs] 715 with call <- [func]Method Call[[[node]Data >>]Name >>, inputs]
751 { Print["Method Call done"] }
752 }{ 716 }{
753 Print["Function!"] 717 with call <- [func]Call[[[node]Data >>]Name >>, inputs]
754 {
755 Pretty Print[inputs, ""]
756 { with call <- [func]Call[[[node]Data >>]Name >>, inputs]}
757 }
758
759 } 718 }
760 }
761 } 719 }
762 } 720 }
763 out <- Fold[["Save Result"]Set Input[2, node index], with call, Range[0, [node]Outputs >>]] 721 out <- Fold[["Save Result"]Set Input[2, node index], with call, Range[0, [node]Outputs >>]]
764 } 722 }
765 723
766 Compile Node@NWorker[worker,program,func,nodes,current:out,out worker] 724 Compile Node@NWorker[worker,program,func,nodes,current:out,out worker]
767 { 725 {
768 Print[["Compile Node: "]Append[[node]Type >>]]
769 node index <- [nodes]Index[current] 726 node index <- [nodes]Index[current]
770 node <- [[worker]Nodes >>]Index[node index] 727 node <- [[worker]Nodes >>]Index[node index]
771 conditions <- [worker]Collect Conditions[node] 728 conditions <- [worker]Collect Conditions[node]
772 [("call","getfield","setfield")]Find[[node]Type >>] 729 [("call","getfield","setfield")]Find[[node]Type >>]
773 { 730 {
774 inputs <- [worker]Collect Inputs[node] 731 inputs <- [worker]Collect Inputs[node]
775 [conditions]For Backend 732 [conditions]For Backend
776 { 733 {
777 Print["Conditional execution, do if"]
778 stream <- [func]Instruction Stream 734 stream <- [func]Instruction Stream
779 nfunc <- [func]Do If[~, nstream] 735 nfunc <- [func]Do If[~, nstream]
780 }{ 736 }{
781 Print["No conditions, full steam ahead"]
782 stream <- Val[func] 737 stream <- Val[func]
783 nfunc <- Val[nstream] 738 nfunc <- Val[nstream]
784 } 739 }
785 nstream <- Compile Call Node[node, program, stream, inputs, node index] 740 nstream <- Compile Call Node[node, program, stream, inputs, node index]
786 }{ 741 }{
787 If[[[node]Type >>] = ["output"]] 742 If[[[node]Type >>] = ["output"]]
788 { 743 {
789 Print["Compiling output node"]
790 inputs <- [worker]Collect Inputs[node] 744 inputs <- [worker]Collect Inputs[node]
791 [conditions]For Backend 745 [conditions]For Backend
792 { 746 {
793 Print["has conditions"]
794 stream <- [func]Instruction Stream 747 stream <- [func]Instruction Stream
795 nfunc <- [func]Do If[~, nstream] 748 nfunc <- [func]Do If[~, nstream]
796 }{ 749 }{
797 Print["no conditions"]
798 stream <- Val[func] 750 stream <- Val[func]
799 nfunc <- Val[nstream] 751 nfunc <- Val[nstream]
800 } 752 }
801 nstream <- [stream]Move[[inputs]Index[0], [[worker]Outputs >>]Index[ [node]Data >> ] ] 753 nstream <- [stream]Move[[inputs]Index[0], [[worker]Outputs >>]Index[ [node]Data >> ] ]
802 }{ 754 }{
908 860
909 FInputs[ifunc, input type, index, inputs:out] 861 FInputs[ifunc, input type, index, inputs:out]
910 { 862 {
911 func <- [ifunc]Set Input Type[Make Basic Type[input type], index] 863 func <- [ifunc]Set Input Type[Make Basic Type[input type], index]
912 name <- [inputs]Index[index] 864 name <- [inputs]Index[index]
913 Print[["FInputs: "]Append[index]]
914 Pretty Print[input type, ""]
915 {
916 If[[[input type]Variant >>] = ["Naked"]] 865 If[[[input type]Variant >>] = ["Naked"]]
917 { 866 {
918 867
919 naked <- [" naked"]Append[name] 868 naked <- [" naked"]Append[name]
920 869
944 } 893 }
945 }{ 894 }{
946 out <- Val[copied] 895 out <- Val[copied]
947 } 896 }
948 } 897 }
949 }
950 } 898 }
951 899
952 FParams[input:out] 900 FParams[input:out]
953 { 901 {
954 iname <- [input]Index[0] 902 iname <- [input]Index[0]
961 { out <- Val[iname] } 909 { out <- Val[iname] }
962 } 910 }
963 } 911 }
964 _Return Param[outputs, inputs, input types, index:out,none] 912 _Return Param[outputs, inputs, input types, index:out,none]
965 { 913 {
966 Print[["_Return Param: "]Append[output]]
967 output <- [outputs]Index[index] 914 output <- [outputs]Index[index]
968 [inputs]Find[output] 915 [inputs]Find[output]
969 { 916 {
970 If[[[input types]Index[~]]Mutable? >>] 917 If[[[input types]Index[~]]Mutable? >>]
971 { 918 {
981 } 928 }
982 } 929 }
983 930
984 Return Param[outputs, inputs, input types:out,none] 931 Return Param[outputs, inputs, input types:out,none]
985 { 932 {
986 Print["Return Param"]
987 ,none <- [outputs]First 933 ,none <- [outputs]First
988 { out,none <- _Return Param[outputs, inputs, input types, ~] } 934 { out,none <- _Return Param[outputs, inputs, input types, ~] }
989 935
990 } 936 }
991 937
1010 } 956 }
1011 } 957 }
1012 958
1013 Compile Foreign Stub[worker,program,name:out] 959 Compile Foreign Stub[worker,program,name:out]
1014 { 960 {
1015 Print[["Compiling FFI stub for "]Append[name]]
1016 ifunc <- [[program]Create Function[name, [worker]Inputs >>, [worker]Outputs >>, "rhope"] 961 ifunc <- [[program]Create Function[name, [worker]Inputs >>, [worker]Outputs >>, "rhope"]
1017 ]Output Types <<[Map[[worker]Output Types >>, "Make Basic Type"]] 962 ]Output Types <<[Map[[worker]Output Types >>, "Make Basic Type"]]
1018 963
1019 rp num <- Return Param[[worker]Outputs >>, [worker]Inputs >>, [worker]Input Types >>] 964 rp num <- Return Param[[worker]Outputs >>, [worker]Inputs >>, [worker]Input Types >>]
1020 { 965 {
1044 { 989 {
1045 out <- program 990 out <- program
1046 }{ 991 }{
1047 If[[[worker]Library >>] = [""]] 992 If[[[worker]Library >>] = [""]]
1048 { 993 {
1049 Print[["Compiling: "]Append[name]]
1050 {
1051 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 >>] 994 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 >>]
1052 995
1053 res vars <- [worker]Result Vars 996 res vars <- [worker]Result Vars
1054 func <- Fold["Set Null", Fold["Set Null", Fold[["Allocate Var"]Set Input[2, "Any Type"], ifunc, res vars], res vars], [worker]Outputs >>] 997 func <- Fold["Set Null", Fold["Set Null", Fold[["Allocate Var"]Set Input[2, "Any Type"], ifunc, res vars], res vars], [worker]Outputs >>]
1055 998
1059 final func <- [worker]Compile Group[program,func,groups, ~] 1002 final func <- [worker]Compile Group[program,func,groups, ~]
1060 }{ 1003 }{
1061 final func <- Val[func] 1004 final func <- Val[func]
1062 } 1005 }
1063 out <- [program]Store Function[Fold["Release", Fold[["Release Var"]Set Input[0, worker], final func, res vars], [worker]Inputs >>]] 1006 out <- [program]Store Function[Fold["Release", Fold[["Release Var"]Set Input[0, worker], final func, res vars], [worker]Inputs >>]]
1064 }
1065 }{ 1007 }{
1066 out <- Compile Foreign Stub[worker,[program]Link[[worker]Convention >>, [worker]Library >> ],name] 1008 out <- Compile Foreign Stub[worker,[program]Link[[worker]Convention >>, [worker]Library >> ],name]
1067 } 1009 }
1068 } 1010 }
1069 } 1011 }
1138 } 1080 }
1139 1081
1140 Make Init[func,field:out] 1082 Make Init[func,field:out]
1141 { 1083 {
1142 name <- [field]Index[0] 1084 name <- [field]Index[0]
1143 Print[["Field: "]Append[name]]
1144 { Print[[" Variant: "]Append[variant]] }
1145 variant <- [[field]Index[1]]Variant >> 1085 variant <- [[field]Index[1]]Variant >>
1146 If[[variant] = ["Boxed"]] 1086 If[[variant] = ["Boxed"]]
1147 { 1087 {
1148 out <- [func]Set Field Null["obj", name] 1088 out <- [func]Set Field Null["obj", name]
1149 { Print["done"] }
1150 }{ 1089 }{
1151 out <- func 1090 out <- func
1152 } 1091 }
1153 } 1092 }
1154 1093
1186 } 1125 }
1187 } 1126 }
1188 1127
1189 Make Special@NBlueprint[bp,backend,func name,bp name,pop worker:out] 1128 Make Special@NBlueprint[bp,backend,func name,bp name,pop worker:out]
1190 { 1129 {
1191 Print[[["Make Special: "]Append[func name]]Append[bp name]]
1192 func <- [[backend]Create Function[func name,("obj"),(),"cdecl"] 1130 func <- [[backend]Create Function[func name,("obj"),(),"cdecl"]
1193 ]Set Input Type[Type Instance[bp name], 0] 1131 ]Set Input Type[Type Instance[bp name], 0]
1194 out <- [backend]Store Function[Fold[pop worker, func, [bp]Fields >>]] 1132 out <- [backend]Store Function[Fold[pop worker, func, [bp]Fields >>]]
1195 } 1133 }
1196 1134
1197 Getters Setters[backend,field,type name:out] 1135 Getters Setters[backend,field,type name:out]
1198 { 1136 {
1199 //TODO: Throw an exception or something if we read a field that is empty 1137 //TODO: Throw an exception or something if we read a field that is empty
1200 Print[["Getters Setters: "]Append[name]]
1201 name <- [field]Index[0] 1138 name <- [field]Index[0]
1202 type <- [field]Index[1] 1139 type <- [field]Index[1]
1203 mytype <- Type Instance[type name] 1140 mytype <- Type Instance[type name]
1204 start getter,getref <- [[[[backend]Create Function[ [[[name]Append[" >>"]]Append["@"]]Append[type name], ("obj"), ("out"), "rhope"] 1141 start getter,getref <- [[[[backend]Create Function[ [[[name]Append[" >>"]]Append["@"]]Append[type name], ("obj"), ("out"), "rhope"]
1205 ]Set Input Type[mytype, 0] 1142 ]Set Input Type[mytype, 0]
1208 If[[[type]Variant >>] = ["Boxed"]] 1145 If[[[type]Variant >>] = ["Boxed"]]
1209 { 1146 {
1210 getter <- [[start getter]Do AddRef[getref, "out"]]Release["obj"] 1147 getter <- [[start getter]Do AddRef[getref, "out"]]Release["obj"]
1211 }{ 1148 }{
1212 getter <- [[start getter]Box[getref, "out", type]]Release["obj"] 1149 getter <- [[start getter]Box[getref, "out", type]]Release["obj"]
1213 { Print["Got getter"] }
1214 } 1150 }
1215 1151
1216 begin setter <- [[[[[backend]Create Function[ [[[name]Append[" <<"]]Append["@"]]Append[type name], ("obj","newval"), ("out"), "rhope"] 1152 begin setter <- [[[[[backend]Create Function[ [[[name]Append[" <<"]]Append["@"]]Append[type name], ("obj","newval"), ("out"), "rhope"]
1217 ]Set Input Type[mytype, 0] 1153 ]Set Input Type[mytype, 0]
1218 ]Set Input Type[[type]Set Variant["Boxed"], 1] 1154 ]Set Input Type[[type]Set Variant["Boxed"], 1]
1228 ,setref <- [[~]Do If[origref, stream] 1164 ,setref <- [[~]Do If[origref, stream]
1229 ]Write Field["obj", name] 1165 ]Write Field["obj", name]
1230 { 1166 {
1231 setter <- [[~]Move["newval", setref] 1167 setter <- [[~]Move["newval", setref]
1232 ]Move["obj", "out"] 1168 ]Move["obj", "out"]
1233 { Print["got setter"] }
1234 } 1169 }
1235 } 1170 }
1236 }{ 1171 }{
1237 ,setref <- [begin setter]Write Field["obj", name] 1172 ,setref <- [begin setter]Write Field["obj", name]
1238 { 1173 {
1239 setter <- [[~]Unbox["newval", setref] 1174 setter <- [[~]Unbox["newval", setref]
1240 ]Move["obj", "out"] 1175 ]Move["obj", "out"]
1241 { Print ["got setter"] }
1242 } 1176 }
1243 } 1177 }
1244 1178
1245 out <- [[backend]Store Function[getter]]Store Function[setter] 1179 out <- [[backend]Store Function[getter]]Store Function[setter]
1246 1180
1247 } 1181 }
1248 1182
1249 Compile Blueprint@NBlueprint[bp,backend,name:out] 1183 Compile Blueprint@NBlueprint[bp,backend,name:out]
1250 { 1184 {
1251 Print[["Compiling blueprint: "]Append[name]]
1252 //Rhope identifiers can't start with spaces, so we can use identifiers that start with spaces for special functions 1185 //Rhope identifiers can't start with spaces, so we can use identifiers that start with spaces for special functions
1253 init name <- [" init "]Append[name] 1186 init name <- [" init "]Append[name]
1254 copy name <- [" copy "]Append[name] 1187 copy name <- [" copy "]Append[name]
1255 cleanup name <- [" cleanup "]Append[name] 1188 cleanup name <- [" cleanup "]Append[name]
1256 type <- [[[Fold["_Compile Blueprint Methods", Fold["_Compile Blueprint Fields", [backend]Create Type[name], [bp]Fields >>], [bp]Methods >>] 1189 type <- [[[Fold["_Compile Blueprint Methods", Fold["_Compile Blueprint Fields", [backend]Create Type[name], [bp]Fields >>], [bp]Methods >>]
1257 ]Init <<[init name] 1190 ]Init <<[init name]
1258 ]Copy <<[copy name] 1191 ]Copy <<[copy name]
1259 ]Cleanup <<[cleanup name] 1192 ]Cleanup <<[cleanup name]
1260 { Print["Created type on backend"] }
1261 1193
1262 out <- [backend]Register Type[type] 1194 out <- [backend]Register Type[type]
1263 } 1195 }
1264 1196
1265 Compile Special@NBlueprint[bp,backend,name:out] 1197 Compile Special@NBlueprint[bp,backend,name:out]
1301 } 1233 }
1302 } 1234 }
1303 1235
1304 Bind Blueprint@NProgram[prog,name,blueprint:out] 1236 Bind Blueprint@NProgram[prog,name,blueprint:out]
1305 { 1237 {
1306 Print[["Bind blueprint: "]Append[name]]
1307 out <- [prog]Blueprints << [ [[prog]Blueprints >>]Set[name, blueprint] ] 1238 out <- [prog]Blueprints << [ [[prog]Blueprints >>]Set[name, blueprint] ]
1308 } 1239 }
1309 1240
1310 _Compile Program BP[backend, blueprint, name:out] 1241 _Compile Program BP[backend, blueprint, name:out]
1311 { 1242 {
1317 out <- [blueprint]Compile Special[backend, name] 1248 out <- [blueprint]Compile Special[backend, name]
1318 } 1249 }
1319 1250
1320 _Compile Program[backend, worker, name:out] 1251 _Compile Program[backend, worker, name:out]
1321 { 1252 {
1322 Print["_Compile Program"]
1323 out <- [worker]Compile Worker[backend, name] 1253 out <- [worker]Compile Worker[backend, name]
1324 } 1254 }
1325 1255
1326 Compile Program@NProgram[prog, backend:out] 1256 Compile Program@NProgram[prog, backend:out]
1327 { 1257 {
1328 backend with bps <- Generate Boolean Methods[Generate Number Methods[Fold["_Compile Program BP Special", Fold["_Compile Program BP", backend, [prog]Blueprints >>], [prog]Blueprints >>]]] 1258 backend with bps <- Generate Boolean Methods[Generate Number Methods[Fold["_Compile Program BP Special", Fold["_Compile Program BP", backend, [prog]Blueprints >>], [prog]Blueprints >>]]]
1329 { Print["All blueprints added"] }
1330 workers with infer <- SMap[[prog]Workers >>, ["Infer Types"]Set Input[1, prog]] 1259 workers with infer <- SMap[[prog]Workers >>, ["Infer Types"]Set Input[1, prog]]
1331 { Print["Type inference complete"] }
1332 out <- Fold["_Compile Program", backend with bps, workers with infer] 1260 out <- Fold["_Compile Program", backend with bps, workers with infer]
1333 } 1261 }
1334 1262
1335 Register Method@NProgram[prog, name, convention, inputs, outputs: out] 1263 Register Method@NProgram[prog, name, convention, inputs, outputs: out]
1336 { 1264 {
1337 out <- [prog]Worker Refs <<[ [[prog]Worker Refs >>]Set[name, Worker Ref[name, convention, inputs, outputs, Yes]]] 1265 out <- [prog]Worker Refs <<[ [[prog]Worker Refs >>]Set[name, Worker Ref[name, convention, inputs, outputs, Yes]]]
1338 } 1266 }
1339 1267
1340 Register Worker@NProgram[prog, name, convention, inputs, outputs: out] 1268 Register Worker@NProgram[prog, name, convention, inputs, outputs: out]
1341 { 1269 {
1342 Print[["Register Worker "]Append[name]]
1343 after reg <- [prog]Worker Refs <<[ 1270 after reg <- [prog]Worker Refs <<[
1344 [ [prog]Worker Refs >> ]Set[name, 1271 [ [prog]Worker Refs >> ]Set[name,
1345 Worker Ref[name, convention, inputs, outputs, No] 1272 Worker Ref[name, convention, inputs, outputs, No]
1346 ] 1273 ]
1347 ] 1274 ]
1392 ]Builtin? <<[Yes]] 1319 ]Builtin? <<[Yes]]
1393 } 1320 }
1394 1321
1395 Find Worker@NProgram[prog, name:out,notfound] 1322 Find Worker@NProgram[prog, name:out,notfound]
1396 { 1323 {
1397 Print[ ["Find Worker@NProgram: "]Append[name] ]
1398 out,notfound <- [[prog]Worker Refs >>]Index[name] 1324 out,notfound <- [[prog]Worker Refs >>]Index[name]
1399 } 1325 }
1400 1326
1401 Find Worker Def@NProgram[prog,name:out,notfound] 1327 Find Worker Def@NProgram[prog,name:out,notfound]
1402 { 1328 {