00001 #ifndef TYPE_H_
00002 #define TYPE_H_
00003
00004 #include <assert.h>
00005
00006
00007
00008
00009 #include <vector>
00010 #include <iostream>
00011 #include <string>
00012 #include <unordered_map>
00013 #include <unordered_set>
00014 #include "../types.h"
00015 #include "../util.h"
00016 #include "./hash.h"
00017 #include "./namespace_context.h"
00018 using namespace std;
00019
00020
00021 #include <boost/serialization/vector.hpp>
00022 #include <boost/serialization/map.hpp>
00023 #include <boost/serialization/set.hpp>
00024 #include <boost/serialization/list.hpp>
00025 #include <boost/serialization/string.hpp>
00026 #include <boost/serialization/version.hpp>
00027 #include <boost/serialization/split_member.hpp>
00028 #include <boost/serialization/shared_ptr.hpp>
00029 #include <boost/serialization/base_object.hpp>
00030 #include <boost/serialization/export.hpp>
00031
00032 namespace il
00033 {
00034
00035 class expression;
00036 class function_declaration;
00037 class type;
00038
00039 enum value_type { INTEGER, IEEE_FLOAT, VOID, COMPLEX, BOOL };
00040 static unordered_map<string, type *> name_to_type;
00041
00042 enum type_attribute_kind {
00043 NO_TYPE_ATTRIBUTE,
00044 POSITION_DEPENDENT_ADT,
00045 SINGLE_VALUED_ADT,
00046 MULTI_VALUED_ADT
00047
00048 };
00049
00050
00051
00052
00053
00054
00055 #define SHARED_PRIVATE(classname) \
00056 classname() {} \
00057 virtual ~classname() {} \
00058 classname(const classname &rhs) {} \
00059 classname &operator=(const classname &rhs) { return *this; }
00060
00061 #define SHARED_PRIVATE_CUSTOM_DTOR(classname) \
00062 classname() {} \
00063 virtual ~classname(); \
00064 classname(const classname &rhs) {} \
00065 classname &operator=(const classname &rhs) { return *this; }
00066
00067 #define SHARED_DEFINE_MAKE_METHOD(classname, formals, ctorargs) \
00068 static classname *make formals \
00069 { \
00070 classname *__t = new classname ctorargs ; \
00071 return static_cast<classname *>(get_instance(__t)); \
00072 }
00073
00074
00075
00076
00080 class type
00081 {
00082 friend class boost::serialization::access;
00083 template<class Archive>
00084 void save(Archive & ar, const unsigned int version) const
00085 {
00086 ar & size;
00087 ar & asize;
00088 ar & typedef_name;
00089 }
00090
00091 template<class Archive>
00092 void load(Archive & ar, const unsigned int version)
00093 {
00094 ar & size;
00095 ar & asize;
00096 ar & typedef_name;
00097 }
00098
00099 BOOST_SERIALIZATION_SPLIT_MEMBER()
00100
00101 static bool _init;
00102 static bool init();
00103 static set<type*> unused_types;
00104
00105 static type* uniquify_type(type* t);
00106
00107
00108 private:
00109 type(const type &rhs) {}
00110 type &operator=(const type &rhs) { return *this; }
00111
00112 public:
00113 static void uniquify_loaded_types();
00114 struct type_hash {
00115 size_t operator()(type *t) const
00116 {
00117 return t->hash();
00118 }
00119 };
00120
00121 struct type_eq {
00122 bool operator()(type *a, type *b) const
00123 {
00124 return *a == *b;
00125 }
00126 };
00127
00128 static void clear();
00129
00130
00131
00132
00133
00134 protected:
00135 type() : hash_c(0) {}
00136 virtual ~type() {}
00137
00142 static type *get_instance(type *t);
00143
00144 static unordered_set<type *, type_hash, type_eq> instances;
00145
00146
00147
00148
00149 void rehash_begin();
00150 void rehash_end();
00151
00152 int size;
00153 int asize;
00154 string typedef_name;
00155
00156
00157 size_t hash_c;
00158
00159
00160 static set<type**> unresolved_types;
00161
00162 public:
00163
00164 static type *get_type_from_name(string name)
00165 {
00166 return name_to_type[name];
00167 }
00168
00169 static void insert_type(string name, type *t)
00170 {
00171 name_to_type[name] = t;
00172 }
00173
00174 void set_attribute( type_attribute_kind attrib, type* k, type* v);
00175
00176 type_attribute_kind get_attribute();
00177 type* get_adt_key_type();
00178 type* get_adt_value_type();
00179
00180 bool is_abstract_data_type();
00181
00182
00183
00184
00185
00186 static void register_loaded_typeref(type** t);
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 virtual bool operator==(const type& other) = 0;
00201 inline size_t hash()
00202 {
00203 return hash_c;
00204 }
00205
00206 virtual void print() {};
00207
00208 virtual string to_string() const {return "";} ;
00209
00210
00211 friend ostream& operator <<(ostream &os, const type &obj);
00212
00213
00214
00215
00216 virtual type *get_deref_type() const;
00217
00218 virtual type* get_inner_type()
00219 {
00220 return NULL;
00221 }
00222
00223 bool is_base_or_enum_type() const
00224 {
00225 return is_base_type() || is_enum_type();
00226 };
00227
00228 bool is_char_type() const;
00229
00230 bool is_array_type() const
00231 {
00232 return is_constarray_type() || is_vararray_type();
00233 }
00234
00235 virtual bool is_void_type() const { return false; }
00236
00237 bool is_void_star_type() const
00238 {
00239 return this->is_pointer_type() &&
00240 this->get_deref_type()->is_void_type();
00241 };
00242
00243 virtual string get_typedef_name()
00244 {
00245 return typedef_name;
00246 }
00247
00248 virtual bool is_pointer_type() const { return false; }
00249 virtual bool is_constarray_type() const { return false; }
00250 virtual bool is_vararray_type() const { return false; }
00251 virtual bool is_enum_type() const { return false; }
00252 virtual bool is_record_type() const { return false; }
00253 virtual bool is_vector_type() const { return false; }
00254 virtual bool is_complex_type() const { return false; }
00255 virtual bool is_base_type() const { return false; }
00256 virtual bool is_function_type() const { return false; }
00257
00258 virtual int get_size() { return size; }
00259 virtual int get_asize() { return asize; }
00260 virtual bool is_signed_type() const { return false; }
00261 virtual void print_kind() const
00262 {
00263 if(is_pointer_type())
00264 cout << "pointer type" << endl;
00265 if(is_constarray_type())
00266 cout << "constarray_type" << endl;
00267 if(is_vararray_type())
00268 cout << "vararray_type" << endl;
00269 if(is_enum_type())
00270 cout << "enum_type" << endl;
00271 if(is_record_type())
00272 cout << "record_type" << endl;
00273 if(is_vector_type())
00274 cout << "vector_type" << endl;
00275 if(is_complex_type())
00276 cout << "complex_type" << endl;
00277 if(is_base_type())
00278 cout << "base_type" << endl;
00279 if(is_function_type())
00280 cout << "function_type" << endl;
00281 }
00282
00283 };
00284
00285
00289 class pointer_type : public type
00290 {
00291 friend class boost::serialization::access;
00292
00293 template<class Archive>
00294 void save(Archive & ar, const unsigned int version) const
00295 {
00296 ar & boost::serialization::base_object<type>(*this);
00297 ar & elem_type;
00298 }
00299
00300 template<class Archive>
00301 void load(Archive & ar, const unsigned int version)
00302 {
00303 ar & boost::serialization::base_object<type>(*this);
00304 ar & elem_type;
00305 type::register_loaded_typeref(&elem_type);
00306 hash_c = 0;
00307 }
00308
00309 BOOST_SERIALIZATION_SPLIT_MEMBER()
00310
00311 private:
00312 SHARED_PRIVATE(pointer_type)
00313
00314 pointer_type(type *t, const string &typedef_name);
00315
00316 public:
00317 SHARED_DEFINE_MAKE_METHOD(pointer_type,
00318 (type *t, const string &typedef_name),
00319 (t, typedef_name))
00320
00321 type *elem_type;
00322
00323 static const int SIZE = 64;
00324 static const int ASIZE = 64;
00325
00326 virtual bool operator==(const type& _other);
00327 void compute_hash();
00328
00329 virtual bool is_pointer_type() const;
00330 virtual string to_string() const;
00331
00336 virtual type *get_deref_type() const;
00337 virtual type* get_inner_type();
00338
00339 };
00340
00344 class array_type : public type
00345 {
00346 friend class boost::serialization::access;
00347
00348 template<class Archive>
00349 void save(Archive & ar, const unsigned int version) const
00350 {
00351 ar & boost::serialization::base_object<type>(*this);
00352 }
00353
00354 template<class Archive>
00355 void load(Archive & ar, const unsigned int version)
00356 {
00357 ar & boost::serialization::base_object<type>(*this);
00358 }
00359
00360 BOOST_SERIALIZATION_SPLIT_MEMBER()
00361
00362 public:
00363 virtual ~array_type(){ };
00364 virtual string to_string() const = 0;
00365 virtual type *get_elem_type() = 0;
00366 };
00367
00368
00372 class constarray_type : public array_type
00373 {
00374 friend class boost::serialization::access;
00375
00376 template<class Archive>
00377 void save(Archive & ar, const unsigned int version) const
00378 {
00379 ar & boost::serialization::base_object<array_type>(*this);
00380 ar & elem_type;
00381 ar & num_elems;
00382 }
00383
00384 template<class Archive>
00385 void load(Archive & ar, const unsigned int version)
00386 {
00387 ar & boost::serialization::base_object<array_type>(*this);
00388 ar & elem_type;
00389 type::register_loaded_typeref(&elem_type);
00390 ar & num_elems;
00391 hash_c = 0;
00392
00393
00394 }
00395
00396 BOOST_SERIALIZATION_SPLIT_MEMBER()
00397
00398 private:
00399 SHARED_PRIVATE(constarray_type)
00400
00401 constarray_type(type *t, int64 num_elems, const string &typedef_name);
00402 void compute_hash();
00403
00404
00405 protected:
00406 type* elem_type;
00407 int64 num_elems;
00408
00409 public:
00410 SHARED_DEFINE_MAKE_METHOD(constarray_type,
00411 (type *t, int64 num_elems, const string &typedef_name),
00412 (t, num_elems, typedef_name))
00413
00414 virtual bool operator==(const type& _other);
00415
00416 virtual type* get_inner_type();
00417
00418 virtual bool is_constarray_type() const;
00419 virtual string to_string() const;
00420
00421 virtual type *get_elem_type();
00422 virtual int64 get_num_elems();
00423 virtual int get_size();
00424 virtual int get_asize();
00425
00426 };
00427
00431 class vararray_type : public array_type
00432 {
00433 friend class boost::serialization::access;
00434
00435 template<class Archive>
00436 void save(Archive & ar, const unsigned int version) const
00437 {
00438 ar & boost::serialization::base_object<array_type>(*this);
00439 ar & elem_type;
00440 ar & num_elems;
00441 }
00442
00443 template<class Archive>
00444 void load(Archive & ar, const unsigned int version)
00445 {
00446 ar & boost::serialization::base_object<array_type>(*this);
00447 ar & elem_type;
00448 type::register_loaded_typeref(&elem_type);
00449 ar & num_elems;
00450 hash_c = 0;
00451
00452 }
00453
00454 BOOST_SERIALIZATION_SPLIT_MEMBER()
00455
00456 private:
00457 SHARED_PRIVATE(vararray_type)
00458
00459 vararray_type(type *t, expression *num_elems, const string &typedef_name);
00460 void compute_hash();
00461
00462 protected:
00463 type *elem_type;
00464 expression *num_elems;
00465
00466 public:
00467 SHARED_DEFINE_MAKE_METHOD(vararray_type,
00468 (type *t, expression *num_elems, const string &typedef_name),
00469 (t, num_elems, typedef_name))
00470
00471 virtual bool operator==(const type& _other);
00472
00473 virtual bool is_vararray_type() const;
00474 virtual string to_string() const;
00475
00476 virtual type* get_inner_type();
00477 virtual type *get_elem_type();
00478 virtual expression * get_num_elems();
00479 };
00480
00481 struct enum_info
00482 {
00483 friend class boost::serialization::access;
00484 template<class Archive>
00485 void save(Archive & ar, const unsigned int version) const
00486 {
00487 ar & fname;
00488 ar & value;
00489 }
00490 template<class Archive>
00491 void load(Archive & ar, const unsigned int version)
00492 {
00493 ar & fname;
00494 ar & value;
00495 }
00496 BOOST_SERIALIZATION_SPLIT_MEMBER()
00497 string fname;
00498 int64 value;
00499 virtual ~enum_info(){};
00500 friend ostream& operator <<(ostream &os, const type &obj);
00501
00502
00503
00504 };
00505
00509 class enum_type : public type
00510 {
00511 public:
00512 vector<enum_info*> elems;
00513 string name;
00514 namespace_context ns;
00515 bool is_signed;
00516
00517 friend class boost::serialization::access;
00518
00519 template<class Archive>
00520 void save(Archive & ar, const unsigned int version) const
00521 {
00522 ar & boost::serialization::base_object<type>(*this);
00523 ar & elems;
00524 ar & name;
00525 ar & ns;
00526 ar & is_signed;
00527 }
00528
00529 template<class Archive>
00530 void load(Archive & ar, const unsigned int version)
00531 {
00532 ar & boost::serialization::base_object<type>(*this);
00533 ar & elems;
00534 ar & name;
00535 ar & ns;
00536 ar & is_signed;
00537 compute_hash_code();
00538 }
00539
00540 BOOST_SERIALIZATION_SPLIT_MEMBER()
00541
00542 private:
00543 SHARED_PRIVATE(enum_type)
00544
00545 enum_type(string name, namespace_context ctx, int size, int asize,
00546 bool is_signed, vector<enum_info> & elems,
00547 const string& typedef_name);
00548 void compute_hash_code();
00549
00550 public:
00551 SHARED_DEFINE_MAKE_METHOD(enum_type,
00552 (string name, namespace_context ctx, int size, int asize,
00553 bool is_signed, vector<enum_info> &elems, const string &typedef_name),
00554 (name, ctx, size, asize, is_signed, elems, typedef_name))
00555
00556 virtual bool operator==(const type& _other);
00557 virtual string to_string() const;
00558 virtual bool is_enum_type() const;
00559 vector<enum_info*> & get_fields();
00560 virtual bool is_signed_type() const;
00561 };
00562
00566 struct record_info
00567 {
00568 friend class boost::serialization::access;
00569
00570 template<class Archive>
00571 void save(Archive & ar, const unsigned int version) const
00572 {
00573 ar & fname;
00574 ar & offset;
00575 ar & t;
00576 }
00577
00578 template<class Archive>
00579 void load(Archive & ar, const unsigned int version)
00580 {
00581 ar & fname;
00582 ar & offset;
00583 ar & t;
00584 type::register_loaded_typeref(&t);
00585 }
00586
00587 BOOST_SERIALIZATION_SPLIT_MEMBER()
00588
00589 string fname;
00590 int offset;
00591 type *t;
00592 virtual ~record_info(){ };
00593 friend ostream& operator <<(ostream &os, const type &obj);
00594
00595 };
00596
00597
00598 enum record_kind {
00599 STRUCT,
00600 UNION,
00601 CLASS
00602 };
00603
00607 class record_type : public type
00608 {
00609 friend class boost::serialization::access;
00610
00611 template<class Archive>
00612 void save(Archive & ar, const unsigned int version) const
00613 {
00614
00615
00616 ((record_type*)this)->compute_recursive_fields();
00617 ar & boost::serialization::base_object<type>(*this);
00618
00619 ar & name;
00620 ar & ns;
00621 ar & kind;
00622 ar & abstract;
00623
00624 ar & elems;
00625 ar & name_to_record_info;
00626 ar & offset_to_elem;
00627
00628 ar & bases;
00629 ar & derivatives;
00630
00631 ar & recursive_fields;
00632
00633 ar & member_functions;
00634 }
00635
00636 template<class Archive>
00637 void load(Archive & ar, const unsigned int version)
00638 {
00639 ar & boost::serialization::base_object<type>(*this);
00640
00641
00642 ar & name;
00643 ar & ns;
00644 ar & kind;
00645 ar & abstract;
00646
00647 ar & elems;
00648 ar & name_to_record_info;
00649 ar & offset_to_elem;
00650
00651 ar & bases;
00652 map<int, record_type*>::iterator it = bases.begin();
00653 for(; it!= bases.end(); it++)
00654 {
00655 int offset = it->first;
00656 type::register_loaded_typeref((type**)&it->second);
00657
00658
00659 }
00660 ar & derivatives;
00661 for(unsigned int i=0; i<derivatives.size(); i++)
00662 {
00663 type::register_loaded_typeref((type**)&derivatives[i]);
00664 }
00665
00666
00667 ar & recursive_fields;
00668 compare_all_fields = true;
00669 ar & member_functions;
00670 compute_hash();
00671
00672 }
00673
00674 BOOST_SERIALIZATION_SPLIT_MEMBER()
00675
00676 public:
00677 vector<record_info*> elems;
00678 map<string, record_info*> name_to_record_info;
00679 map<int, record_info*> offset_to_elem;
00680 vector<function_declaration *> member_functions;
00681
00682 map<int, record_type*> bases;
00683 vector<record_type *> derivatives;
00684
00685 string name;
00686 namespace_context ns;
00687 record_kind kind;
00688 vector<record_info*> recursive_fields;
00689
00690
00691
00692
00693
00694
00695 bool compare_all_fields;
00696
00697
00698
00699
00700 bool abstract;
00701
00702
00703 void compute_recursive_fields();
00704
00705 private:
00706 SHARED_PRIVATE_CUSTOM_DTOR(record_type)
00707
00708 record_type(string name,
00709 namespace_context ctx,
00710 int size,
00711 int asize,
00712 bool is_union,
00713 bool is_class,
00714 const vector<record_info *> &elems,
00715 const string& typedef_name, bool is_abstract);
00716 void compute_hash();
00717
00718
00719
00720
00721 public:
00722 SHARED_DEFINE_MAKE_METHOD(record_type,
00723 (string name,
00724 namespace_context ctx,
00725 int size,
00726 int asize,
00727 bool is_union,
00728 bool is_class,
00729 const vector<record_info*> &elems,
00730 const string &typedef_name, bool is_abstract),
00731 (name, ctx, size, asize, is_union, is_class, elems,
00732 typedef_name, is_abstract))
00733
00734 virtual bool operator==(const type& _other);
00735
00736 void add_member_function(function_declaration *fd);
00737 vector<function_declaration *> &get_member_functions();
00738
00739 void update_incomplete_record(int size, int asize,
00740 const vector<record_info*> &elems, bool is_abstract);
00741
00742
00743 void add_base(record_type *base, long int offset);
00744 const map<int, record_type*> &get_bases();
00745 void add_derivative(record_type *sub);
00746 vector<record_type *> &get_derivatives();
00747
00752 void get_transitive_subclasses(set<record_type*>& subclasses);
00753
00754 type** get_typeref_from_index(int i);
00755
00756 bool is_recursive();
00757 vector<record_info *> &get_recursive_fields();
00758
00762 bool has_virtual_methods();
00763
00767 bool is_abstract();
00768
00769
00776 void get_all_methods(set<function_declaration*>& all_methods);
00777
00778
00779 virtual string to_string() const;
00780 virtual bool is_record_type() const;
00781
00785 bool is_supertype_of(il::record_type* t);
00786
00790 bool is_subtype_of(il::record_type* t);
00791
00797 void get_classes_inheriting_method(string fun_name, il::type* signature,
00798 set<il::record_type*>& inheriting_classes);
00799
00804 bool contains_method(string fun_name, type* sig);
00805
00806 vector<record_info *> &get_fields();
00807
00808 record_info *get_field_from_name(string name);
00809
00810
00811
00812
00813
00814 record_info *get_field_from_offset(int offset);
00815
00816 bool is_struct();
00817 bool is_class();
00818 bool is_union();
00819
00820
00821 };
00822
00823
00833 class vector_type : public type
00834 {
00835 friend class boost::serialization::access;
00836 template<class Archive>
00837 void save(Archive & ar, const unsigned int version) const
00838 {
00839 ar & boost::serialization::base_object<type>(*this);
00840 ar & elem_type;
00841 ar & num_elems;
00842 }
00843 template<class Archive>
00844 void load(Archive & ar, const unsigned int version)
00845 {
00846 ar & boost::serialization::base_object<type>(*this);
00847 ar & elem_type;
00848 type::register_loaded_typeref(&elem_type);
00849 ar & num_elems;
00850 hash_c = 0;
00851 }
00852 BOOST_SERIALIZATION_SPLIT_MEMBER()
00853
00854 private:
00855 SHARED_PRIVATE(vector_type)
00856
00857 vector_type(type *elem_type, int num_elems);
00858 void compute_hash();
00859
00860 protected:
00861 type *elem_type;
00862 int num_elems;
00863
00864 public:
00865
00866 SHARED_DEFINE_MAKE_METHOD(vector_type,
00867 (type *elem_type, int num_elems),
00868 (elem_type, num_elems))
00869
00870 virtual bool operator==(const type& _other);
00871 virtual int get_num_elems();
00872 virtual type *get_elem_type();
00873 virtual string to_string() const;
00874 virtual bool is_vector_type() const;
00875
00876 virtual int get_size();
00877 virtual int get_asize();
00878
00879 };
00880
00884 class complex_type: public type
00885 {
00886 friend class boost::serialization::access;
00887 template<class Archive>
00888 void save(Archive & ar, const unsigned int version) const
00889 {
00890 ar & boost::serialization::base_object<type>(*this);
00891 ar & elem_type;
00892 }
00893 template<class Archive>
00894 void load(Archive & ar, const unsigned int version)
00895 {
00896 ar & boost::serialization::base_object<type>(*this);
00897 ar & elem_type;
00898 il::type::register_loaded_typeref(&elem_type);
00899 hash_c = 0;
00900 }
00901 BOOST_SERIALIZATION_SPLIT_MEMBER()
00902
00903 private:
00904 ;
00905 SHARED_PRIVATE(complex_type)
00906
00907 complex_type(type *elem_type);
00908 void compute_hash();
00909
00910 protected:
00911 type *elem_type;
00912 public:
00913
00914 SHARED_DEFINE_MAKE_METHOD(complex_type,
00915 (type *elem_type),
00916 (elem_type))
00917
00918 virtual bool operator==(const type& _other);
00919
00920 virtual type *get_elem_type();
00921 virtual string to_string() const;
00922 virtual bool is_complex_type() const;
00923
00924 virtual int get_size();
00925 virtual int get_asize();
00926
00927 };
00928
00929
00933 class function_type: public type
00934 {
00935 friend class boost::serialization::access;
00936 template<class Archive>
00937 void save(Archive & ar, const unsigned int version) const
00938 {
00939 ar & boost::serialization::base_object<type>(*this);
00940 ar & ret_type;
00941 ar & arg_types;
00942 ar & is_vararg;
00943 }
00944 template<class Archive>
00945 void load(Archive & ar, const unsigned int version)
00946 {
00947 ar & boost::serialization::base_object<type>(*this);
00948 ar & ret_type;
00949 if(ret_type != NULL) {
00950 type::register_loaded_typeref(&ret_type);
00951 }
00952 ar & arg_types;
00953 for(unsigned int i=0; i<arg_types.size(); i++) {
00954 type::register_loaded_typeref(&arg_types[i]);
00955 }
00956 ar & is_vararg;
00957 hash_c = 0;
00958 }
00959 BOOST_SERIALIZATION_SPLIT_MEMBER()
00960
00961 private:
00962 SHARED_PRIVATE(function_type)
00963
00964 function_type(type *ret_type, const vector<type*> &arg_types, bool is_vararg);
00965 void compute_hash();
00966
00967 public:
00968 type *ret_type;
00969 vector<type*> arg_types;
00970 bool is_vararg;
00971
00972 public:
00973 SHARED_DEFINE_MAKE_METHOD(function_type,
00974 (type *ret_type, const vector<type *> &arg_types, bool is_vararg),
00975 (ret_type, arg_types, is_vararg))
00976
00977 virtual bool operator==(const type& _other);
00978
00979 virtual type *get_return_type();
00980 const vector<type*> & get_arg_types();
00981 virtual string to_string() const;
00982 string to_byte_string() const;
00983 virtual bool is_function_type() const;
00984
00991 function_type* get_method_signature();
00992
00993 };
00994
00995
00999 class base_type: public type
01000 {
01001 friend class boost::serialization::access;
01002 template<class Archive>
01003 void save(Archive & ar, const unsigned int version) const
01004 {
01005 ar & boost::serialization::base_object<type>(*this);
01006 ar & name;
01007 ar & is_signed;
01008 ar & vt;
01009 }
01010 template<class Archive>
01011 void load(Archive & ar, const unsigned int version)
01012 {
01013 ar & boost::serialization::base_object<type>(*this);
01014 ar & name;
01015 ar & is_signed;
01016 ar & vt;
01017 compute_hash();
01018 }
01019 BOOST_SERIALIZATION_SPLIT_MEMBER()
01020
01021 private:
01022 SHARED_PRIVATE(base_type)
01023
01024 base_type(string name,
01025 int size,
01026 int asize,
01027 bool is_signed,
01028 value_type vt,
01029 string typedef_name);
01030
01031 void compute_hash();
01032
01033 public:
01034 string name;
01035 bool is_signed;
01036 value_type vt;
01037
01038 public:
01039 SHARED_DEFINE_MAKE_METHOD(base_type,
01040 (string name,
01041 int size,
01042 int asize,
01043 bool is_signed,
01044 value_type vt,
01045 string typedef_name),
01046 (name, size, asize, is_signed, vt, typedef_name))
01047
01048 virtual bool operator==(const type& _other);
01049
01050 virtual string get_name() const;
01051
01052 virtual bool is_void_type() const;
01053 virtual bool is_signed_type() const;
01054 virtual string to_string() const;
01055 virtual bool is_base_type() const;
01056
01057 };
01058
01059
01060
01061
01062
01063 ostream& operator <<(ostream &os, const type &obj);
01064
01065
01066 type * get_integer_type();
01067 type *get_unsigned_integer_type();
01068 type *get_char_type();
01069 type* get_void_type();
01070 type* get_void_ptr_type();
01071 function_type* get_void_function_type();
01072
01073
01074 }
01075
01076 #endif
01077
01078