comparison cbackend_c.rhope @ 170:ac5c2d78663f

Inline calls to If@Boolean when static type info is present
author Mike Pavone <pavone@retrodev.com>
date Sun, 08 May 2011 18:21:19 -0700
parents fd06fb07762a
children a32afde77abb
comparison
equal deleted inserted replaced
169:fd06fb07762a 170:ac5c2d78663f
594 source <- [psource]Make Op[func] 594 source <- [psource]Make Op[func]
595 dest <- [pdest]Make Op[func] 595 dest <- [pdest]Make Op[func]
596 out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]] 596 out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]]
597 } 597 }
598 598
599
599 Do AddRef@C Function[func,psource,pdest:out] 600 Do AddRef@C Function[func,psource,pdest:out]
600 { 601 {
601 source <- [psource]Make Op[func] 602 source <- [psource]Make Op[func]
602 dest <- [pdest]Make Op[func] 603 dest <- [pdest]Make Op[func]
603 out <- [func]Add Statement[[[[dest]Append[" = add_ref((object *)"]]Append[source]]Append[")"]] 604 out <- [func]Add Statement[[[[dest]Append[" = add_ref((object *)"]]Append[source]]Append[")"]]
878 879
879 If[[[rargs]Length] > [[func]Last NumParams >>]] 880 If[[[rargs]Length] > [[func]Last NumParams >>]]
880 { 881 {
881 If[[[func]Last NumParams >>] = [-1]] 882 If[[[func]Last NumParams >>] = [-1]]
882 { 883 {
884 Print["No previous PrepCall"]
883 freed <- Val[func] 885 freed <- Val[func]
884 }{ 886 }{
887 Print[[["Last NumParams is "]Append[String[[func]Last NumParams >>]]]Append[" adding FreeCall"]]
885 freed <- [func]Add Raw Line["FreeCall"] 888 freed <- [func]Add Raw Line["FreeCall"]
886 } 889 }
887 prepped <- [[freed]Add Raw Line[ [["PrepCall("]Append[String[[rargs]Length]]]Append[")"] ] 890 prepped <- [[freed]Add Raw Line[ [["PrepCall("]Append[String[[rargs]Length]]]Append[")"] ]
888 ]Last NumParams <<[[rargs]Length] 891 ]Last NumParams <<[[rargs]Length]
889 }{ 892 }{
977 } 980 }
978 981
979 Do If@C Function[func,condition,stream:out] 982 Do If@C Function[func,condition,stream:out]
980 { 983 {
981 cond <- [condition]Make Op[func] 984 cond <- [condition]Make Op[func]
982 out <- [[Fold[_If C[?], [[func 985 after statements <- Fold[_If C[?], [[func
983 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ] 986 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ]
984 ]Add Raw Line["{"], [stream]Statements >>] 987 ]Add Raw Line["{"], [stream]Statements >>]
985 ]Add Raw Line["}"] 988
989
990 If[[[[func]Last NumParams >>]=[-1]]And[[[stream]Last NumParams >>]>[-1]]]
991 {
992 after free <- [after statements]Add Raw Line["FreeCall"]
993 }{
994 after free <- Val[after statements]
995 }
996 out <- [[after free]Add Raw Line["}"]
986 ]Resume Index <<[[stream]Resume Index >>] 997 ]Resume Index <<[[stream]Resume Index >>]
987
988 } 998 }
989 999
990 Discard Outputs@C Function[func,first to discard:out] 1000 Discard Outputs@C Function[func,first to discard:out]
991 { 1001 {
992 out <- [[[[[func 1002 out <- [[[[[func