00001 #ifndef FUNCTION_DECLARATION_H_
00002 #define FUNCTION_DECLARATION_H_
00003
00004 #include "declaration.h"
00005 #include <vector>
00006 #include <string>
00007
00008 using namespace std;
00009
00010 #include "location.h"
00011 #include <vector>
00012 #include "variable.h"
00013 #include "namespace_context.h"
00014
00015 namespace il
00016 {
00017 class block;
00018 class variable_declaration;
00019 class function_declaration;
00020
00021
00025 class function_declaration : public il::declaration
00026 {
00027 friend class boost::serialization::access;
00028
00029 template<class Archive>
00030 void save(Archive & ar, const unsigned int version) const
00031 {
00032 ar & boost::serialization::base_object<il::declaration>(*this);
00033 ar & qt;
00034 ar & name;
00035 ar & ns;
00036 ar & ret_type;
00037 ar & arguments;
00038 ar & body;
00039 ar & is_alloc;
00040 ar & is_dealloc;
00041 ar & constructor;
00042 ar & destructor;
00043 ar & is_inline;
00044 ar & vararg;
00045 ar & member_function;
00046 ar & static_member_function;
00047 ar & is_virtual;
00048 ar & is_abstract;
00049 ar & signature;
00050 }
00051
00052 template<class Archive>
00053 void load(Archive & ar, const unsigned int version)
00054 {
00055 ar & boost::serialization::base_object<il::declaration>(*this);
00056 ar & qt;
00057 ar & name;
00058 ar & ns;
00059 ar & ret_type;
00060 type::register_loaded_typeref(&ret_type);
00061 ar & arguments;
00062 ar & body;
00063 ar & is_alloc;
00064 ar & is_dealloc;
00065 ar & constructor;
00066 ar & destructor;
00067 ar & is_inline;
00068 ar & vararg;
00069 ar & member_function;
00070 ar & static_member_function;
00071 ar & is_virtual;
00072 ar & is_abstract;
00073 ar & signature;
00074 il::type::register_loaded_typeref((il::type**)&signature);
00075 }
00076
00077 BOOST_SERIALIZATION_SPLIT_MEMBER()
00078
00079 private:
00080 qualifier_type qt;
00081 string name;
00082 namespace_context ns;
00083 type *ret_type;
00084 vector<variable_declaration*> arguments;
00085 block* body;
00086 bool is_alloc;
00087 bool is_dealloc;
00088 bool constructor;
00089 bool destructor;
00090 bool is_inline;
00091 bool vararg;
00092 bool member_function;
00093 bool static_member_function;
00094 bool is_virtual;
00095 bool is_abstract;
00096 function_type* signature;
00097
00098 public:
00099 function_declaration();
00100 function_declaration(string name,
00101 namespace_context ns,
00102 qualifier_type qt,
00103 type *ret_type,
00104 vector<variable_declaration *> &args,
00105 block *body,
00106 bool is_alloc,
00107 bool is_dealloc,
00108 bool is_constructor,
00109 bool is_destructor,
00110 bool is_inline,
00111 bool is_vararg,
00112 bool is_member_function,
00113 bool is_static_member_function,
00114 bool is_virtual,
00115 bool is_abstract,
00116 function_type *sig);
00117
00118 friend ostream &operator<<(ostream &os, const function_declaration &obj);
00119
00123 string get_name();
00124
00129 int get_num_args();
00130
00131
00132
00136 bool is_method();
00137
00141 bool is_virtual_method();
00142
00143
00147 bool is_abstract_virtual_method();
00148
00152 bool is_static_method();
00153
00157 bool is_allocator();
00158
00162 bool is_deallocator();
00163
00167 bool is_constructor();
00168
00172 bool is_destructor();
00173
00174
00175
00180 block* get_body();
00181
00185 void set_body(block *b);
00186
00191 const vector<variable_declaration*> & get_arguments();
00192
00197 type* get_ret_type();
00198
00202 const il::namespace_context & get_namespace();
00203
00204
00208 bool is_vararg();
00209
00213 bool is_inlined();
00214 virtual ~function_declaration();
00215 virtual void print();
00216 virtual string to_string() const;
00217 virtual bool is_fun_decl();
00218 virtual bool is_var_decl();
00219
00223 virtual function_type *get_signature();
00224 };
00225
00226 }
00227
00228 #endif