# HG changeset patch # User Mike Pavone # Date 1254885227 14400 # Node ID 7f05bbe82f24091bcabe4a2b163199d2b3ad251c # Parent 640f541e911623e69c8687df71cb3125896e43c8 Started work on adding Array support diff -r 640f541e9116 -r 7f05bbe82f24 backendutils.rhope --- a/backendutils.rhope Mon Oct 05 23:12:43 2009 -0400 +++ b/backendutils.rhope Tue Oct 06 23:13:47 2009 -0400 @@ -1,7 +1,7 @@ Escape Rhope Name NU[name:escaped] { - escaped <- [[[[[[[[[[name]Replace["@","_AT_"] + escaped <- [[[[[[[[[[[[name]Replace["@","_AT_"] ]Replace[" ","_SP_"] ]Replace[":","_CN_"] ]Replace["?","_QN_"] @@ -11,6 +11,8 @@ ]Replace["/","_DV_"] ]Replace["<","_LT_"] ]Replace[">","_GT_"] + ]Replace["(","_LP_"] + ]Replace[")","_RP_"] } Escape Rhope Name[name:escaped] diff -r 640f541e9116 -r 7f05bbe82f24 cbackend.rhope --- a/cbackend.rhope Mon Oct 05 23:12:43 2009 -0400 +++ b/cbackend.rhope Tue Oct 06 23:13:47 2009 -0400 @@ -128,16 +128,42 @@ out <- Fold["_Register Field C", field reg, [ctype]Fields >>] } -Rhope Type to C[type:out] +Rhope Type to C[type:out,array] { If[[Type Of[type]]=["Type Instance"]] { - typename <- [type]Name >> variant <- [type]Variant >> + If[[[type]Name >>] = ["Array"]] + { + [("Naked","Raw Pointer")]Find[variant] + { + pre param <- [[type]Params >>]Index[0] {} + { pre param <- Type Instance["Any Type"] } + [[type]Params >>]Index[1] + { param,param <- [pre param]Set Variant[~] } + { param <- Val[pre param] } + child type <- Rhope Type to C[param] + If[[variant] = ["Naked"]] + { + out <- Val[child type] + array <- "[1]" + }{ + out <- [child type]Append[" *"] + array <- "" + } + }{ + typename <- "Array" + } + }{ + typename <- [type]Name >> + } }{ typename <- type + param <- "Any Type" variant <- "boxed" } + Val[typename] + { array <- "" } If[[typename] = ["Any Type"]] { out <- "struct object *" @@ -155,16 +181,17 @@ }{ postfix <- " *" } - - out <- [[prefix]Append[Escape Rhope Name[typename]]]Append[postfix] } + out <- [[prefix]Append[Escape Rhope Name[typename]]]Append[postfix] } _Type Def C Type[text,field:out] { name <- [field]Index[0] - type <- ["\n\t"]Append[Rhope Type to C[[field]Index[1]]] - out <- [[[[text]Append[type]]Append[" "]]Append[Escape Rhope Name[name]]]Append[";"] + ,postfix <- Rhope Type to C[[field]Index[1]] + { type <- ["\n\t"]Append[~] } + + out <- [[[[text]Append[type]]Append[" "]]Append[[Escape Rhope Name[name]]Append[postfix]]]Append[";"] } Type Def@C Type[ctype:out]