diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-06 12:52:53 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-06 12:52:53 +0200 |
commit | cb9ea47e7825b5073d4d645afb94f6326cb7cf4d (patch) | |
tree | 201c215b08df918924153a60520046c294438a6b /cutl/compiler/type-info.hxx |
Start the libcutl repository
Diffstat (limited to 'cutl/compiler/type-info.hxx')
-rw-r--r-- | cutl/compiler/type-info.hxx | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/cutl/compiler/type-info.hxx b/cutl/compiler/type-info.hxx new file mode 100644 index 0000000..f970067 --- /dev/null +++ b/cutl/compiler/type-info.hxx @@ -0,0 +1,109 @@ +// file : cutl/compiler/type-info.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef CUTL_COMPILER_TYPE_INFO_HXX +#define CUTL_COMPILER_TYPE_INFO_HXX + +#include <map> +#include <vector> +#include <typeinfo> // std::type_info + +#include <cutl/static-ptr.hxx> +#include <cutl/compiler/type-id.hxx> + +namespace cutl +{ + namespace compiler + { + // + // + class type_info; + typedef type_info type_info_t; + + + // + // + class base_info + { + public: + base_info (type_id const&); + + public: + type_info_t const& + type_info () const; + + private: + type_id type_id_; + mutable type_info_t const* type_info_; + }; + + typedef base_info base_info_t; + + + // + // + class type_info + { + typedef std::vector<base_info> bases; + + public: + typedef + bases::const_iterator + base_iterator; + + public: + type_info (type_id_t const&); + + type_id_t + type_id () const; + + base_iterator + begin_base () const; + + base_iterator + end_base () const; + + void + add_base (type_id_t const&); + + private: + type_id_t type_id_; + bases bases_; + }; + + + // + // + class no_type_info {}; + + type_info const& + lookup (type_id const&); + + type_info const& + lookup (std::type_info const&); + + template <typename X> + type_info const& + lookup (X const volatile&); + + template<typename X> + type_info const& + lookup (); + + void + insert (type_info const&); + + namespace bits + { + struct default_type_info_id {}; + typedef std::map<type_id, type_info> type_info_map; + static static_ptr<type_info_map, default_type_info_id> type_info_map_; + } + } +} + +#include <cutl/compiler/type-info.ixx> + +#endif // CUTL_COMPILER_TYPE_INFO_HXX |