comparison cbackend_c.rhope @ 136:fc3815b7462f

Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
author Mike Pavone <pavone@retrodev.com>
date Sun, 14 Nov 2010 23:07:55 -0500
parents 18a4403fe576
children a68e6828d896
comparison
equal deleted inserted replaced
135:18a4403fe576 136:fc3815b7462f
474 source2 <- [psource2]Make Op[func] 474 source2 <- [psource2]Make Op[func]
475 dest <- [pdest]Make Op[func] 475 dest <- [pdest]Make Op[func]
476 out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]] 476 out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]]
477 } 477 }
478 478
479 Make AddRef Op@C Function[func,val:out]
480 {
481 out <- [["add_ref((object *)"]Append[ [val]Make Op[func] ]]Append[")"]
482 }
483
479 Add@C Function[func,source1,source2,dest:out] 484 Add@C Function[func,source1,source2,dest:out]
480 { 485 {
481 out <- [func]Add Operator Statement[source1,source2,dest," + "] 486 out <- [func]Add Operator Statement[source1,source2,dest," + "]
482 } 487 }
483 488
1132 p <- Pattern[("_", "@", " ", ":", "?", "+", "-", "*", "/", "<", ">", "(", ")", "!", "=", "'", 1137 p <- Pattern[("_", "@", " ", ":", "?", "+", "-", "*", "/", "<", ">", "(", ")", "!", "=", "'",
1133 "\"", "\t", ",", ".", "\n", "{", "}", "[", "]", "#", "\\", "\r", ";", "&", "|", "%", "^", "`", "~")] 1138 "\"", "\t", ",", ".", "\n", "{", "}", "[", "]", "#", "\\", "\r", ";", "&", "|", "%", "^", "`", "~")]
1134 out <- [[[[[[Build[C Program()]]Functions <<[Dictionary[]]]Method Registry <<[C Method Registry[]]]Type Registry <<[C Type Registry[p]]]Field Registry <<[C Field Registry[]]]Libraries <<[Dictionary[]]]Escape Pattern <<[p] 1139 out <- [[[[[[Build[C Program()]]Functions <<[Dictionary[]]]Method Registry <<[C Method Registry[]]]Type Registry <<[C Type Registry[p]]]Field Registry <<[C Field Registry[]]]Libraries <<[Dictionary[]]]Escape Pattern <<[p]
1135 } 1140 }
1136 1141
1137 Supported Number Types@JS Program[program:out] 1142 Supported Number Types@C Program[program:out]
1138 { 1143 {
1139 out <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64") 1144 out <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64")
1140 } 1145 }
1141 1146
1142 Needed Specials@JS Program[program,typename,makespecial:out] 1147 Needed Specials@C Program[program,typename,makespecial:out]
1143 { 1148 {
1144 init name <- [" init "]Append[typename] 1149 init name <- [" init "]Append[typename]
1145 with init <- [()]Append[ [[()]Append[init name]]Append[[makespecial]Index["init"]] ] 1150 with init <- [()]Append[ [[()]Append[init name]]Append[[makespecial]Index["init"]] ]
1146 [("Array","Boxed Array","Worker")]Find[=[?,typename]] 1151 [("Array","Boxed Array","Worker")]Find[=[?,typename]]
1147 { 1152 {
1150 copy name <- [" copy "]Append[typename] 1155 copy name <- [" copy "]Append[typename]
1151 cleanup name <- [" cleanup "]Append[typename] 1156 cleanup name <- [" cleanup "]Append[typename]
1152 out <- [[with init]Append[ [[()]Append[copy name]]Append[[makespecial]Index["copy"]] ] 1157 out <- [[with init]Append[ [[()]Append[copy name]]Append[[makespecial]Index["copy"]] ]
1153 ]Append[ [[()]Append[cleanup name]]Append[[makespecial]Index["cleanup"]] ] 1158 ]Append[ [[()]Append[cleanup name]]Append[[makespecial]Index["cleanup"]] ]
1154 } 1159 }
1160 }
1161
1162 Set Stdlib Imports@C Program[program,parser:out]
1163 {
1164 out <- [parser]Imports <<[ [[parser]Imports >>]Set["kernel.rhope", Yes] ]
1155 } 1165 }
1156 1166
1157 Link@C Program[program,language,library:out] 1167 Link@C Program[program,language,library:out]
1158 { 1168 {
1159 If[[library] = ["runtime"]] 1169 If[[library] = ["runtime"]]