comparison cbackend.rhope @ 69:d0ce696786cc

Clean up debug print statements a bit. Fix bug that prevented workers that took no inputs from working. Remove workaround in Array for said bug.
author Mike Pavone <pavone@retrodev.com>
date Wed, 16 Jun 2010 04:36:08 +0000
parents d4b44ae2e34a
children f7bcf3db1342
comparison
equal deleted inserted replaced
68:38d9cd036d49 69:d0ce696786cc
353 } 353 }
354 354
355 Type Inits@C Type Registry[reg,method reg,field reg:out] 355 Type Inits@C Type Registry[reg,method reg,field reg:out]
356 { 356 {
357 out <- Fold[[[["_Type Inits C"]Set Input[0, reg]]Set Input[1, method reg]]Set Input[2, field reg], "", [reg]Definitions >>] 357 out <- Fold[[[["_Type Inits C"]Set Input[0, reg]]Set Input[1, method reg]]Set Input[2, field reg], "", [reg]Definitions >>]
358 { Print["Type inits got output"] }
359 } 358 }
360 359
361 Register Type@C Type Registry[reg,def:out] 360 Register Type@C Type Registry[reg,def:out]
362 { 361 {
363 name <- [def]Name >> 362 name <- [def]Name >>
365 { 364 {
366 [[reg]Definitions >>]Index[name] 365 [[reg]Definitions >>]Index[name]
367 { 366 {
368 out <- reg 367 out <- reg
369 }{ 368 }{
370 Print[["Registered def for "]Append[name]]
371 out <- [reg]Definitions <<[[[reg]Definitions >>]Set[name, def]] 369 out <- [reg]Definitions <<[[[reg]Definitions >>]Set[name, def]]
372 } 370 }
373 }{ 371 }{
374 out <- [[[reg]Lookup <<[ [[reg]Lookup >>]Set[name, ["TYPE_FIRST_USER+"]Append[[reg]Next ID >>]] ] 372 out <- [[[reg]Lookup <<[ [[reg]Lookup >>]Set[name, ["TYPE_FIRST_USER+"]Append[[reg]Next ID >>]] ]
375 ]Definitions <<[ [[reg]Definitions >>]Set[name, def] ] 373 ]Definitions <<[ [[reg]Definitions >>]Set[name, def] ]
386 } 384 }
387 } 385 }
388 386
389 Simple Type?@C Type Registry[reg,name:yep,nope,notfound] 387 Simple Type?@C Type Registry[reg,name:yep,nope,notfound]
390 { 388 {
391 Print[["Symple Type?: "]Append[name]]
392 ,notfound <- [[reg]Definitions >>]Index[name] 389 ,notfound <- [[reg]Definitions >>]Index[name]
393 { 390 {
394 Print["found type"]
395 yep,nope <- If[[[[~]Fields >>]Length] = [1]] 391 yep,nope <- If[[[[~]Fields >>]Length] = [1]]
396 }{
397 Pretty Print[reg, ""]
398 } 392 }
399 } 393 }
400 394
401 Blueprint C Function 395 Blueprint C Function
402 { 396 {
450 out <- [func]Output Types <<[ [[func]Output Types >>]Set[output num, type] ] 444 out <- [func]Output Types <<[ [[func]Output Types >>]Set[output num, type] ]
451 } 445 }
452 446
453 Register Constant@C Function[func,name,constant:out] 447 Register Constant@C Function[func,name,constant:out]
454 { 448 {
455 Print["Register Constant"]
456 Print[name]
457 out <- [func]Constants <<[ [[func]Constants >>]Set[name, constant] ] 449 out <- [func]Constants <<[ [[func]Constants >>]Set[name, constant] ]
458 { Print["Got register constant output"] }
459 } 450 }
460 451
461 Allocate Var@C Function[func,name,type:out] 452 Allocate Var@C Function[func,name,type:out]
462 { 453 {
463 Print[["Allocate Var: "]Append[name]]
464 out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ] 454 out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ]
465 } 455 }
466 456
467 Add Statement@C Function[func,statement:out] 457 Add Statement@C Function[func,statement:out]
468 { 458 {
563 } 553 }
564 554
565 Release@C Function[func,psource:out] 555 Release@C Function[func,psource:out]
566 { 556 {
567 source <- [psource]Make Op[func] 557 source <- [psource]Make Op[func]
568 Print[["Release: "]Append[source]]
569 out <- [func]Add Statement[[["release_ref((object *)"]Append[source]]Append[")"]] 558 out <- [func]Add Statement[[["release_ref((object *)"]Append[source]]Append[")"]]
570 } 559 }
571 560
572 Set Null@C Function[func,pdest:out] 561 Set Null@C Function[func,pdest:out]
573 { 562 {
574 dest <- [pdest]Make Op[func] 563 dest <- [pdest]Make Op[func]
575 Print[["Set Null: "]Append[dest]]
576 out <- [func]Add Statement[[dest]Append[" = NULL"]] 564 out <- [func]Add Statement[[dest]Append[" = NULL"]]
577 } 565 }
578 566
579 Lookup Constant@C Function[func,const:out] 567 Lookup Constant@C Function[func,const:out]
580 { 568 {
634 result op <- Field Ref[var,field] 622 result op <- Field Ref[var,field]
635 } 623 }
636 624
637 Set Field Null@C Function[func,var,field:out] 625 Set Field Null@C Function[func,var,field:out]
638 { 626 {
639 Print["Set Field Null"]
640 out <- [func]Add Statement[ [[func]Field Result[var,field]]Append[" = NULL"] ] 627 out <- [func]Add Statement[ [[func]Field Result[var,field]]Append[" = NULL"] ]
641 } 628 }
642 629
643 Copy@C Function[func,pdest:out] 630 Copy@C Function[func,pdest:out]
644 { 631 {
905 out <- [list]Append[ [[Rhope Type to C[[types]Index[index]]]Append[" "]]Append[Escape Rhope Name[input]] ] 892 out <- [list]Append[ [[Rhope Type to C[[types]Index[index]]]Append[" "]]Append[Escape Rhope Name[input]] ]
906 } 893 }
907 894
908 Naked Proto@C Function[func:out] 895 Naked Proto@C Function[func:out]
909 { 896 {
910 Print[["Naked Proto: "]Append[ [func]Name >>] ]
911 [[func]Output Types >>]Index[0] 897 [[func]Output Types >>]Index[0]
912 { 898 {
913 outtype <- [Rhope Type to C[~]]Append[" "] 899 outtype <- [Rhope Type to C[~]]Append[" "]
914 }{ 900 }{
915 outtype <- "void " 901 outtype <- "void "
917 out <- [[[[outtype 903 out <- [[[[outtype
918 ]Append[ Escape Rhope Name NU[[func]Name >>]] 904 ]Append[ Escape Rhope Name NU[[func]Name >>]]
919 ]Append["("] 905 ]Append["("]
920 ]Append[ [Fold[["_Proto Input"]Set Input[3, [func]Input Types >>], (), [func]Inputs >>]]Join[", "] ] 906 ]Append[ [Fold[["_Proto Input"]Set Input[3, [func]Input Types >>], (), [func]Inputs >>]]Join[", "] ]
921 ]Append[")"] 907 ]Append[")"]
922 { Print[~] }
923 } 908 }
924 909
925 Type Check@C Function[func,text,type,input num:out] 910 Type Check@C Function[func,text,type,input num:out]
926 { 911 {
927 If[[type] = ["Any Type"]] 912 If[[type] = ["Any Type"]]
1087 out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name]]]Append[";\n"] ] 1072 out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name]]]Append[";\n"] ]
1088 } 1073 }
1089 1074
1090 _Set Consts C Program[text,value,name,type reg:out] 1075 _Set Consts C Program[text,value,name,type reg:out]
1091 { 1076 {
1092 Print[["_Set Consts: "]Append[valtype]]
1093 Pretty Print[value, "_Set Consts: "]
1094 //TODO: Support more constant types 1077 //TODO: Support more constant types
1095 valtype <- Type Of[value] 1078 valtype <- Type Of[value]
1096 [("Int32","Whole Number")]Find[valtype] 1079 [("Int32","Whole Number")]Find[valtype]
1097 { 1080 {
1098 out <- [text]Append[[[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_Int32("]]Append[value]]Append[");\n"]] 1081 out <- [text]Append[[[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_Int32("]]Append[value]]Append[");\n"]]
1099 { Print["_Set Consts got output integer"] }
1100 }{ 1082 }{
1101 If[[valtype] = ["Type Instance"]] 1083 If[[valtype] = ["Type Instance"]]
1102 { 1084 {
1103 //TODO: Support parametric types 1085 //TODO: Support parametric types
1104 typeid <- [type reg]Type ID[[value]Name >>] 1086 typeid <- [type reg]Type ID[[value]Name >>]
1105 out <- [text]Append[[[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_Blueprint("]]Append[typeid]]Append[");\n"]] 1087 out <- [text]Append[[[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_Blueprint("]]Append[typeid]]Append[");\n"]]
1106 { Print["_Set Consts got output blueprint"] }
1107 }{ 1088 }{
1108 If[[valtype] = ["Yes No"]] 1089 If[[valtype] = ["Yes No"]]
1109 { 1090 {
1110 If[value] 1091 If[value]
1111 { 1092 {
1112 out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_yes;\n"]] 1093 out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_yes;\n"]]
1113 { Print["_Set Consts got output yes"] }
1114 }{ 1094 }{
1115 out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_no;\n"]] 1095 out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_no;\n"]]
1116 { Print["_Set Consts got output no"] }
1117 } 1096 }
1118 }{ 1097 }{
1119 If[[valtype] = ["Machine Integer"]] 1098 If[[valtype] = ["Machine Integer"]]
1120 { 1099 {
1121 If[[value]Signed? >>] 1100 If[[value]Signed? >>]
1277 ]Append[")\n\n"] 1256 ]Append[")\n\n"]
1278 } 1257 }
1279 1258
1280 Text@C Program[program:out] 1259 Text@C Program[program:out]
1281 { 1260 {
1282 Print["Text@C Program"]
1283 type defs <- [[program]Type Registry >>]Definitions >> 1261 type defs <- [[program]Type Registry >>]Definitions >>
1284 constants <- Fold["Combine Consts", Dictionary[], [program]Functions >>] 1262 constants <- Fold["Combine Consts", Dictionary[], [program]Functions >>]
1285 all methods <- Fold["Field to Types", Fold["Method to Types", Dictionary[], type defs], type defs] 1263 all methods <- Fold["Field to Types", Fold["Method to Types", Dictionary[], type defs], type defs]
1286 headers <- "#include <stdio.h> 1264 headers <- "#include <stdio.h>
1287 #include <stdlib.h> 1265 #include <stdlib.h>