Mercurial > repos > rhope
comparison cbackend_c.rhope @ 120:cd25171e1bb2
Use List for Subsets instead of a Dictionary for performance reasons. Fix issue with List literals. Compiled compiler is now self-hosting.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 21 Oct 2010 23:55:15 -0400 |
parents | b3f56e1d54a0 |
children | 4e4ecbca0b5d |
comparison
equal
deleted
inserted
replaced
119:72c648bca43b | 120:cd25171e1bb2 |
---|---|
631 out <- func | 631 out <- func |
632 result op <- Field Ref[var,field] | 632 result op <- Field Ref[var,field] |
633 } | 633 } |
634 | 634 |
635 | 635 |
636 | |
636 Set Field Null@C Function[func,var,field:out] | 637 Set Field Null@C Function[func,var,field:out] |
637 { | 638 { |
638 out <- [func]Add Statement[ [[func]Field Result[var,field]]Append[" = NULL"] ] | 639 out <- [func]Add Statement[ [[func]Field Result[var,field]]Append[" = NULL"] ] |
639 } | 640 } |
640 | 641 |
1231 } | 1232 } |
1232 }{ | 1233 }{ |
1233 | 1234 |
1234 [(String(),String Slice(),String Cat())]Find[=[valtype,?]] | 1235 [(String(),String Slice(),String Cat())]Find[=[valtype,?]] |
1235 { | 1236 { |
1236 out <- [["make_String(\""]Append[ [[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\"", "\\\""] ]]Append["\")"] | 1237 out <- [["make_String(\""]Append[ [[[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\"", "\\\""]]Replace["\r", "\\r"] ]]Append["\")"] |
1237 }{ | 1238 }{ |
1238 If[[valtype]=[Worker Literal()]] | 1239 If[[valtype]=[Worker Literal()]] |
1239 { | 1240 { |
1240 //TODO: Figure out how to fully support these in nested cases | 1241 //TODO: Figure out how to fully support these in nested cases |
1241 //or workaround the problem higher up in the food chain | 1242 //or workaround the problem higher up in the food chain |
1279 _Set Consts C Program[text,value,name,type reg:out] | 1280 _Set Consts C Program[text,value,name,type reg:out] |
1280 { | 1281 { |
1281 valtype <- Blueprint Of[value] | 1282 valtype <- Blueprint Of[value] |
1282 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] | 1283 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] |
1283 { | 1284 { |
1285 Print[[name]Append[" is not of an early constant type"]] | |
1284 out <- text | 1286 out <- text |
1285 }{ | 1287 }{ |
1286 Const Construct C[value,type reg] | 1288 Const Construct C[value,type reg] |
1287 { out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } | 1289 { out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
1288 } | 1290 } |
1305 valtype <- Blueprint Of[value] | 1307 valtype <- Blueprint Of[value] |
1306 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] | 1308 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] |
1307 { | 1309 { |
1308 If[[~]>[3]] | 1310 If[[~]>[3]] |
1309 { | 1311 { |
1310 out <- [Fold[_Set List Els[?, ?, ?, type reg], "\trhope(FUNC_List, inout, 0, 1);\n", value] | 1312 out <- [Fold[_Set List Els[?, ?, ?, type reg], [text]Append["\trhope(FUNC_List, inout, 0, 1);\n"], value] |
1311 ]Append[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = inout[0];\n"]] | 1313 ]Append[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = inout[0];\n"]] |
1312 }{ | 1314 }{ |
1313 Const Construct C[value,type reg] | 1315 Const Construct C[value,type reg] |
1314 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } | 1316 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
1315 | 1317 |