Inferno
0.2
|
00001 #ifndef FALL_OUT_HPP 00002 #define FALL_OUT_HPP 00003 00004 #include "sr/search_replace.hpp" 00005 00006 namespace Steps { 00007 00008 /// Put all the labels in an array indexable by an enum 00009 class PlaceLabelsInArray : public SearchReplace 00010 { 00011 public: 00012 PlaceLabelsInArray(); 00013 }; 00014 00015 /// Change all types from Labeley to the state enum, and move lmap lookups from && to goto 00016 class LabelTypeToEnum : public SearchReplace 00017 { 00018 public: 00019 LabelTypeToEnum(); 00020 }; 00021 00022 /// Variable-by-variable, change type from Labeley to the state enum, and move lmap lookups though the variable 00023 class LabelVarsToEnum : public CompareReplace 00024 { 00025 public: 00026 LabelVarsToEnum(); 00027 }; 00028 00029 /// Find c ? a[i] : a[j] and replace with a[ c ? i : j ] 00030 class SwapSubscriptMultiplex : public SearchReplace 00031 { 00032 public: 00033 SwapSubscriptMultiplex(); 00034 }; 00035 00036 /// Insert state variable as an enum 00037 class AddStateEnumVar : public SearchReplace 00038 { 00039 public: 00040 AddStateEnumVar(); 00041 }; 00042 00043 /// Eliminate all but the last goto by placing state bodies under if. Only 00044 /// act on states that are combable i.e. do not yield 00045 class ApplyCombGotoPolicy : public SearchReplace 00046 { 00047 public: 00048 ApplyCombGotoPolicy(); 00049 }; 00050 00051 class ApplyYieldGotoPolicy : public SearchReplace 00052 { 00053 public: 00054 ApplyYieldGotoPolicy(); 00055 }; 00056 00057 /// Deal with a state at the end that is not followed by a goto and which 00058 /// will therefore end up exiting off the bottom of the function (absent a 00059 /// return or terminator). Create a conditional goto so that exit can occur. 00060 class ApplyBottomPolicy : public SearchReplace 00061 { 00062 public: 00063 ApplyBottomPolicy(); 00064 }; 00065 00066 /// Group all labels at the top by placing state bodies under if 00067 class ApplyLabelPolicy : public SearchReplace 00068 { 00069 public: 00070 ApplyLabelPolicy(); 00071 }; 00072 00073 /// Move code above the uppermost label under the label but conditional 00074 /// on the delta count being zero, i.e. no yields have occurred yet. Only 00075 /// works if there is already a yield before the first goto 00076 class ApplyTopPolicy : public SearchReplace 00077 { 00078 public: 00079 ApplyTopPolicy(); 00080 }; 00081 00082 /// Ensure we always yield before the first goto (since reset does not 00083 /// comb into non-reset code). 00084 class EnsureResetYield : public SearchReplace 00085 { 00086 public: 00087 EnsureResetYield(); 00088 }; 00089 00090 /// Detect a superloop formed from the remaingin gotos. There must be only one 00091 /// label, and there must be nothing above or below the superloop. Intermediate 00092 /// gotos become continues. Parameter chooses whether to handle conditional goto 00093 /// at the bottom. You always want to run this with false, and again with true 00094 /// if you want to support exiting the loop. 00095 class DetectSuperLoop : public SearchReplace 00096 { 00097 public: 00098 DetectSuperLoop( bool is_conditional_goto ); 00099 }; 00100 00101 class InsertInferredYield : public SearchReplace 00102 { 00103 public: 00104 InsertInferredYield(); 00105 }; 00106 00107 }; // end namespace 00108 00109 #endif 00110