Mercurial > repos > rhope
comparison cbackend_c.rhope @ 142:7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 21 Nov 2010 16:33:17 -0500 |
parents | f2cb85c53ced |
children | f3686f60985d |
comparison
equal
deleted
inserted
replaced
141:f2cb85c53ced | 142:7bbdc034e347 |
---|---|
152 { | 152 { |
153 primitive <- Yes | 153 primitive <- Yes |
154 [[type]Name >>]Slice[3] {} | 154 [[type]Name >>]Slice[3] {} |
155 { typename <- [["int"]Append[~]]Append["_t"] } | 155 { typename <- [["int"]Append[~]]Append["_t"] } |
156 }{ | 156 }{ |
157 ,regulartype <- [("UInt64","UInt32","UInt16","UInt8")]Find[=[[type]Name >>,?]] | 157 [("UInt64","UInt32","UInt16","UInt8")]Find[=[[type]Name >>,?]] |
158 { | 158 { |
159 primitive <- Yes | 159 primitive <- Yes |
160 [[type]Name >>]Slice[4] {} | 160 [[type]Name >>]Slice[4] {} |
161 { typename <- [["uint"]Append[~]]Append["_t"] } | 161 { typename <- [["uint"]Append[~]]Append["_t"] } |
162 }{ | |
163 ,regulartype <- If[[[type]Name >>]=["Context"]] | |
164 { | |
165 typename <- "context *" | |
166 primitive <- Yes | |
167 } | |
162 } | 168 } |
163 } | 169 } |
164 } | 170 } |
165 | 171 |
166 Val[regulartype] | 172 Val[regulartype] |
776 | 782 |
777 Val Call@C Function[func,to call,args:out] | 783 Val Call@C Function[func,to call,args:out] |
778 { | 784 { |
779 worker <- Make Op[Strip Addref[to call], func] | 785 worker <- Make Op[Strip Addref[to call], func] |
780 rargs <- Map[args, Make Op[?, func]] | 786 rargs <- Map[args, Make Op[?, func]] |
787 | |
788 If[[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]] | |
789 { | |
790 valcall <- "ValCall(" | |
791 postlude <- "ValCallPostlude(" | |
792 }{ | |
793 valcall <- "ValCallNoLocals(" | |
794 postlude <- "ValCallNoLocalsPostlude(" | |
795 } | |
781 | 796 |
782 If[[[func]Last NumParams >>] = [-1]] | 797 If[[[func]Last NumParams >>] = [-1]] |
783 { | 798 { |
784 prepped <- [[func]Add Raw Line[ | 799 prepped <- [[func]Add Raw Line[ |
785 [[[["VCPrepCall(" | 800 [[[["VCPrepCall(" |
801 } | 816 } |
802 | 817 |
803 | 818 |
804 out <- [[[[Fold[_Val Function Arg C[?, ?, ?, worker], prepped, rargs] | 819 out <- [[[[Fold[_Val Function Arg C[?, ?, ?, worker], prepped, rargs] |
805 ]Add Raw Line[ | 820 ]Add Raw Line[ |
806 [[[[[[[["ValCall(" | 821 [[[[[[[[valcall |
807 ]Append[worker] | 822 ]Append[worker] |
808 ]Append[", "] | 823 ]Append[", "] |
809 ]Append[String[[rargs]Length]] | 824 ]Append[String[[rargs]Length]] |
810 ]Append[", "] | 825 ]Append[", "] |
811 ]Append[String[[func]Resume Index >>]] | 826 ]Append[String[[func]Resume Index >>]] |
812 ]Append[", "] | 827 ]Append[", "] |
813 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] | 828 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
814 ]Append[")"]] | 829 ]Append[")"]] |
815 ]Add Raw Line["DISPATCH"] | 830 ]Add Raw Line["DISPATCH"] |
816 ]Add Raw Line[ | 831 ]Add Raw Line[ |
817 [[[["ValCallPostlude(" | 832 [[[[postlude |
818 ]Append[String[[func]Resume Index >>]] | 833 ]Append[String[[func]Resume Index >>]] |
819 ]Append[", "] | 834 ]Append[", "] |
820 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] | 835 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
821 ]Append[")"]] | 836 ]Append[")"]] |
822 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] | 837 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] |
843 out <- [func]Func Base[Escape Rhope Name[name,[func]Escape Pattern >>],args, "Call"] | 858 out <- [func]Func Base[Escape Rhope Name[name,[func]Escape Pattern >>],args, "Call"] |
844 } | 859 } |
845 } | 860 } |
846 } | 861 } |
847 | 862 |
848 Func Base@C Function[func,tocall,args,type:out] | 863 Func Base@C Function[func,tocall,args,rtype:out] |
849 { | 864 { |
850 Print[ [[func]Name >>]Append[ [": Func Base("]Append[tocall] ] ] | 865 Print[ [[func]Name >>]Append[ [": Func Base("]Append[tocall] ] ] |
851 rargs <- Map[args, Make Op[?, func]] | 866 rargs <- Map[args, Make Op[?, func]] |
867 | |
868 If[[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]] | |
869 { type <- Val[rtype] } | |
870 { type <- [rtype]Append["NoLocals"] } | |
852 | 871 |
853 If[[[rargs]Length] > [[func]Last NumParams >>]] | 872 If[[[rargs]Length] > [[func]Last NumParams >>]] |
854 { | 873 { |
855 If[[[func]Last NumParams >>] = [-1]] | 874 If[[[func]Last NumParams >>] = [-1]] |
856 { | 875 { |
1129 type <- "Func" | 1148 type <- "Func" |
1130 cname <- Val[fname] | 1149 cname <- Val[fname] |
1131 } | 1150 } |
1132 fname <- Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>] | 1151 fname <- Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>] |
1133 param check <- Fold[Check Param Type C[?, ?, ?, func], "", [func]Input Types >>] | 1152 param check <- Fold[Check Param Type C[?, ?, ?, func], "", [func]Input Types >>] |
1153 If[[[func]Last NumParams >>] = [-1]] | |
1154 { | |
1155 freecall <- "" | |
1156 }{ | |
1157 freecall <- "\n\tFreeCall\n" | |
1158 } | |
1134 If[ [ [[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]]+[[[func]Uses >>]Length] ] = [0] ] | 1159 If[ [ [[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]]+[[[func]Uses >>]Length] ] = [0] ] |
1135 { | 1160 { |
1136 out <- [[[[[[[[ [type]Append["NoLocals("] | 1161 out <- [[[[[[[[[ [type]Append["NoLocals("] |
1137 ]Append[cname] | 1162 ]Append[cname] |
1138 ]Append[",\n\tNumParams "] | 1163 ]Append[",\n\tNumParams "] |
1139 ]Append[ String[[[func]Inputs >>]Length] ] | 1164 ]Append[ String[[[func]Inputs >>]Length] ] |
1140 ]Append[")\n\n"] | 1165 ]Append[")\n\n"] |
1141 ]Append[param check] | 1166 ]Append[param check] |
1142 ]Append[ [[func]Statements >>]Join[""] ] | 1167 ]Append[ [[func]Statements >>]Join[""] ] |
1168 ]Append[freecall] | |
1143 ]Append["EndFuncNoLocals\n"] | 1169 ]Append["EndFuncNoLocals\n"] |
1144 ]Append["DISPATCH"] | 1170 ]Append["DISPATCH"] |
1145 }{ | 1171 }{ |
1146 If[[[func]Last NumParams >>] = [-1]] | |
1147 { | |
1148 freecall <- "" | |
1149 }{ | |
1150 freecall <- "\n\tFreeCall\n" | |
1151 } | |
1152 If[[[func]Uses >>]Length] | 1172 If[[[func]Uses >>]Length] |
1153 { | 1173 { |
1154 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"] | 1174 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"] |
1155 init trans <- [[Fold[Find Trans Cell[func,?], begin trans, [func]Uses >>] | 1175 init trans <- [[Fold[Find Trans Cell[func,?], begin trans, [func]Uses >>] |
1156 ]Append[[["transretry_"]Append[fname]]Append[":\n"]] | 1176 ]Append[[["transretry_"]Append[fname]]Append[":\n"]] |