00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef BRANCH_H_
00016 #define BRANCH_H_
00017
00018 #include "Instruction.h"
00019
00020 #include<string>
00021 #include <vector>
00022 using namespace std;
00023
00024 namespace il{class node;}
00025
00026 namespace sail {
00027 class Variable;
00028 class Label;
00029 class Symbol;
00030
00040 class Branch: public Instruction {
00041 friend class boost::serialization::access;
00042
00043 template<class Archive>
00044 void serialize(Archive & ar, const unsigned int version)
00045 {
00046 ar & boost::serialization::base_object<sail::Instruction>(*this);
00047 ar & targets;
00048 ar & is_if;
00049 }
00050
00051 private:
00052 vector<pair<Symbol*, Label*> > *targets;
00053 bool is_if;
00054
00055 public:
00056
00057
00058
00059 Branch(Symbol* if_var, Symbol* else_var, Label* then_label, Label* else_label,
00060 il::node* original);
00061
00062
00063
00064
00065 Branch(vector<pair<Symbol*, Label*> > *targets,
00066 il::node* original);
00067 Branch(){targets = NULL;};
00068 virtual string to_string() const;
00069 virtual string to_string(bool pretty_print) const;
00070
00076 bool is_if_statement();
00077
00082 vector<pair<Symbol*, Label*> > * get_targets();
00083
00088 Label* get_then_label();
00089
00094 Label* get_else_label();
00095
00100 Symbol* get_if_condition();
00101
00106 Symbol* get_else_condition();
00107 virtual bool is_removable();
00108 virtual ~Branch();
00109 };
00110
00111 }
00112
00113 #endif