comparison cbackend_c.rhope @ 135:18a4403fe576

Javascript backend can now produce broken output. Needs fixes plus port of standard lib
author Mike Pavone <pavone@retrodev.com>
date Sun, 14 Nov 2010 03:09:49 -0500
parents 50406500334d
children fc3815b7462f
comparison
equal deleted inserted replaced
134:386f4a874821 135:18a4403fe576
323 ]Set["Float64", "TYPE_FLOAT64"] //11 323 ]Set["Float64", "TYPE_FLOAT64"] //11
324 ]Set["Real Number", "TYPE_FLOAT64"] 324 ]Set["Real Number", "TYPE_FLOAT64"]
325 ]Set["Blueprint", "TYPE_BLUEPRINT"] //12 325 ]Set["Blueprint", "TYPE_BLUEPRINT"] //12
326 ]Set["Array", "TYPE_ARRAY"] //13 326 ]Set["Array", "TYPE_ARRAY"] //13
327 ]Set["Boxed Array", "TYPE_BOXEDARRAY"]//14 327 ]Set["Boxed Array", "TYPE_BOXEDARRAY"]//14
328 ]Set["Worker", "TYPE_WORKER"] //15 328 ]Set["Worker", "TYPE_WORKER"] //15
329 ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //16 329 ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //16
330 ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //17 330 ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //17
331 ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //18 331 ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //18
332 ]Definitions << [Dictionary[]] 332 ]Definitions << [Dictionary[]]
333 ]Next ID <<[0] 333 ]Next ID <<[0]
1132 p <- Pattern[("_", "@", " ", ":", "?", "+", "-", "*", "/", "<", ">", "(", ")", "!", "=", "'", 1132 p <- Pattern[("_", "@", " ", ":", "?", "+", "-", "*", "/", "<", ">", "(", ")", "!", "=", "'",
1133 "\"", "\t", ",", ".", "\n", "{", "}", "[", "]", "#", "\\", "\r", ";", "&", "|", "%", "^", "`", "~")] 1133 "\"", "\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] 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]
1135 } 1135 }
1136 1136
1137 Supported Number Types@JS Program[program:out]
1138 {
1139 out <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64")
1140 }
1141
1142 Needed Specials@JS Program[program,typename,makespecial:out]
1143 {
1144 init name <- [" init "]Append[typename]
1145 with init <- [()]Append[ [[()]Append[init name]]Append[[makespecial]Index["init"]] ]
1146 [("Array","Boxed Array","Worker")]Find[=[?,typename]]
1147 {
1148 out <- Val[with init]
1149 }{
1150 copy name <- [" copy "]Append[typename]
1151 cleanup name <- [" cleanup "]Append[typename]
1152 out <- [[with init]Append[ [[()]Append[copy name]]Append[[makespecial]Index["copy"]] ]
1153 ]Append[ [[()]Append[cleanup name]]Append[[makespecial]Index["cleanup"]] ]
1154 }
1155 }
1156
1137 Link@C Program[program,language,library:out] 1157 Link@C Program[program,language,library:out]
1138 { 1158 {
1139 If[[library] = ["runtime"]] 1159 If[[library] = ["runtime"]]
1140 { 1160 {
1141 out <- program 1161 out <- program
1476 Init Type Names[text,typeid,name,reg:out] 1496 Init Type Names[text,typeid,name,reg:out]
1477 { 1497 {
1478 [reg]Defined?[name] 1498 [reg]Defined?[name]
1479 { out <- [text]Append[ [[[["\tregistered_types["]Append[typeid]]Append["]->name = "]]Append[Const Construct C[name, reg]]]Append[";\n"] ] } 1499 { out <- [text]Append[ [[[["\tregistered_types["]Append[typeid]]Append["]->name = "]]Append[Const Construct C[name, reg]]]Append[";\n"] ] }
1480 { out <- text } 1500 { out <- text }
1501 }
1502
1503 Text Filename@C Program[program,source name:out]
1504 {
1505 out <- [source name]Append[".c"]
1481 } 1506 }
1482 1507
1483 Text@C Program[program:out] 1508 Text@C Program[program:out]
1484 { 1509 {
1485 p <- [program]Escape Pattern >> 1510 p <- [program]Escape Pattern >>