Inferno  0.2
lower_control_flow.hpp
Go to the documentation of this file.
00001 #ifndef LOWER_CONTROL_FLOW_HPP
00002 #define LOWER_CONTROL_FLOW_HPP
00003 
00004 #include "sr/search_replace.hpp"
00005 
00006 namespace Steps {
00007 
00008 /** Detect an uncombable switch and mark it for lowering. This is 
00009     any switch with fall throughs.  */
00010 class DetectUncombableSwitch : public SearchReplace
00011 {
00012 public:
00013     DetectUncombableSwitch();
00014 };
00015         
00016 /** Make all fors uncombable to make next step easier */
00017 class MakeAllForUncombable : public SearchReplace
00018 {
00019 public:
00020     MakeAllForUncombable();
00021 };
00022         
00023 /** Detect a combable for and mark it for lowering. This is 
00024     any indefinite for. */
00025 class DetectCombableFor : public SearchReplace
00026 {
00027 public:
00028     DetectCombableFor();
00029 };
00030         
00031 /** Make all breaks uncombable to make next step easier */
00032 class MakeAllBreakUncombable : public SearchReplace
00033 {
00034 public:
00035     MakeAllBreakUncombable();
00036 };
00037         
00038 /** Detect a combable break and mark it for lowering. This is 
00039     a break at the top level of a combable switch. */
00040 class DetectCombableBreak : public SearchReplace
00041 {
00042 public:
00043     DetectCombableBreak();
00044 };
00045         
00046 /** Convert for loops into while loops, preserving correct 
00047     behaviour of continue, which always means "jump to the 
00048     bottom of the body" */
00049 class ForToWhile : public SearchReplace
00050 {
00051 public:
00052     ForToWhile();
00053 };
00054 
00055 /** Convert While loops to Do loops */
00056 class WhileToDo : public SearchReplace
00057 {
00058 public:
00059     WhileToDo();
00060 };
00061 
00062 /** Lower general if statements into a simplified form of if(x) goto y; */
00063 class IfToIfGoto : public SearchReplace
00064 {
00065 public:
00066     IfToIfGoto();
00067 };
00068 
00069 /** Eliminate switch statements by replacing them with gotos,
00070     conditional gotos (if(x) goto Y;) and labels, supporting
00071     fall-through, default and GCC range-case extension. */
00072 class SwitchToIfGoto : public SearchReplace
00073 {
00074 public:
00075     SwitchToIfGoto();
00076 };
00077 
00078 /** Eliminate Do loops by replacing them with the conditional
00079     goto pattern. Supports continue. */
00080 class DoToIfGoto : public SearchReplace
00081 {
00082 public:
00083     DoToIfGoto();
00084 };
00085 
00086 /** Eliminate break statements by replacing them with gotos to
00087     the end of the relevent block. */
00088 class BreakToGoto : public SearchReplace
00089 {
00090 public:
00091     BreakToGoto();
00092 };
00093 
00094 /** Reduce || to an if, due to its conditional execution and sequence point behaviour */
00095 class LogicalOrToIf : public SearchReplace
00096 {
00097 public:
00098     LogicalOrToIf();
00099 };
00100 
00101 /** Reduce && to an if, due to its conditional execution and sequence point behaviour */
00102 class LogicalAndToIf : public SearchReplace
00103 {
00104 public:
00105     LogicalAndToIf();
00106 };
00107 
00108 /** Reduce ?: to an if, due to its conditional execution and sequence point behaviour */
00109 class MultiplexorToIf : public SearchReplace
00110 {
00111 public:
00112     MultiplexorToIf();
00113 };
00114 
00115 /** Evaluate the arguments to a funciton into temps first, and then pass the temps
00116     into the call - done in case an argument itself contains a function call. */
00117 class ExtractCallParams : public SearchReplace
00118 {
00119 public:
00120     ExtractCallParams();
00121 };
00122 
00123 }; // end namespace
00124 
00125 #endif 
00126