00001 #ifndef IL_SWITCH_STATEMENT_H_
00002 #define IL_SWITCH_STATEMENT_H_
00003
00004 #include "control_statement.h"
00005
00006 #include <vector>
00007 #include <map>
00008 #include <set>
00009
00010 using namespace std;
00011
00012 namespace il
00013 {
00014 class expression;
00015 class case_label;
00016
00020 class switch_statement : public il::control_statement
00021 {
00022 friend class boost::serialization::access;
00023
00024 template<class Archive>
00025 void serialize(Archive & ar, const unsigned int version)
00026 {
00027 ar & boost::serialization::base_object<il::control_statement>(*this);
00028 ar & cond;
00029 ar & body;
00030 ar & case_labels;
00031 }
00032 private:
00033 expression* cond;
00034 statement* body;
00035
00036 vector<case_label*>* case_labels;
00037
00038
00039
00040
00041
00042
00043
00044 vector<pair<long, long> > case_label_ranges;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 map<case_label*, vector<case_label*>* >* equivalence_classes;
00059
00060 map<case_label*, vector<pair<long, long> > * > equivalence_class_ranges;
00061
00062 public:
00063 switch_statement();
00064 switch_statement(expression* cond, statement* body,
00065 vector<case_label*>* case_labels,
00066 map<case_label*, vector<case_label*>* >* representatives,
00067 location loc);
00068 expression* get_cond();
00069 statement* get_body();
00070 vector<case_label*>* get_case_labels();
00071
00072
00073
00074
00075
00076
00077
00078 vector<pair<long, long> > & get_case_ranges();
00079
00080
00081
00082
00083
00084 map<case_label*, vector<pair<long, long> > * > &
00085 get_equivalence_class_ranges();
00086 virtual ~switch_statement();
00087 virtual void print();
00088 virtual string to_string() const;
00089 map<case_label*, vector<case_label*>* >* get_label_equivalence_classes();
00090
00091 private:
00092
00093
00094
00095
00096 void coalesce_labels(vector<case_label*> * labels,
00097 vector<pair<long, long> > & ranges,
00098 set<case_label*> * default_eq_class);
00099
00100 };
00101
00102 }
00103
00104 #endif