Mercurial > repos > rhope
comparison cbackend.rhope @ 66:d4b44ae2e34a
New variant of C backend works now
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 06 Jun 2010 20:29:10 -0400 |
parents | 1db811fa4744 |
children | d0ce696786cc |
comparison
equal
deleted
inserted
replaced
65:1db811fa4744 | 66:d4b44ae2e34a |
---|---|
1 Import extendlib.rhope | 1 Import extendlib.rhope |
2 Import backendutils.rhope | 2 Import backendutils.rhope |
3 Import number.rhope | |
4 | 3 |
5 Blueprint Blueprint Def | 4 Blueprint Blueprint Def |
6 { | 5 { |
7 Name | 6 Name |
8 Fixed Size | 7 Fixed Size |
301 ]Append[", (special_func)"] | 300 ]Append[", (special_func)"] |
302 ]Append[Escape Rhope Name NU[[ctype]Copy >> ]] | 301 ]Append[Escape Rhope Name NU[[ctype]Copy >> ]] |
303 ]Append[", (special_func)"] | 302 ]Append[", (special_func)"] |
304 ]Append[Escape Rhope Name NU[[ctype]Cleanup >>]] | 303 ]Append[Escape Rhope Name NU[[ctype]Cleanup >>]] |
305 ]Append[");"]]] ] | 304 ]Append[");"]]] ] |
306 out <- Fold[[["_Type Init C Field"]Set Input[0, [ctype]Name >>]]Set Input[1, field reg], Fold[[["_Type Init C"]Set Input[0, [ctype]Name >>]]Set Input[1, method reg], start, [ctype]Methods >>], [ctype]Fields >>] | 305 out <- Val[start]//Fold[[["_Type Init C Field"]Set Input[0, [ctype]Name >>]]Set Input[1, field reg], Fold[[["_Type Init C"]Set Input[0, [ctype]Name >>]]Set Input[1, method reg], start, [ctype]Methods >>], [ctype]Fields >>] |
307 } | 306 } |
308 | 307 |
309 Blueprint C Type Registry | 308 Blueprint C Type Registry |
310 { | 309 { |
311 Lookup | 310 Lookup |
412 Type Registry | 411 Type Registry |
413 Constants | 412 Constants |
414 Input Types | 413 Input Types |
415 Output Types | 414 Output Types |
416 Resume Index | 415 Resume Index |
416 Last NumParams | |
417 } | 417 } |
418 | 418 |
419 C Function[name,inputs,outputs,convention:out] | 419 C Function[name,inputs,outputs,convention:out] |
420 { | 420 { |
421 out <- C Function With Registry[name,inputs,outputs,convention, C Method Registry[], C Field Registry[], C Type Registry[]] | 421 out <- C Function With Registry[name,inputs,outputs,convention, C Method Registry[], C Field Registry[], C Type Registry[]] |
422 } | 422 } |
423 | 423 |
424 C Function With Registry[name,inputs,outputs,convention,registry,field reg,type reg:out] | 424 C Function With Registry[name,inputs,outputs,convention,registry,field reg,type reg:out] |
425 { | 425 { |
426 out <- [[[[[[[[[[[[[Build["C Function"] | 426 out <- [[[[[[[[[[[[[[Build["C Function"] |
427 ]Name <<[name] | 427 ]Name <<[name] |
428 ]Inputs <<[inputs] | 428 ]Inputs <<[inputs] |
429 ]Outputs <<[outputs] | 429 ]Outputs <<[outputs] |
430 ]Convention <<[convention] | 430 ]Convention <<[convention] |
431 ]Variables <<[Dictionary[]] | 431 ]Variables <<[Dictionary[]] |
435 ]Type Registry <<[type reg] | 435 ]Type Registry <<[type reg] |
436 ]Constants <<[Dictionary[]] | 436 ]Constants <<[Dictionary[]] |
437 ]Input Types <<[ Fold[["Append"]Set Input[1, "Any Type"], (), inputs] ] | 437 ]Input Types <<[ Fold[["Append"]Set Input[1, "Any Type"], (), inputs] ] |
438 ]Output Types <<[ Fold[["Append"]Set Input[1, "Any Type"], (), outputs] ] | 438 ]Output Types <<[ Fold[["Append"]Set Input[1, "Any Type"], (), outputs] ] |
439 ]Resume Index <<[1] | 439 ]Resume Index <<[1] |
440 ]Last NumParams <<[-1] | |
440 } | 441 } |
441 | 442 |
442 Set Input Type@C Function[func,type,input num:out] | 443 Set Input Type@C Function[func,type,input num:out] |
443 { | 444 { |
444 out <- [func]Input Types <<[ [[func]Input Types >>]Set[input num, type] ] | 445 out <- [func]Input Types <<[ [[func]Input Types >>]Set[input num, type] ] |
563 | 564 |
564 Release@C Function[func,psource:out] | 565 Release@C Function[func,psource:out] |
565 { | 566 { |
566 source <- [psource]Make Op[func] | 567 source <- [psource]Make Op[func] |
567 Print[["Release: "]Append[source]] | 568 Print[["Release: "]Append[source]] |
568 out <- [func]Add Statement[[["release_ref("]Append[source]]Append[")"]] | 569 out <- [func]Add Statement[[["release_ref((object *)"]Append[source]]Append[")"]] |
569 } | 570 } |
570 | 571 |
571 Set Null@C Function[func,pdest:out] | 572 Set Null@C Function[func,pdest:out] |
572 { | 573 { |
573 dest <- [pdest]Make Op[func] | 574 dest <- [pdest]Make Op[func] |
706 } | 707 } |
707 | 708 |
708 Func Base@C Function[func,tocall,args,type:out] | 709 Func Base@C Function[func,tocall,args,type:out] |
709 { | 710 { |
710 rargs <- Map[args, ["Make Op"]Set Input[1, func]] | 711 rargs <- Map[args, ["Make Op"]Set Input[1, func]] |
711 out <- [[Fold["_Function Arg C", [func]Add Raw Line[ [["PrepCall("]Append[[rargs]Length]]Append[")"] ], rargs] | 712 |
713 If[[[rargs]Length] > [[func]Last NumParams >>]] | |
714 { | |
715 If[[[func]Last NumParams >>] = [-1]] | |
716 { | |
717 freed <- Val[func] | |
718 }{ | |
719 freed <- [func]Add Raw Line["FreeCall"] | |
720 } | |
721 prepped <- [[freed]Add Raw Line[ [["PrepCall("]Append[[rargs]Length]]Append[")"] ] | |
722 ]Last NumParams <<[[rargs]Length] | |
723 }{ | |
724 prepped <- Val[func] | |
725 } | |
726 | |
727 | |
728 out <- [[Fold["_Function Arg C", prepped, rargs] | |
712 ]Add Raw Line[ | 729 ]Add Raw Line[ |
713 [[[[[[[[[type]Append["("] | 730 [[[[[[[[[type]Append["("] |
714 ]Append[tocall] | 731 ]Append[tocall] |
715 ]Append[", "] | 732 ]Append[", "] |
716 ]Append[[rargs]Length] | 733 ]Append[[rargs]Length] |
736 Val[do store] | 753 Val[do store] |
737 { stmt <- [[Make Op[store result, func]]Append[" = "]]Append[base] } | 754 { stmt <- [[Make Op[store result, func]]Append[" = "]]Append[base] } |
738 out <- [func]Add Statement[stmt] | 755 out <- [func]Add Statement[stmt] |
739 } | 756 } |
740 | 757 |
741 Field Base@C Function[func,field,args,type:out] | |
742 { | |
743 rargs <- Map[args, ["Make Op"]Set Input[1, func]] | |
744 out <- [Fold["_Function Arg C", func, rargs] | |
745 ]Add Raw Line[[[ [type]Append["("] ]Append[ [[func]Field Registry >>]Field ID[field] ]]Append[")"]] | |
746 } | |
747 | |
748 Get Field Call@C Function[func,field,source:out] | 758 Get Field Call@C Function[func,field,source:out] |
749 { | 759 { |
750 out <- [func]Field Base[field, [()]Append[source], "GFieldCall"] | 760 out <- [func]Func Base[Escape Rhope Name[[field]Append[" >>"]], [()]Append[source], "Call"] |
751 } | 761 } |
752 | 762 |
753 Set Field Call@C Function[func,field,object,value:out] | 763 Set Field Call@C Function[func,field,object,value:out] |
754 { | 764 { |
755 out <- [func]Field Base[field, [[()]Append[object]]Append[value], "SFieldCall"] | 765 out <- [func]Func Base[Escape Rhope Name[[field]Append[" <<"]], [[()]Append[object]]Append[value], "Call"] |
756 } | 766 } |
757 | 767 |
758 Tail Method Call@C Function[func,method,args:out] | 768 Tail Method Call@C Function[func,method,args:out] |
759 { | 769 { |
760 out <- [func]Func Base[[[func]Method Registry >>]Method ID[method],args, "TMCall"] | 770 out <- [func]Func Base[[[func]Method Registry >>]Method ID[method],args, "TMCall"] |
769 { | 779 { |
770 If[[[func]Convention >>] = ["rhope"]] | 780 If[[[func]Convention >>] = ["rhope"]] |
771 { | 781 { |
772 [[func]Inputs >>]Find[op] | 782 [[func]Inputs >>]Find[op] |
773 { | 783 { |
774 out <- [["cdata->params["]Append[~]]Append["]"] | 784 out <- [["my_cdata->params["]Append[~]]Append[" ]"] |
775 }{ | 785 }{ |
776 out <- ["locals->"]Append[Escape Rhope Name[op]] | 786 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]Append[Escape Rhope Name[op]] |
777 } | 787 } |
778 }{ | 788 }{ |
779 out <- Escape Rhope Name[op] | 789 out <- Escape Rhope Name[op] |
780 } | 790 } |
781 } | 791 } |
782 | 792 |
783 Resolve Output@C Function[func,name:out] | 793 Resolve Output@C Function[func,name:out] |
784 { | 794 { |
785 If[[[func]Convention >>] = ["rhope"]] | 795 If[[[func]Convention >>] = ["rhope"]] |
786 { | 796 { |
787 out <- ["locals->"]Append[Escape Rhope Name[name]] | 797 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]Append[Escape Rhope Name[name]] |
788 }{ | 798 }{ |
789 out <- Escape Rhope Name[name] | 799 out <- Escape Rhope Name[name] |
790 } | 800 } |
791 } | 801 } |
792 | 802 |
801 } | 811 } |
802 | 812 |
803 Do If@C Function[func,condition,stream:out] | 813 Do If@C Function[func,condition,stream:out] |
804 { | 814 { |
805 cond <- [condition]Make Op[func] | 815 cond <- [condition]Make Op[func] |
806 out <- [Fold["_If C", [[func | 816 out <- [[Fold["_If C", [[func |
807 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ] | 817 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ] |
808 ]Add Raw Line["{"], [stream]Statements >>] | 818 ]Add Raw Line["{"], [stream]Statements >>] |
809 ]Add Raw Line["}"] | 819 ]Add Raw Line["}"] |
820 ]Resume Index <<[[stream]Resume Index >>] | |
810 | 821 |
811 } | 822 } |
812 | 823 |
813 Result Reference@C Function[func,output:out] | 824 Result Reference@C Function[func,output:out] |
814 { | 825 { |
815 out <- [["call->params["]Append[output]]Append["]"] | 826 out <- [["cdata->params["]Append[output]]Append["]"] |
816 } | 827 } |
817 | 828 |
818 If Null Else@C Function[func,left,right:out] | 829 If Null Else@C Function[func,left,right:out] |
819 { | 830 { |
820 check <- [[Make Condition[left]]Strip Addref]Make Op[func] | 831 check <- [[Make Condition[left]]Strip Addref]Make Op[func] |
827 ]Append[" : "] | 838 ]Append[" : "] |
828 ]Append[r] | 839 ]Append[r] |
829 ]Append[")"] | 840 ]Append[")"] |
830 } | 841 } |
831 | 842 |
832 _Set Outputs C[string,inputname,inputnum:out] | 843 _Set Outputs C[string,inputname,inputnum,func:out] |
833 { | 844 { |
834 out <- [string]Append[[[ [ ["\tRet("]Append[inputnum] ]Append[", locals->"]]Append[inputname]]Append[")\n"]] | 845 out <- [string]Append[[[ [ ["\tRet("]Append[inputnum] ]Append[ [[", lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]]Append[inputname]]Append[")\n"]] |
835 } | 846 } |
836 | 847 |
837 Set Outputs@C Function[func:out] | 848 Set Outputs@C Function[func:out] |
838 { | 849 { |
839 If[[[func]Convention >>] = ["rhope"]] | 850 If[[[func]Convention >>] = ["rhope"]] |
840 { | 851 { |
841 out <- Fold["_Set Outputs C", "", [func]Outputs >>] | 852 out <- [[[Fold[["_Set Outputs C"]Set Input[3, func], "", [func]Outputs >>]]Append["\tNumRet("]]Append[[[func]Outputs >>]Length]]Append[")\n"] |
842 }{ | 853 }{ |
843 [[func]Outputs >>]Index[0] | 854 [[func]Outputs >>]Index[0] |
844 { | 855 { |
845 out <- [["\treturn "]Append[Escape Rhope Name[~]]]Append[";\n"] | 856 out <- [["\treturn "]Append[Escape Rhope Name[~]]]Append[";\n"] |
846 }{ | 857 }{ |
862 { | 873 { |
863 Print[["Definitions@C Function: "]Append[[func]Name >>]] | 874 Print[["Definitions@C Function: "]Append[[func]Name >>]] |
864 { | 875 { |
865 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ] | 876 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ] |
866 { | 877 { |
867 localtype <- [[[Fold[["_Output Defs C"]Set Input[3, func], Fold["_Var Defs C","typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} l_"]]Append[Escape Rhope Name[[func]Name >>]]]Append[";\n"] | 878 localtype <- [[[Fold[["_Output Defs C"]Set Input[3, func], Fold["_Var Defs C","typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} lt_"]]Append[Escape Rhope Name[[func]Name >>]]]Append[";\n"] |
868 }{ | 879 }{ |
869 localtype <- "" | 880 localtype <- "" |
870 } | 881 } |
871 | 882 |
872 If[ [[func]Convention >>] = ["rhope"] ] | 883 If[ [[func]Convention >>] = ["rhope"] ] |
956 } | 967 } |
957 fname <- Escape Rhope Name[[func]Name >>] | 968 fname <- Escape Rhope Name[[func]Name >>] |
958 param check <- Fold[["Check Param Type C"]Set Input[3, func], "", [func]Input Types >>] | 969 param check <- Fold[["Check Param Type C"]Set Input[3, func], "", [func]Input Types >>] |
959 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] | 970 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] |
960 { | 971 { |
961 out <- [[[[[[[ [type]Append["NoLocals("] | 972 out <- [[[[[[[[ [type]Append["NoLocals("] |
962 ]Append[cname] | 973 ]Append[cname] |
963 ]Append[",\n\tNumParams "] | 974 ]Append[",\n\tNumParams "] |
964 ]Append[ [[func]Inputs >>]Length ] | 975 ]Append[ [[func]Inputs >>]Length ] |
965 ]Append[")\n\n"] | 976 ]Append[")\n\n"] |
966 ]Append[param check] | 977 ]Append[param check] |
967 ]Append[ [[func]Statements >>]Join[""] ] | 978 ]Append[ [[func]Statements >>]Join[""] ] |
968 ]Append["EndFuncNoLocals"] | 979 ]Append["EndFuncNoLocals\n"] |
980 ]Append["DISPATCH"] | |
969 }{ | 981 }{ |
970 out <- [[[[[[[[ [type]Append["("] | 982 If[[[func]Last NumParams >>] = [-1]] |
983 { | |
984 freecall <- "" | |
985 }{ | |
986 freecall <- "\n\tFreeCall\n" | |
987 } | |
988 out <- [[[[[[[[[[ [type]Append["("] | |
971 ]Append[cname] | 989 ]Append[cname] |
972 ]Append[",\n\tNumParams "] | 990 ]Append[",\n\tNumParams "] |
973 ]Append[ [[func]Inputs >>]Length ] | 991 ]Append[ [[func]Inputs >>]Length ] |
974 ]Append[")\n\n"] | 992 ]Append[")\n\n"] |
975 ]Append[param check] | 993 ]Append[param check] |
976 ]Append[ [[func]Statements >>]Join[""] ] | 994 ]Append[ [[func]Statements >>]Join[""] ] |
995 ]Append[freecall] | |
977 ]Append[[func]Set Outputs] | 996 ]Append[[func]Set Outputs] |
978 ]Append[[["EndFunc("]Append[fname]]Append[")"]] | 997 ]Append[[["EndFunc("]Append[fname]]Append[")\n"]] |
998 ]Append["DISPATCH"] | |
979 } | 999 } |
980 }{ | 1000 }{ |
981 | 1001 |
982 out <- [[[ | 1002 out <- [[[ |
983 Fold[["_Output Defs C"]Set Input[3, func], | 1003 Fold[["_Output Defs C"]Set Input[3, func], |
1147 }{ | 1167 }{ |
1148 out <- text | 1168 out <- text |
1149 } | 1169 } |
1150 } | 1170 } |
1151 | 1171 |
1172 _Dispatch Switch Methods[text,id,raw name:out] | |
1173 { | |
1174 name <- Escape Rhope Name[raw name] | |
1175 out <- [text]Append[ [[[["\tcase FUNC_"]Append[name]]Append[": goto f_"]]Append[name]]Append[";\\\n"] ] | |
1176 } | |
1177 | |
1152 _Dispatch Enum Sub[text, num, name:out] | 1178 _Dispatch Enum Sub[text, num, name:out] |
1153 { | 1179 { |
1154 out <- [[[[[text | 1180 out <- [[[[[text |
1155 ]Append["\tRES_"] | 1181 ]Append["\tRES_"] |
1156 ]Append[num] | 1182 ]Append[num] |
1169 }{ | 1195 }{ |
1170 out <- text | 1196 out <- text |
1171 } | 1197 } |
1172 } | 1198 } |
1173 | 1199 |
1174 Dispatch@C Program[program:out] | 1200 _Dispatch Enum Methods[text,types,name:out] |
1201 { | |
1202 out <- [text]Append[ [["\tFUNC_"]Append[Escape Rhope Name[name]]]Append[",\n"] ] | |
1203 } | |
1204 | |
1205 Dispatch@C Program[program,all methods:out] | |
1175 { | 1206 { |
1176 out <- [[[[["typedef enum {\n" | 1207 out <- [[[[["typedef enum {\n" |
1177 ]Append[Fold["_Dispatch Enum", "", [program]Functions >>]] | 1208 ]Append[Fold["_Dispatch Enum", |
1209 [Fold["_Dispatch Enum Methods", "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n"], | |
1210 [program]Functions >>]] | |
1178 ]Append["\tEND\n} funcids;\n\n"] | 1211 ]Append["\tEND\n} funcids;\n\n"] |
1179 ]Append["#define DISPATCH switch(func) { \\\n"] | 1212 ]Append["#define DISPATCH switch(func) { \\\n"] |
1180 ]Append[Fold["_Dispatch Switch", "", [program]Functions >>]] | 1213 ]Append[Fold["_Dispatch Switch", |
1214 [Fold["_Dispatch Switch Methods", "", all methods]]Append["\tcase FUNC_Build: goto f_Build;\\\n\tcase FUNC_BlueprintSP_Of: goto f_BlueprintSP_Of;\\\n"], | |
1215 [program]Functions >>]] | |
1181 ]Append["\tcase END: goto DO_END;\\\n}\n\n"] | 1216 ]Append["\tcase END: goto DO_END;\\\n}\n\n"] |
1182 } | 1217 } |
1183 | 1218 |
1184 Not Native[func:out] | 1219 Not Native[func:out] |
1185 { | 1220 { |
1191 Native[func:out] | 1226 Native[func:out] |
1192 { | 1227 { |
1193 out <- [[func]Convention >>] = ["rhope"] | 1228 out <- [[func]Convention >>] = ["rhope"] |
1194 } | 1229 } |
1195 | 1230 |
1231 Local Pointers[text,func:out] | |
1232 { | |
1233 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] | |
1234 { | |
1235 out <- text | |
1236 }{ | |
1237 out <- [text]Append[[["\tFuncDef("]Append[Escape Rhope Name[[func]Name >>]]]Append[")\n"]] | |
1238 } | |
1239 } | |
1240 | |
1241 _Method to Types[dict,name,type:out] | |
1242 { | |
1243 typelist <- [dict]Index[name] {} | |
1244 { typelist <- () } | |
1245 | |
1246 out <- [dict]Set[name, [typelist]Append[[type]Name >>]] | |
1247 | |
1248 } | |
1249 | |
1250 _Field to Types[dict,field,type:out] | |
1251 { | |
1252 name <- [field]Index[0] | |
1253 out <- _Method to Types[_Method to Types[dict, [name]Append[" >>"], type], [name]Append[" <<"], type] | |
1254 | |
1255 } | |
1256 | |
1257 Method to Types[dict,type:out] | |
1258 { | |
1259 out <- Fold[["_Method to Types"]Set Input[2, type], dict, [type]Methods >>] | |
1260 } | |
1261 | |
1262 Field to Types[dict,type:out] | |
1263 { | |
1264 out <- Fold[["_Field to Types"]Set Input[2, type], dict, [type]Fields >>] | |
1265 } | |
1266 | |
1267 _Method Dispatch[text, type, method, reg: out] | |
1268 { | |
1269 out <- [[[[[[[text]Append["\tMethodDispatch("]]Append[ [reg]Type ID[type] ]]Append[","]]Append[Escape Rhope Name[method]]]Append[","]]Append[Escape Rhope Name[type]]]Append[")\n"] | |
1270 } | |
1271 | |
1272 Method Dispatch[text, types, method, reg: out] | |
1273 { | |
1274 out <- [[[Fold[[["_Method Dispatch"]Set Input[2, method]]Set Input[3, reg], [[[text]Append["Method("]]Append[ Escape Rhope Name[method] ]]Append[")\n"], types] | |
1275 ]Append["EndMethod("] | |
1276 ]Append[Escape Rhope Name[method]] | |
1277 ]Append[")\n\n"] | |
1278 } | |
1279 | |
1196 Text@C Program[program:out] | 1280 Text@C Program[program:out] |
1197 { | 1281 { |
1198 Print["Text@C Program"] | 1282 Print["Text@C Program"] |
1283 type defs <- [[program]Type Registry >>]Definitions >> | |
1199 constants <- Fold["Combine Consts", Dictionary[], [program]Functions >>] | 1284 constants <- Fold["Combine Consts", Dictionary[], [program]Functions >>] |
1285 all methods <- Fold["Field to Types", Fold["Method to Types", Dictionary[], type defs], type defs] | |
1200 headers <- "#include <stdio.h> | 1286 headers <- "#include <stdio.h> |
1287 #include <stdlib.h> | |
1201 #include \"builtin.h\" | 1288 #include \"builtin.h\" |
1202 #include \"object.h\" | 1289 #include \"object.h\" |
1203 #include \"context.h\" | 1290 #include \"context.h\" |
1204 #include \"func.h\" | 1291 #include \"func.h\" |
1205 #include \"integer.h\" | 1292 #include \"integer.h\" |
1206 #include \"blueprint.h\" | 1293 #include \"blueprint.h\" |
1207 #include \"array.h\" | 1294 #include \"array.h\" |
1208 #include \"bool.h\"\n\n" | 1295 #include \"bool.h\"\n\n" |
1209 out <- [[[[[[[[[[[headers | 1296 out <- [[[[[[[[[[[[[[[headers |
1210 ]Append[[program]Dispatch] | 1297 ]Append[[program]Dispatch[all methods]] |
1211 ]Append[[[program]Type Registry >>]Type Defs] | 1298 ]Append[[[program]Type Registry >>]Type Defs] |
1212 ]Append[Fold["_Consts C Program", | 1299 ]Append[Fold["_Consts C Program", |
1213 Fold["_Defs C Program", "", [program]Functions >>], | 1300 Fold["_Defs C Program", "", [program]Functions >>], |
1214 constants]] | 1301 constants]] |
1215 ]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], "", Filter[[program]Functions >>, "Not Native"]]] | 1302 ]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], "", Filter[[program]Functions >>, "Not Native"]]] |
1216 ]Append["\n | 1303 ]Append["\n |
1217 void rhope(uint32_t func) | 1304 uint16_t rhope(uint32_t func, object ** params, uint16_t numparams, uint16_t callspace) |
1218 { | 1305 { |
1219 uint16_t resume,idx; | 1306 uint16_t resume,idx; |
1220 context * ct; | 1307 context * ct; |
1221 calldata * cdata, *temp_cdata;"] | 1308 calldata * cdata, *temp_cdata, *my_cdata;\n\nFuncDef(Build)\nFuncDef(BlueprintSP_Of)\n"] |
1309 ]Append[Fold["Local Pointers", "", [program]Functions >>]] | |
1310 ]Append[" | |
1311 ct = new_context(); | |
1312 cdata = alloc_cdata(ct, NULL, callspace); | |
1313 cdata->num_params = numparams; | |
1314 for(idx = 0; idx < numparams; ++idx) | |
1315 cdata->params[0-idx] = params[idx]; | |
1316 cdata->func = END; | |
1317 DISPATCH\n"] | |
1318 ]Append[Fold[["Method Dispatch"]Set Input[3, [program]Type Registry >>], "", all methods]] | |
1319 ]Append[" | |
1320 Func(Build, | |
1321 NumParams 1) | |
1322 | |
1323 Param(0, TYPE_BLUEPRINT) | |
1324 | |
1325 lv_Build->bp = ((t_Blueprint *)(cdata->params[0]))->bp; | |
1326 release_ref(cdata->params[0]); | |
1327 | |
1328 Ret(0, new_object_bp(lv_Build->bp)) | |
1329 EndFunc(Build) | |
1330 DISPATCH | |
1331 | |
1332 Func(BlueprintSP_Of, | |
1333 NumParams 1) | |
1334 | |
1335 lv_BlueprintSP_Of->bp = get_blueprint(cdata->params[0]); | |
1336 release_ref(cdata->params[0]); | |
1337 | |
1338 Ret(0, new_object(TYPE_BLUEPRINT)) | |
1339 ((t_Blueprint *)cdata->params[0])->bp = lv_BlueprintSP_Of->bp; | |
1340 EndFunc(BlueprintSP_Of) | |
1341 DISPATCH\n"] | |
1222 ]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], "", Filter[[program]Functions >>, "Native"]]] | 1342 ]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], "", Filter[[program]Functions >>, "Native"]]] |
1223 ]Append["\n\nint main(int argc, char **argv) | 1343 ]Append[" |
1224 { | 1344 DO_END: |
1345 for(idx = 0; idx < cdata->num_params; ++idx) | |
1346 params[idx] = cdata->params[0-idx]; | |
1347 free_context(ct); | |
1348 return cdata->num_params; | |
1349 | |
1350 _exception: | |
1351 puts(\"Exception! Trace follows:\"); | |
1352 while(cdata && cdata->func != END) | |
1353 { | |
1354 printf(\"%d\\n\", cdata->func); | |
1355 cdata = cdata->lastframe; | |
1356 } | |
1357 return 0; | |
1358 } | |
1359 | |
1360 #include \"builtin.c\" | |
1361 #include \"array.c\" | |
1362 | |
1363 int main(int argc, char **argv) | |
1364 { | |
1365 blueprint * bp; | |
1225 register_builtin_types();\n\n"] | 1366 register_builtin_types();\n\n"] |
1226 ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ] | 1367 ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ] |
1227 ]Append[Fold[["_Set Consts C Program"]Set Input[3, [program]Type Registry >>], "", constants]] | 1368 ]Append[Fold[["_Set Consts C Program"]Set Input[3, [program]Type Registry >>], "", constants]] |
1228 ]Append[Fold[["_Set Late Consts C"]Set Input[3, [program]Type Registry >>], "", constants]] | 1369 ]Append[Fold[["_Set Late Consts C"]Set Input[3, [program]Type Registry >>], "", constants]] |
1229 ]Append[" | 1370 ]Append[" |
1230 rhope(FUNC_Main); | 1371 rhope(FUNC_Main, NULL, 0, 0); |
1231 return 0; | 1372 return 0; |
1232 }\n\n"] | 1373 }\n\n"] |
1233 | 1374 |
1234 } | 1375 } |
1235 | 1376 |