00001 #ifndef TRY_CATCH_STATEMENT_H_
00002 #define TRY_CATCH_STATEMENT_H_
00003
00004 #include "control_statement.h"
00005
00006 #include <vector>
00007
00008 namespace il
00009 {
00010
00014 class try_catch_statement : public il::control_statement
00015 {
00016 friend class boost::serialization::access;
00017
00018 template<class Archive>
00019 void save(Archive & ar, const unsigned int version) const
00020 {
00021 ar & boost::serialization::base_object<il::control_statement>(*this);
00022 ar & try_statement;
00023 ar & catch_types;
00024 ar & catch_bodies;
00025 }
00026
00027 template<class Archive>
00028 void load(Archive & ar, const unsigned int version)
00029 {
00030 ar & boost::serialization::base_object<il::control_statement>(*this);
00031 ar & try_statement;
00032 ar & catch_types;
00033 for(unsigned int i=0; i<catch_types.size(); i++) {
00034 type::register_loaded_typeref(&catch_types[i]);
00035 }
00036
00037 ar & catch_bodies;
00038 }
00039
00040 BOOST_SERIALIZATION_SPLIT_MEMBER()
00041 private:
00042 statement *try_statement;
00043
00047 vector<type *> catch_types;
00048 vector<statement *> catch_bodies;
00049
00050 public:
00051 try_catch_statement(statement *try_stmt, location loc);
00052 try_catch_statement(statement *try_stmt, location loc,
00053 vector<type *> catch_types, vector<statement *> catch_bodies);
00054 try_catch_statement();
00055 virtual ~try_catch_statement();
00056 void print();
00057 statement *get_try_statement();
00058 vector<type *> &get_catch_types();
00059 vector<statement *> &get_catch_bodies();
00060 void add_handler(type *catch_type, statement *catch_body);
00061 virtual string to_string() const;
00062
00063 };
00064
00065 }
00066
00067 #endif