Mercurial > repos > rhope
comparison nworker_c.rhope @ 118:b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 15 Oct 2010 00:55:02 -0400 |
parents | 4d089503fb51 |
children | cd25171e1bb2 |
comparison
equal
deleted
inserted
replaced
117:4d089503fb51 | 118:b3f56e1d54a0 |
---|---|
480 Add Input@NWorker[worker,name,number:out,node index] | 480 Add Input@NWorker[worker,name,number:out,node index] |
481 { | 481 { |
482 out,node index <- [worker]Add Typed Input[name,number,Type Instance["Any Type"]] | 482 out,node index <- [worker]Add Typed Input[name,number,Type Instance["Any Type"]] |
483 } | 483 } |
484 | 484 |
485 Add Anon Input@NWorker[worker,number:out] | |
486 { | |
487 If[[number]>[Length[[worker]Inputs >>]]] | |
488 { | |
489 prepped <- [worker]Add Anon Input[[number]-[1]] | |
490 }{ | |
491 prepped <- Val[worker] | |
492 } | |
493 out <- out <- [[prepped]Inputs <<[[[prepped]Inputs >>]Set[number,[" unnamed"]Append[String[number]]]] | |
494 ]Input Types <<[[[prepped]Input Types >>]Set[number,Type Instance["Any Type"]]] | |
495 } | |
496 | |
485 Add Typed Input@NWorker[worker,name,number,type:out,node index] | 497 Add Typed Input@NWorker[worker,name,number,type:out,node index] |
486 { | 498 { |
487 ,node index <- [worker]Add Node["input",number,0,1] | 499 If[[number]>[Length[[worker]Inputs >>]]] |
500 { | |
501 prepped <- [worker]Add Anon Input[[number]-[1]] | |
502 }{ | |
503 prepped <- Val[worker] | |
504 } | |
505 ,node index <- [prepped]Add Node["input",number,0,1] | |
488 { | 506 { |
489 out <- [[~]Inputs <<[[[~]Inputs >>]Set[number,name]] | 507 out <- [[~]Inputs <<[[[~]Inputs >>]Set[number,name]] |
490 ]Input Types <<[[[~]Input Types >>]Set[number,type]] | 508 ]Input Types <<[[[~]Input Types >>]Set[number,type]] |
491 } | 509 } |
492 } | 510 } |
880 constname <- Const Name[[node]Data >>, node index, [worker]Name >>] | 898 constname <- Const Name[[node]Data >>, node index, [worker]Name >>] |
881 withconst <- [func]Register Constant[constname, [node]Data >>] | 899 withconst <- [func]Register Constant[constname, [node]Data >>] |
882 [conditions]For Backend | 900 [conditions]For Backend |
883 { | 901 { |
884 stream <- [[withconst]Instruction Stream | 902 stream <- [[withconst]Instruction Stream |
885 ]Move[Constant[constname], Result Var Name[0, node index]] | 903 ]Move[Strip Addref[Constant[constname]], Result Var Name[0, node index]] |
886 nfunc <- [withconst]Do If[~, stream] | 904 nfunc <- [withconst]Do If[~, stream] |
887 }{ | 905 }{ |
888 nfunc <- Val[withconst] | 906 nfunc <- Val[withconst] |
889 } | 907 } |
890 }{ | 908 }{ |
1080 out <- Val[copied] | 1098 out <- Val[copied] |
1081 } | 1099 } |
1082 } | 1100 } |
1083 } | 1101 } |
1084 | 1102 |
1103 Release Raw Inputs[func,input type,index,inputs,outputs:out] | |
1104 { | |
1105 If[[[input type]Variant >>] = ["Raw Pointer"]] | |
1106 { | |
1107 name <- [inputs]Index[index] | |
1108 If[[input type]Mutable? >>] | |
1109 { | |
1110 [outputs]Find[=[?,[inputs]Index[index]]] | |
1111 { | |
1112 out <- func | |
1113 }{ | |
1114 out <- [func]Release[name] | |
1115 } | |
1116 }{ | |
1117 out <- [func]Release[name] | |
1118 } | |
1119 }{ | |
1120 out <- func | |
1121 } | |
1122 } | |
1123 | |
1085 FParams[input:out] | 1124 FParams[input:out] |
1086 { | 1125 { |
1087 iname <- [input]Index[0] | 1126 iname <- [input]Index[0] |
1088 type <- [input]Index[1] | 1127 type <- [input]Index[1] |
1089 If[[[type]Variant >>] = ["Naked"]] | 1128 If[[[type]Variant >>] = ["Naked"]] |
1162 rfunc <- Val[ifunc] | 1201 rfunc <- Val[ifunc] |
1163 } | 1202 } |
1164 | 1203 |
1165 Fold[FInputs[?, ?, ?, [worker]Inputs >>], rfunc, [worker]Input Types >>] | 1204 Fold[FInputs[?, ?, ?, [worker]Inputs >>], rfunc, [worker]Input Types >>] |
1166 { [~]Call Foreign[name, [worker]Convention >>, Map[Zip[[worker]Inputs >>, [worker]Input Types >>], FParams[?]], rparam] | 1205 { [~]Call Foreign[name, [worker]Convention >>, Map[Zip[[worker]Inputs >>, [worker]Input Types >>], FParams[?]], rparam] |
1206 { Fold[Release Raw Inputs[?, ?, ?, [worker]Inputs >>, [worker]Outputs >>], ~, [worker]Input Types >>] | |
1167 { Fold[Save Foreign Result[?, ?, ?, [worker]Output Types >>, [worker]Inputs >>, [worker]Input Types >>], ~, [worker]Outputs >>] | 1207 { Fold[Save Foreign Result[?, ?, ?, [worker]Output Types >>, [worker]Inputs >>, [worker]Input Types >>], ~, [worker]Outputs >>] |
1168 { out <- [program]Store Function[~] }}} | 1208 { out <- [program]Store Function[~] }}}} |
1169 } | 1209 } |
1170 | 1210 |
1171 Compile Worker@NWorker[worker,program,name:out] | 1211 Compile Worker@NWorker[worker,program,name:out] |
1172 { | 1212 { |
1173 If[[worker]Builtin? >>] | 1213 If[[worker]Builtin? >>] |
1362 | 1402 |
1363 Compile Blueprint@NBlueprint[bp,backend,name:out] | 1403 Compile Blueprint@NBlueprint[bp,backend,name:out] |
1364 { | 1404 { |
1365 //Rhope identifiers can't start with spaces, so we can use identifiers that start with spaces for special functions | 1405 //Rhope identifiers can't start with spaces, so we can use identifiers that start with spaces for special functions |
1366 init name <- [" init "]Append[name] | 1406 init name <- [" init "]Append[name] |
1367 copy name <- [" copy "]Append[name] | 1407 [("Array","Boxed Array","Worker")]Find[=[?,name]] |
1368 cleanup name <- [" cleanup "]Append[name] | 1408 { |
1409 [("internalarraynaked","internalarrayboxed","internalworker")]Index[~] | |
1410 { | |
1411 copy name <- [~]Append["copy"] | |
1412 cleanup name <- [~]Append["cleanup"] | |
1413 } | |
1414 }{ | |
1415 copy name <- [" copy "]Append[name] | |
1416 cleanup name <- [" cleanup "]Append[name] | |
1417 } | |
1369 type <- [[[Fold[_Compile Blueprint Methods[?], Fold[_Compile Blueprint Fields[?], [backend]Create Type[name], [bp]Fields >>], [bp]Methods >>] | 1418 type <- [[[Fold[_Compile Blueprint Methods[?], Fold[_Compile Blueprint Fields[?], [backend]Create Type[name], [bp]Fields >>], [bp]Methods >>] |
1370 ]Init <<[init name] | 1419 ]Init <<[init name] |
1371 ]Copy <<[copy name] | 1420 ]Copy <<[copy name] |
1372 ]Cleanup <<[cleanup name] | 1421 ]Cleanup <<[cleanup name] |
1373 | 1422 |
1375 } | 1424 } |
1376 | 1425 |
1377 Compile Special@NBlueprint[bp,backend,name:out] | 1426 Compile Special@NBlueprint[bp,backend,name:out] |
1378 { | 1427 { |
1379 init name <- [" init "]Append[name] | 1428 init name <- [" init "]Append[name] |
1380 copy name <- [" copy "]Append[name] | 1429 [("Array","Boxed Array","Worker")]Find[=[?,name]] |
1381 cleanup name <- [" cleanup "]Append[name] | 1430 { |
1382 got specials <- [bp]Make Special[ | 1431 after copyclean <- Val[backend] |
1383 [bp]Make Special[ | 1432 }{ |
1384 [bp]Make Special[backend, init name, name, Make Init[?]], | 1433 copy name <- [" copy "]Append[name] |
1385 copy name, name, Make Copy[?]], | 1434 cleanup name <- [" cleanup "]Append[name] |
1386 cleanup name, name, Make Cleanup[?]] | 1435 after copyclean <- [bp]Make Special[ |
1387 out <- Fold[Getters Setters[?, ?, name], got specials, [bp]Fields >>] | 1436 [bp]Make Special[backend, copy name, name, Make Copy[?]], |
1437 cleanup name, name, Make Cleanup[?]] | |
1438 } | |
1439 out <- Fold[Getters Setters[?, ?, name], [bp]Make Special[after copyclean, init name, name, Make Init[?]], [bp]Fields >>] | |
1388 } | 1440 } |
1389 | 1441 |
1390 Blueprint NProgram | 1442 Blueprint NProgram |
1391 { | 1443 { |
1392 Blueprints | 1444 Blueprints |