comparison cbackend.rhope @ 92:e73a93fb5de1

Beginning of port of compiler to itself, some bugfixes and a refcount optimization
author Mike Pavone <pavone@retrodev.com>
date Mon, 02 Aug 2010 00:58:55 -0400
parents bcdc326b3d6e
children 5a08705f7610
comparison
equal deleted inserted replaced
91:bcdc326b3d6e 92:e73a93fb5de1
763 out <- [func]Val Call[[args]Index[0], Tail[args,1]] 763 out <- [func]Val Call[[args]Index[0], Tail[args,1]]
764 }{ 764 }{
765 If[[name]=["Call"]] 765 If[[name]=["Call"]]
766 { 766 {
767 to call <- [args]Index[0] 767 to call <- [args]Index[0]
768 out <- [[[[[func]Add Raw Line[[["if (get_blueprint("]Append[Make Op[Strip Addref[to call], func]]]Append[")->type_id == TYPE_WORKER) {"]] 768 last numparams <- [func]Last NumParams >>
769 out <- [[[[[[func]Add Raw Line[[["if (get_blueprint("]Append[Make Op[Strip Addref[to call], func]]]Append[")->type_id == TYPE_WORKER) {"]]
769 ]Val Call[to call, Tail[args,1]] 770 ]Val Call[to call, Tail[args,1]]
770 ]Add Raw Line["} else {"] 771 ]Add Raw Line["} else {"]
772 ]Last NumParams <<[last numparams]
771 ]Func Base["Call",args, "Call"] 773 ]Func Base["Call",args, "Call"]
772 ]Add Raw Line["}"] 774 ]Add Raw Line["}"]
773 }{ 775 }{
774 out <- [func]Func Base[Escape Rhope Name[name],args, "Call"] 776 out <- [func]Func Base[Escape Rhope Name[name],args, "Call"]
775 } 777 }
1208 ]Append[[value]Value >>] 1210 ]Append[[value]Value >>]
1209 ]Append[")"] 1211 ]Append[")"]
1210 }{ 1212 }{
1211 If[[valtype] = ["String"]] 1213 If[[valtype] = ["String"]]
1212 { 1214 {
1213 out <- [["make_String(\""]Append[ [[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\"", "\\\""] ]]Append["\")"] 1215 out <- [["make_String(\""]Append[ [[[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\r", "\\r"]]Replace["\"", "\\\""] ]]Append["\")"]
1214 }{ 1216 }{
1215 If[[valtype]=["Worker Literal"]] 1217 If[[valtype]=["Worker Literal"]]
1216 { 1218 {
1217 //TODO: Figure out how to fully support these in nested cases 1219 //TODO: Figure out how to fully support these in nested cases
1218 //or workaround the problem higher up in the food chain 1220 //or workaround the problem higher up in the food chain
1278 valtype <- Type Of[value] 1280 valtype <- Type Of[value]
1279 [("String","Worker Literal","List")]Find[valtype] 1281 [("String","Worker Literal","List")]Find[valtype]
1280 { 1282 {
1281 If[[valtype]=["List"]] 1283 If[[valtype]=["List"]]
1282 { 1284 {
1283 out <- [Fold[["_Set List Els"]Set Input[3, type reg], "\trhope(FUNC_List, inout, 0, 1);\n", value] 1285 out <- [Fold[["_Set List Els"]Set Input[3, type reg], [text]Append["\trhope(FUNC_List, inout, 0, 1);\n"], value]
1284 ]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = inout[0];\n"]] 1286 ]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = inout[0];\n"]]
1285 }{ 1287 }{
1286 Const Construct C[value,type reg] 1288 Const Construct C[value,type reg]
1287 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] } 1289 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
1288 1290