comparison cbackend.rhope @ 21:e9272f7ebd26

Limited compilation from dataflow graph to C backend
author Mike Pavone <pavone@retrodev.com>
date Tue, 23 Jun 2009 01:16:04 -0400
parents b715532225c0
children 914ad38f9b59
comparison
equal deleted inserted replaced
20:b715532225c0 21:e9272f7ebd26
216 cond <- [condition]Make Op[func] 216 cond <- [condition]Make Op[func]
217 out <- [Fold["_If C", [[func 217 out <- [Fold["_If C", [[func
218 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ] 218 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ]
219 ]Add Raw Line["{"], [stream]Statements >>] 219 ]Add Raw Line["{"], [stream]Statements >>]
220 ]Add Raw Line["}"] 220 ]Add Raw Line["}"]
221 { Print["Do if done"] }
222 221
223 } 222 }
224 223
225 Result Reference@C Function[func,output:out] 224 Result Reference@C Function[func,output:out]
226 { 225 {
227 out <- [["call->params["]Append[output]]Append["]"] 226 out <- [["call->params["]Append[output]]Append["]"]
227 }
228
229 If Null Else@C Function[func,left,right:out]
230 {
231 out <- [[[[[["("
232 ]Append[left]
233 ]Append[" ? "]
234 ]Append[left]
235 ]Append[" : "]
236 ]Append[right]
237 ]Append[")"]
228 } 238 }
229 239
230 Init Outputs@C Function[func:out] 240 Init Outputs@C Function[func:out]
231 { 241 {
232 If[[[[func]Outputs >>]Length ] > [0]] 242 If[[[[func]Outputs >>]Length ] > [0]]
279 } 289 }
280 290
281 291
282 Definitions@C Function[func:out] 292 Definitions@C Function[func:out]
283 { 293 {
284 Print["Definitions"]
285 out <- [[[Fold["_Output Defs C", Fold["_Var Defs C","typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} l_"]]Append[Escape Rhope Name[[func]Name >>]]]Append[";\n"] 294 out <- [[[Fold["_Output Defs C", Fold["_Var Defs C","typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} l_"]]Append[Escape Rhope Name[[func]Name >>]]]Append[";\n"]
286 } 295 }
287 296
288 Text@C Function[func:out] 297 Text@C Function[func:out]
289 { 298 {