00001
00002
00003 #ifndef VARIABLE_DECLARATION_H_
00004 #define VARIABLE_DECLARATION_H_
00005
00006
00007 #include "declaration.h"
00008 #include "namespace_context.h"
00009 #include <iostream>
00010
00011
00012
00013 namespace il
00014 {
00015 class variable;
00016 class expression;
00017
00022 class variable_declaration : public il::declaration
00023 {
00024 friend class boost::serialization::access;
00025
00026 template<class Archive>
00027 void serialize(Archive & ar, const unsigned int version)
00028 {
00029 ar & boost::serialization::base_object<il::declaration>(*this);
00030 ar & var;
00031 ar & ns;
00032 ar & init_exp;
00033 }
00034 private:
00035 variable *var;
00036 expression *init_exp;
00037 namespace_context ns;
00038 public:
00039 friend ostream& operator <<(ostream &os, const variable_declaration *obj);
00040 variable_declaration(variable * v, namespace_context ns, expression *init,
00041 location loc);
00042 variable_declaration();
00043 virtual ~variable_declaration();
00044 void set_initializer(expression* init);
00045 variable* get_variable();
00046 bool has_initializer();
00047 expression *get_initializer();
00048 const namespace_context& get_namespace() const;
00049 void print();
00050 node **get_init_ref()
00051 {
00052 return (node**)(&init_exp);
00053 };
00054 virtual string to_string() const;
00055 virtual bool is_fun_decl();
00056 virtual bool is_var_decl();
00057
00058
00059 };
00060
00061 }
00062
00063 #endif