# HG changeset patch # User Mike Pavone # Date 1272517963 14400 # Node ID 243d013a49cbf076dea351533867029134e7796e # Parent 70af7fa155d0603630f253d7ada680005baeae23 Defer processing of string literals until after simpler ones to avoid a segfault diff -r 70af7fa155d0 -r 243d013a49cb cbackend.rhope --- a/cbackend.rhope Thu Apr 29 04:32:54 2010 +0000 +++ b/cbackend.rhope Thu Apr 29 01:12:43 2010 -0400 @@ -1085,14 +1085,22 @@ make <- [[[" = make_"]Append[s]]Append["nt"]]Append[[value]Size >>] out <- [text]Append[ [[[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[make]]Append["("]]Append[[value]Value >>]]Append[");\n"] ] }{ - If[[valtype] = ["String"]] - { - out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_String(\""]]Append[ [[value]Replace["\n", "\\n"]]Replace["\\", "\\\\"]]]Append["\");\n"] ] - } + out <- text } } } } +} + +_Set Late Consts C[text,value,name,type reg:out] +{ + valtype <- Type Of[value] + If[[valtype] = ["String"]] + { + out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_String(\""]]Append[ [[value]Replace["\n", "\\n"]]Replace["\\", "\\\\"]]]Append["\");\n"] ] + }{ + out <- text + } } Text@C Program[program:out] @@ -1108,7 +1116,7 @@ #include \"blueprint.h\" #include \"array.h\" #include \"bool.h\"\n\n" - out <- [[[[[[headers + out <- [[[[[[[headers ]Append[[[program]Type Registry >>]Type Defs] ]Append[Fold[["_Text C Program"]Set Input[2, [program]Type Registry >>], Fold["_Consts C Program", @@ -1123,7 +1131,8 @@ blueprint * bp; register_builtin_types();\n\n"] ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ] - ]Append[Fold[["_Set Consts C Program"]Set Input[3, [program]Type Registry >>], "", constants]] + ]Append[Fold[["_Set Consts C Program"]Set Input[3, [program]Type Registry >>], "", constants]] + ]Append[Fold[["_Set Late Consts C"]Set Input[3, [program]Type Registry >>], "", constants]] ]Append[" ct = new_context(); cdata = alloc_cdata(ct, 0);