comparison cbackend.rhope @ 186:ba35ab624ec2

Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
author Mike Pavone <pavone@retrodev.com>
date Fri, 07 Oct 2011 00:10:02 -0700
parents c6ba9fe45910
children
comparison
equal deleted inserted replaced
185:4580c08fd4e8 186:ba35ab624ec2
598 598
599 599
600 600
601 601
602 602
603
603 Do AddRef@C Function[func,psource,pdest:out] 604 Do AddRef@C Function[func,psource,pdest:out]
604 { 605 {
605 source <- [psource]Make Op[func] 606 source <- [psource]Make Op[func]
606 dest <- [pdest]Make Op[func] 607 dest <- [pdest]Make Op[func]
607 out <- [func]Add Statement[[[[dest]Append[" = add_ref((object *)"]]Append[source]]Append[")"]] 608 out <- [func]Add Statement[[[[dest]Append[" = add_ref((object *)"]]Append[source]]Append[")"]]
696 697
697 Global Reference@C Function[func,store,var:out] 698 Global Reference@C Function[func,store,var:out]
698 { 699 {
699 700
700 estore <- Escape Rhope Name[store,[func]Escape Pattern >>] 701 estore <- Escape Rhope Name[store,[func]Escape Pattern >>]
701 out <- [[[[[ [["((mutt_"]Append[estore]]Append["*)lv_"]]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->gs_"]]Append[estore]]Append["->local_data)->gs_"]]Append[Escape Rhope Name[var,[func]Escape Pattern >>]] 702 out <- [[[[[ [["((mutt_"]Append[estore]]Append["*)lv("]]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", gs_"]]Append[estore]]Append[")->local_data)->gs_"]]Append[Escape Rhope Name[var,[func]Escape Pattern >>]]
702 } 703 }
703 704
704 Set Global@C Function[func,store,var,src:out] 705 Set Global@C Function[func,store,var,src:out]
705 { 706 {
706 estore <- Escape Rhope Name[store,[func]Escape Pattern >>] 707 estore <- Escape Rhope Name[store,[func]Escape Pattern >>]
707 cell pointer <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->gs_"]]Append[estore] 708 cell pointer <- [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", gs_"]]Append[estore]]Append[")"]
708 out <- [[[[func]Add Statement[[["tmp = copy_object("]Append[[cell pointer]Append["->local_data"]]]Append[")"]] 709 out <- [[[[func]Add Statement[[["tmp = copy_object("]Append[[cell pointer]Append["->local_data"]]]Append[")"]]
709 ]Add Statement[ [[[["((mutt_"]Append[estore]]Append[" *)tmp)->gs_"]]Append[Escape Rhope Name[var, [func]Escape Pattern >>]]]Append[[" = "]Append[[src]Make Op[func]]] ] 710 ]Add Statement[ [[[["((mutt_"]Append[estore]]Append[" *)tmp)->gs_"]]Append[Escape Rhope Name[var, [func]Escape Pattern >>]]]Append[[" = "]Append[[src]Make Op[func]]] ]
710 ]Add Statement[[cell pointer]Append["->local_data = tmp"]] 711 ]Add Statement[[cell pointer]Append["->local_data = tmp"]]
711 ]Add Statement[[cell pointer]Append["->local_version++"]] 712 ]Add Statement[[cell pointer]Append["->local_version++"]]
712 } 713 }
949 { 950 {
950 If[[[func]Convention >>] = ["rhope"]] 951 If[[[func]Convention >>] = ["rhope"]]
951 { 952 {
952 [[func]Inputs >>]Find[=[op,?]] 953 [[func]Inputs >>]Find[=[op,?]]
953 { 954 {
954 out <- [["my_cdata->params["]Append[String[~]]]Append[" ]"] 955 out <- [["my_params("]Append[String[~]]]Append[")"]
955 }{ 956 }{
956 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->"]]Append[Escape Rhope Name[op,[func]Escape Pattern >>]] 957 out <- [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", "]]Append[Escape Rhope Name[op,[func]Escape Pattern >>]]]Append[")"]
957 } 958 }
958 }{ 959 }{
959 out <- Escape Rhope Name[op,[func]Escape Pattern >>] 960 out <- Escape Rhope Name[op,[func]Escape Pattern >>]
960 } 961 }
961 } 962 }
962 963
963 Resolve Output@C Function[func,name:out] 964 Resolve Output@C Function[func,name:out]
964 { 965 {
965 If[[[func]Convention >>] = ["rhope"]] 966 If[[[func]Convention >>] = ["rhope"]]
966 { 967 {
967 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->"]]Append[Escape Rhope Name[name,[func]Escape Pattern >>]] 968 out <- [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", "]]Append[Escape Rhope Name[name,[func]Escape Pattern >>]]]Append[")"]
968 }{ 969 }{
969 out <- Escape Rhope Name[name,[func]Escape Pattern >>] 970 out <- Escape Rhope Name[name,[func]Escape Pattern >>]
970 } 971 }
971 } 972 }
972 973
1000 } 1001 }
1001 1002
1002 Discard Outputs@C Function[func,first to discard:out] 1003 Discard Outputs@C Function[func,first to discard:out]
1003 { 1004 {
1004 out <- [[[[[func 1005 out <- [[[[[func
1005 ]Add Raw Line[[["for(idx = "]Append[String[first to discard]]]Append["; idx < cdata->num_params; ++idx)"]] 1006 ]Add Raw Line[[["for(idx = "]Append[String[first to discard]]]Append["; idx < numresults; ++idx)"]]
1006 ]Add Raw Line["{"] 1007 ]Add Raw Line["{"]
1007 ]Add Raw Line[" if (cdata->params[idx])"] 1008 ]Add Raw Line[" if (result(idx))"]
1008 ]Add Raw Line[" release_ref(cdata->params[idx]);"] 1009 ]Add Raw Line[" release_ref(result(idx));"]
1009 ]Add Raw Line["}"] 1010 ]Add Raw Line["}"]
1010 } 1011 }
1011 1012
1012 Result Reference@C Function[func,output:out] 1013 Result Reference@C Function[func,output:out]
1013 { 1014 {
1014 out <- [["cdata->params["]Append[String[output]]]Append["]"] 1015 out <- [["result("]Append[String[output]]]Append[")"]
1015 } 1016 }
1016 1017
1017 Checked Result Reference@C Function[func,output:out] 1018 Checked Result Reference@C Function[func,output:out]
1018 { 1019 {
1019 out <- [[[["("]Append[String[output]]]Append[" < cdata->num_params ? cdata->params["]]Append[String[output]]]Append["] : NULL)"] 1020 out <- [[[["("]Append[String[output]]]Append[" < numresults ? result("]]Append[String[output]]]Append[") : NULL)"]
1020 } 1021 }
1021 1022
1022 1023
1023 If Null Else@C Function[func,left,right:out] 1024 If Null Else@C Function[func,left,right:out]
1024 { 1025 {
1034 ]Append[")"] 1035 ]Append[")"]
1035 } 1036 }
1036 1037
1037 _Set Outputs C[string,inputname,inputnum,func:out] 1038 _Set Outputs C[string,inputname,inputnum,func:out]
1038 { 1039 {
1039 out <- [string]Append[[[ [ ["\tRet("]Append[String[inputnum]] ]Append[ [[", lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->"]]]Append[Escape Rhope Name[inputname,[func]Escape Pattern >>]]]Append[")\n"]] 1040 out <- [string]Append[[[ [ ["\tRet("]Append[String[inputnum]] ]Append[ [[", lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", "]]]Append[Escape Rhope Name[inputname,[func]Escape Pattern >>]]]Append["))\n"]]
1040 } 1041 }
1041 1042
1042 Set Outputs@C Function[func:out] 1043 Set Outputs@C Function[func:out]
1043 { 1044 {
1044 If[[[func]Convention >>] = ["rhope"]] 1045 If[[[func]Convention >>] = ["rhope"]]
1053 } 1054 }
1054 } 1055 }
1055 } 1056 }
1056 _Output Defs C[string,varname,index,func:out] 1057 _Output Defs C[string,varname,index,func:out]
1057 { 1058 {
1058 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[[[func]Output Types >>]Index[index],[func]Escape Pattern >>]] ]]Append[[" "]Append[Escape Rhope Name[varname,[func]Escape Pattern >>]]]]Append[";\n"] 1059 out <- [[[string]Append[ [" lvar("]Append[Rhope Type to C[[[func]Output Types >>]Index[index],[func]Escape Pattern >>]] ]]Append[[", "]Append[Escape Rhope Name[varname,[func]Escape Pattern >>]]]]Append[")"]
1059 } 1060 }
1060 _Var Defs C[string,type,varname,p:out] 1061 _Var Defs C[string,type,varname,p:out]
1061 { 1062 {
1062 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[type,p]] ]]Append[[" "]Append[Escape Rhope Name[varname,p]]]]Append[";\n"] 1063 out <- [[[string]Append[ [" lvar("]Append[Rhope Type to C[type,p]] ]]Append[[", "]Append[Escape Rhope Name[varname,p]]]]Append[")"]
1063 } 1064 }
1064 _Global Cell Defs C[func,p,string,store:out] 1065 _Global Cell Defs C[func,p,string,store:out]
1065 { 1066 {
1066 out <- [string]Append[ [["\ttrans_cell *gs_"]Append[Escape Rhope Name[store,p]]]Append[";\n"] ] 1067 out <- [string]Append[ [[" lvar(trans_cell *, gs_"]Append[Escape Rhope Name[store,p]]]Append[")"] ]
1067 } 1068 }
1068 1069
1069 1070
1070 Definitions@C Function[func:out] 1071 Definitions@C Function[func:out]
1071 { 1072 {
1072 Print[["Definitions@C Function: "]Append[[func]Name >>]] 1073 Print[["Definitions@C Function: "]Append[[func]Name >>]]
1073 { 1074 {
1074 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ] 1075 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ]
1075 { 1076 {
1076 localtype <- [[[Fold[_Global Cell Defs C[func,[func]Escape Pattern >>,?], Fold[_Output Defs C[?, ?, ?, func], Fold[_Var Defs C[?,?,?,[func]Escape Pattern >>],"typedef struct {\n", [func]Variables >>], [func]Outputs >>], [func]Uses >>]]Append["} lt_"]]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[";\n"] 1077 ename <- Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]
1078 localtype <- [
1079 [
1080 [
1081 Fold[
1082 _Global Cell Defs C[func,[func]Escape Pattern >>,?],
1083 Fold[
1084 _Output Defs C[?, ?, ?, func],
1085 Fold[
1086 _Var Defs C[?,?,?,[func]Escape Pattern >>],
1087 ["#define ldec_"]Append[ename],
1088 [func]Variables >>],
1089 [func]Outputs >>],
1090 [func]Uses >>]
1091 ]Append["\nLocalsType(ldec_"]]Append[ename]
1092 ]Append[ [[", "]Append[ename]]Append[")\n"] ]
1077 }{ 1093 }{
1078 localtype <- "" 1094 localtype <- ""
1079 } 1095 }
1080 1096
1081 If[ [[func]Convention >>] = ["rhope"] ] 1097 If[ [[func]Convention >>] = ["rhope"] ]
1145 } 1161 }
1146 1162
1147 Find Trans Cell@C Function[func,text,store:out] 1163 Find Trans Cell@C Function[func,text,store:out]
1148 { 1164 {
1149 estore <- Escape Rhope Name[store,[func]Escape Pattern >>] 1165 estore <- Escape Rhope Name[store,[func]Escape Pattern >>]
1150 out <- [text]Append[ [[[["lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->gs_"]]Append[estore]]Append[[[" = find_obj_cell(ct->transaction, gs_"]Append[estore]]Append[");\n"]] ] 1166 out <- [text]Append[ [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", gs_"]]Append[estore]]Append[[[") = find_obj_cell(cur_transaction, gs_"]Append[estore]]Append[");\n"]] ]
1151 } 1167 }
1152 1168
1153 Text@C Function[func:out] 1169 Text@C Function[func:out]
1154 { 1170 {
1155 Print[["Text@C Function: "]Append[[func]Name >>]] 1171 Print[["Text@C Function: "]Append[[func]Name >>]]
1175 }{ 1191 }{
1176 freecall <- "\n\tFreeCall\n" 1192 freecall <- "\n\tFreeCall\n"
1177 } 1193 }
1178 If[ [ [[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]]+[[[func]Uses >>]Length] ] = [0] ] 1194 If[ [ [[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]]+[[[func]Uses >>]Length] ] = [0] ]
1179 { 1195 {
1180 out <- [[[[[[[[[ [type]Append["NoLocals("] 1196 out <- [[[[[[[[[[[ [type]Append["NoLocals("]
1181 ]Append[cname] 1197 ]Append[cname]
1182 ]Append[",\n\tNumParams "] 1198 ]Append[",\n\tNumParams "]
1183 ]Append[ String[[[func]Inputs >>]Length] ] 1199 ]Append[ String[[[func]Inputs >>]Length] ]
1200 ]Append[",\n\tNumOutputs "]
1201 ]Append[ String[[[func]Outputs >>]Length] ]
1184 ]Append[")\n\n"] 1202 ]Append[")\n\n"]
1185 ]Append[param check] 1203 ]Append[param check]
1186 ]Append[ [[func]Statements >>]Join[""] ] 1204 ]Append[ [[func]Statements >>]Join[""] ]
1187 ]Append[freecall] 1205 ]Append[freecall]
1188 ]Append["EndFuncNoLocals\n"] 1206 ]Append["EndFuncNoLocals\n"]
1191 If[[[func]Uses >>]Length] 1209 If[[[func]Uses >>]Length]
1192 { 1210 {
1193 begin trans <- [[[["\tbegin_transaction(ct, "]Append[ String[[[func]Uses >>]Length] ]]Append[", "]]Append[ [Map[Map[[func]Uses >>, Escape Rhope Name[?, [func]Escape Pattern >>]], ["gs_"]Append[?]]]Join[", "] ]]Append[");\n"] 1211 begin trans <- [[[["\tbegin_transaction(ct, "]Append[ String[[[func]Uses >>]Length] ]]Append[", "]]Append[ [Map[Map[[func]Uses >>, Escape Rhope Name[?, [func]Escape Pattern >>]], ["gs_"]Append[?]]]Join[", "] ]]Append[");\n"]
1194 init trans <- [[Fold[Find Trans Cell[func,?], begin trans, [func]Uses >>] 1212 init trans <- [[Fold[Find Trans Cell[func,?], begin trans, [func]Uses >>]
1195 ]Append[[["transretry_"]Append[fname]]Append[":\n"]] 1213 ]Append[[["transretry_"]Append[fname]]Append[":\n"]]
1196 ]Append["\tfor(idx = 0; idx < cdata->num_params; ++idx) { add_ref(cdata->params[idx]); }\n"] 1214 ]Append[ [["\tfor(idx = 0; idx < "]Append[String[[[func]Inputs >>]Length]]]Append["; ++idx) { add_ref(my_params(idx)); }\n"] ]
1197 //TODO: Figure out whether this is a readonly or write transaction 1215 //TODO: Figure out whether this is a readonly or write transaction
1198 commit trans <- [[["\tif(!commit_transaction(ct, 0)) { prep_retry(ct); goto transretry_"]Append[fname]]Append["; }\n"] 1216 commit trans <- [[["\tif(!commit_transaction(ct, 0)) { prep_retry(ct); goto transretry_"]Append[fname]]Append["; }\n"]
1199 ]Append["\tfor(idx = 0; idx < cdata->num_params; ++idx) { release_ref(cdata->params[idx]); }\n"] 1217 ]Append[ [["\tfor(idx = 0; idx < "]Append[String[[[func]Inputs >>]Length]]]Append["; ++idx) { release_ref(my_params(idx)); }\n"] ]
1200 }{ 1218 }{
1201 init trans <- "" 1219 init trans <- ""
1202 commit trans <- "" 1220 commit trans <- ""
1203 } 1221 }
1204 out <- [[[[[[[[[[[[ [type]Append["("] 1222 out <- [[[[[[[[[[[[[[ [type]Append["("]
1205 ]Append[cname] 1223 ]Append[cname]
1206 ]Append[",\n\tNumParams "] 1224 ]Append[",\n\tNumParams "]
1207 ]Append[ String[[[func]Inputs >>]Length] ] 1225 ]Append[ String[[[func]Inputs >>]Length] ]
1226 ]Append[",\n\tNumOutputs "]
1227 ]Append[ String[[[func]Outputs >>]Length] ]
1208 ]Append[")\n\n"] 1228 ]Append[")\n\n"]
1209 ]Append[param check] 1229 ]Append[param check]
1210 ]Append[init trans] 1230 ]Append[init trans]
1211 ]Append[ [[func]Statements >>]Join[""] ] 1231 ]Append[ [[func]Statements >>]Join[""] ]
1212 ]Append[freecall] 1232 ]Append[freecall]
1517 } 1537 }
1518 1538
1519 _Dispatch Enum Sub[text, num, name:out] 1539 _Dispatch Enum Sub[text, num, name:out]
1520 { 1540 {
1521 out <- [[[[[text 1541 out <- [[[[[text
1522 ]Append["\tRES_"] 1542 ]Append["\tResEnum("]
1523 ]Append[String[num]] 1543 ]Append[String[num]]
1524 ]Append["_"] 1544 ]Append[", "]
1525 ]Append[name] 1545 ]Append[name]
1526 ]Append[",\n"] 1546 ]Append[")\n"]
1527 } 1547 }
1528 1548
1529 _Dispatch Enum[text,func,raw name:out] 1549 _Dispatch Enum[text,func,raw name:out]
1530 { 1550 {
1531 If[[[func]Convention >>] = ["rhope"]] 1551 If[[[func]Convention >>] = ["rhope"]]
1545 1565
1546 Dispatch@C Program[program,all methods:out] 1566 Dispatch@C Program[program,all methods:out]
1547 { 1567 {
1548 out <- [[[[["typedef enum {\n" 1568 out <- [[[[["typedef enum {\n"
1549 ]Append[Fold[_Dispatch Enum[?], 1569 ]Append[Fold[_Dispatch Enum[?],
1550 [Fold[_Dispatch Enum Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n\tFUNC_Pause,\n\tRES_1_Pause,\n\tFUNC_Resume,\n\tFUNC_RunSP_Bytecode,\n\tRES_1_RunSP_Bytecode,\n"], 1570 [Fold[_Dispatch Enum Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n\tFUNC_Pause,\n\tResEnum(1, Pause)\n\tFUNC_Resume,\n\tFUNC_RunSP_Bytecode,\n\tResEnum(1, RunSP_Bytecode)\n"],
1551 [program]Functions >>]] 1571 [program]Functions >>]]
1552 ]Append["\tEND,\n\tEND_THREAD\n} funcids;\n\n"] 1572 ]Append["\tEND,\n\tEND_THREAD\n} funcids;\n\n"]
1553 ]Append["#define DispatchEntries \\\n"] 1573 ]Append["#define DispatchEntries \\\n"]
1554 ]Append[Fold[_Dispatch Switch[?], 1574 ]Append[Fold[_Dispatch Switch[?],
1555 [Fold[_Dispatch Switch Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n\tDispatchEntry(Pause)\\\n\tResumeEntry(1,Pause)\\\n\tDispatchEntry(Resume)\\\n\tDispatchEntry(RunSP_Bytecode)\\\n\tResumeEntry(1,RunSP_Bytecode)\\\n"], 1575 [Fold[_Dispatch Switch Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n\tDispatchEntry(Pause)\\\n\tResumeEntry(1,Pause)\\\n\tDispatchEntry(Resume)\\\n\tDispatchEntry(RunSP_Bytecode)\\\n\tResumeEntry(1,RunSP_Bytecode)\\\n"],
1573 { 1593 {
1574 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] 1594 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ]
1575 { 1595 {
1576 out <- text 1596 out <- text
1577 }{ 1597 }{
1578 out <- [text]Append[[["\tFuncDef("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[")\n"]] 1598 If[[[func]Name >>]Contains["@"]]
1599 {
1600 deftype <- "\tMethodDef("
1601 }{
1602 deftype <- "\tFuncDef("
1603 }
1604 out <- [text]Append[[[deftype]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[")\n"]]
1579 } 1605 }
1580 } 1606 }
1581 1607
1582 _Method to Types[dict,name,type:out] 1608 _Method to Types[dict,name,type:out]
1583 { 1609 {
1671 1697
1672 #include \"builtin.c\" 1698 #include \"builtin.c\"
1673 #include \"array.c\" 1699 #include \"array.c\"
1674 #include \"worker.c\" 1700 #include \"worker.c\"
1675 1701
1676 int main(int argc, char **argv) 1702 #include \"main_start.c\" \n\n"]
1677 {
1678 blueprint * bp;
1679 int numret;
1680 int idx;
1681 object * inout[3];
1682 register_builtin_types();
1683 register_type_byid(TYPE_MUTABLEGLOBAL, sizeof(mutable_object)-sizeof(object), NULL, NULL, NULL);\n\n"]
1684 ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ] 1703 ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ]
1685 ]Append[Fold[_Global Type Inits C[?, ?, p], "", [program]Global Stores >>]] 1704 ]Append[Fold[_Global Type Inits C[?, ?, p], "", [program]Global Stores >>]]
1686 ]Append[Fold[_Set Consts C Program[?, ?, ?, [program]Type Registry >>], "", constants]] 1705 ]Append[Fold[_Set Consts C Program[?, ?, ?, [program]Type Registry >>], "", constants]]
1687 ]Append[Fold[_Set Late Consts C[?, ?, ?, [program]Type Registry >>], "", constants]] 1706 ]Append[Fold[_Set Late Consts C[?, ?, ?, [program]Type Registry >>], "", constants]]
1688 ]Append[Fold[_Global Store Inits C[?, ?, [program]Type Registry >>], "", [program]Global Stores >>]] 1707 ]Append[Fold[_Global Store Inits C[?, ?, [program]Type Registry >>], "", [program]Global Stores >>]]
1689 ]Append[Fold[Init Type Names[?, ?, ?, [program]Type Registry >>], "", [[program]Type Registry >>]Lookup >>]] 1708 ]Append[Fold[Init Type Names[?, ?, ?, [program]Type Registry >>], "", [[program]Type Registry >>]Lookup >>]]
1690 ]Append[" 1709 ]Append["
1691 rhope(FUNC_List, inout, 0, 1); 1710 #include \"main_mid.c\"
1692 for (idx = 0; idx < argc; ++idx) 1711
1693 { 1712 #ifdef ENABLE_LEAK_DETECTION\n\n"]
1694 inout[1] = make_String(argv[idx]);
1695 rhope(FUNC_Append, inout, 2, 2);
1696 }
1697 numret = rhope(FUNC_Main, inout, 1, 1);
1698 #ifdef ENABLE_LEAK_DETECTION\n"]
1699 ]Append[Fold[_Consts C Release[?, ?, ?, p], "", constants]] 1713 ]Append[Fold[_Consts C Release[?, ?, ?, p], "", constants]]
1700 ]Append[ 1714 ]Append[
1701 " 1715 "
1702 print_mem_info(manager); 1716 print_mem_info(manager);
1703 print_live_object_types(manager); 1717 print_live_object_types(manager);
1704 #endif //ENABLE_LEAK_DETECTION 1718 #endif //ENABLE_LEAK_DETECTION
1705 1719 #include \"main_end.c\"\n\n"]
1706 #ifdef ENABLE_PROFILING 1720
1707 for (idx = 0; idx < END; ++idx) 1721 }
1708 { 1722
1709 if(profile_counts[idx]) 1723
1710 printf(\"Func: %d\tCount: %llu\tTime: %llu\tAvg: %f\tSelf: %llu\tAvg: %f\tNested Count: %llu\\n\", idx, profile_counts[idx], profile_totals[idx], ((double)profile_totals[idx])/((double)profile_counts[idx]), profile_selftotals[idx], ((double)profile_selftotals[idx])/((double)profile_counts[idx]), profile_nestedcounts[idx]);
1711 }
1712 #endif
1713 if (!numret)
1714 return 0;
1715 if (numret < 0)
1716 return numret;
1717 if (get_blueprint(inout[0])->type_id == TYPE_INT32)
1718 return ((t_Int32 *)inout[0])->Num;
1719
1720 rhope(FUNC_If, inout, 1, 2);
1721 if (inout[0])
1722 return 0;
1723 return 1;
1724 }\n\n"]
1725
1726 }
1727
1728