Inferno
0.2
|
00001 /* 00002 * clean_up.hpp 00003 * 00004 * Created on: 26 Dec 2009 00005 * Author: jgraley 00006 */ 00007 00008 #ifndef CLEAN_UP_HPP 00009 #define CLEAN_UP_HPP 00010 00011 #include "sr/search_replace.hpp" 00012 00013 namespace Steps { 00014 00015 /// Find compound statements inside compund statements and flatten 00016 class CleanupCompoundExpression : public SearchReplace 00017 { 00018 public: 00019 CleanupCompoundExpression(); 00020 }; 00021 00022 /// Find compound statements inside compund statements and flatten 00023 class CleanupCompoundMulti : public SearchReplace 00024 { 00025 public: 00026 CleanupCompoundMulti(); 00027 }; 00028 00029 /// Find compound blocks with only a single statement, and flatten 00030 class CleanupCompoundSingle : public SearchReplace 00031 { 00032 public: 00033 CleanupCompoundSingle(); 00034 }; 00035 00036 /// Get rid of Nops 00037 class CleanupNop : public SearchReplace 00038 { 00039 public: 00040 CleanupNop(); 00041 }; 00042 00043 /** Simplify the case where two lables appear together and are therefore 00044 duplicates. Just have one label. */ 00045 class CleanupDuplicateLabels : public SearchReplace 00046 { 00047 public: 00048 CleanupDuplicateLabels(); 00049 }; 00050 00051 /// Find a goto to a lable just before the label, and remove the goto 00052 class CleanupIneffectualGoto : public SearchReplace 00053 { 00054 public: 00055 CleanupIneffectualGoto(); 00056 }; 00057 00058 /// Find a goto to a lable just before the label, and remove the goto 00059 class CleanupIneffectualLabels : public SearchReplace 00060 { 00061 public: 00062 CleanupIneffectualLabels(); 00063 }; 00064 00065 /** Find labels never referenced (ie neither jumped to nor used as a variable) 00066 and dispense with them */ 00067 class CleanupUnusedLabels : public SearchReplace 00068 { 00069 public: 00070 CleanupUnusedLabels(); 00071 }; 00072 00073 /** Remove dead code in switch statements */ 00074 class CleanUpDeadCode : public SearchReplace 00075 { 00076 public: 00077 CleanUpDeadCode(); 00078 }; 00079 00080 /** turn a compound expression that does not end in an expression into an ordinary compound */ 00081 class ReduceVoidCompoundExpression : public SearchReplace 00082 { 00083 public: 00084 ReduceVoidCompoundExpression(); 00085 }; 00086 00087 /** Remove instances not used anywhere - except Callables and instances of InheritanceRecord since 00088 these might do something useful even when not referenced.*/ 00089 class CleanupUnusedVariables : public CompareReplace 00090 { 00091 public: 00092 CleanupUnusedVariables(); 00093 }; 00094 00095 /// Simplify if(x) if(y) z using && 00096 class CleanupNestedIf : public SearchReplace 00097 { 00098 public: 00099 CleanupNestedIf(); 00100 }; 00101 00102 }; // end namespace 00103 00104 #endif 00105