Mercurial > repos > rhope
diff cbackend.rhope @ 12:31f8182f3433
Finished fib test and did some small work on the c backend
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 25 May 2009 23:34:36 -0400 |
parents | 73e978d590c7 |
children | 69dfca29565f |
line wrap: on
line diff
--- a/cbackend.rhope Tue May 19 23:29:55 2009 -0400 +++ b/cbackend.rhope Mon May 25 23:34:36 2009 -0400 @@ -1,3 +1,5 @@ +Import extendlib.rhope +Import backendutils.rhope Blueprint Blueprint Def { @@ -40,7 +42,7 @@ Add Statement@C Function[func,statement:out] { - out <- [func]Statements <<[ [[func]Statements >>]Append[[statement]Append[";"]] ] + out <- [func]Statements <<[ [[func]Statements >>]Append[["\t"]Append[[statement]Append[";\n"]]] ] } Add Operator Statement@C Function[func,source1,source2,dest,op:out] @@ -73,6 +75,26 @@ out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]] } +Init Outputs@C Function[func] +{ + If[[[[func]Outputs >>]Length ] > [0]] + { + out <- [["\tlocals->"]Append[ [[func]Outputs >>]Join[" = NULL;\n\tlocals->"] ]]Append[" = NULL;\n"] + }{ + out <- "" + } +} + +Release Inputs@C Function[func] +{ + If[[[[func]Inputs >>]Length ] > [0]] + { + out <- [["\trelease_ref(->"]Append[ [[func]Outputs >>]Join[" = NULL;\n\tlocals->"] ]]Append[" = NULL;\n"] + }{ + out <- "" + } +} + Definitions@C Function[func:out] { @@ -80,5 +102,13 @@ Text@C Function[func:out] { - + cname <- Escape Rhope Name[[func]Name >>] + out <- [[[[[[["Func(" + ]Append[cname] + ]Append[",\n\tNumParams "] + ]Append[ [[func]Inputs >>]Length ] + ]Append[",\n\tCallSpace 32,\n\t"]//TODO: Fill in with calculated callspace value + ]Append[["l_"]Append[cname]] + ]Append[")\n\n"] + ]Append[[func]Init Outputs] } \ No newline at end of file