Mercurial > repos > rhope
comparison 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 |
comparison
equal
deleted
inserted
replaced
11:3021dac0d8f5 | 12:31f8182f3433 |
---|---|
1 Import extendlib.rhope | |
2 Import backendutils.rhope | |
1 | 3 |
2 Blueprint Blueprint Def | 4 Blueprint Blueprint Def |
3 { | 5 { |
4 Name | 6 Name |
5 Fixed Size | 7 Fixed Size |
38 out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ] | 40 out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ] |
39 } | 41 } |
40 | 42 |
41 Add Statement@C Function[func,statement:out] | 43 Add Statement@C Function[func,statement:out] |
42 { | 44 { |
43 out <- [func]Statements <<[ [[func]Statements >>]Append[[statement]Append[";"]] ] | 45 out <- [func]Statements <<[ [[func]Statements >>]Append[["\t"]Append[[statement]Append[";\n"]]] ] |
44 } | 46 } |
45 | 47 |
46 Add Operator Statement@C Function[func,source1,source2,dest,op:out] | 48 Add Operator Statement@C Function[func,source1,source2,dest,op:out] |
47 { | 49 { |
48 out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]] | 50 out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]] |
71 Move@C Function[func,source,dest:out] | 73 Move@C Function[func,source,dest:out] |
72 { | 74 { |
73 out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]] | 75 out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]] |
74 } | 76 } |
75 | 77 |
78 Init Outputs@C Function[func] | |
79 { | |
80 If[[[[func]Outputs >>]Length ] > [0]] | |
81 { | |
82 out <- [["\tlocals->"]Append[ [[func]Outputs >>]Join[" = NULL;\n\tlocals->"] ]]Append[" = NULL;\n"] | |
83 }{ | |
84 out <- "" | |
85 } | |
86 } | |
87 | |
88 Release Inputs@C Function[func] | |
89 { | |
90 If[[[[func]Inputs >>]Length ] > [0]] | |
91 { | |
92 out <- [["\trelease_ref(->"]Append[ [[func]Outputs >>]Join[" = NULL;\n\tlocals->"] ]]Append[" = NULL;\n"] | |
93 }{ | |
94 out <- "" | |
95 } | |
96 } | |
97 | |
76 Definitions@C Function[func:out] | 98 Definitions@C Function[func:out] |
77 { | 99 { |
78 | 100 |
79 } | 101 } |
80 | 102 |
81 Text@C Function[func:out] | 103 Text@C Function[func:out] |
82 { | 104 { |
83 | 105 cname <- Escape Rhope Name[[func]Name >>] |
106 out <- [[[[[[["Func(" | |
107 ]Append[cname] | |
108 ]Append[",\n\tNumParams "] | |
109 ]Append[ [[func]Inputs >>]Length ] | |
110 ]Append[",\n\tCallSpace 32,\n\t"]//TODO: Fill in with calculated callspace value | |
111 ]Append[["l_"]Append[cname]] | |
112 ]Append[")\n\n"] | |
113 ]Append[[func]Init Outputs] | |
84 } | 114 } |