Debian Codegraph @

cutl/compiler/type-info.ixx

raw
1 // file : cutl/compiler/type-info.ixx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : MIT; see accompanying LICENSE file
4
5 namespace cutl
6 {
7 namespace compiler
8 {
9 // base_info
10 //
11
12 inline
13 base_info::
14 base_info (type_id const& type_id)
15 : type_id_ (type_id), type_info_ (0)
16 {
17 }
18
19 inline
20 type_info_t const& base_info::
21 type_info () const
22 {
23 // We need to do delayed lookup because of the unpredictable
24 // order in which type information may be added.
25 //
26 // @@ MT-unsafe
27 //
28 if (type_info_ == 0)
29 type_info_ = &(lookup (type_id_));
30
31 return *type_info_;
32 }
33
34 // type_info
35 //
36
37 inline
38 type_info::
39 type_info (type_id_t const& tid)
40 : type_id_ (tid)
41 {
42 }
43
44 inline
45 type_id_t type_info::
46 type_id () const
47 {
48 return type_id_;
49 }
50
51 inline
52 type_info::base_iterator type_info::
53 begin_base () const
54 {
55 return bases_.begin ();
56 }
57
58
59 inline
60 type_info::base_iterator type_info::
61 end_base () const
62 {
63 return bases_.end ();
64 }
65
66 inline
67 void type_info::
68 add_base (type_id_t const& tid)
69 {
70 bases_.push_back (base_info (tid));
71 }
72
73 //
74 //
75 inline type_info const&
76 lookup (std::type_info const& tid)
77 {
78 return lookup (type_id (tid));
79 }
80
81 template <typename X>
82 inline type_info const&
83 lookup (X const volatile& x)
84 {
85 return lookup (typeid (x));
86 }
87
88 template<typename X>
89 inline type_info const&
90 lookup ()
91 {
92 return lookup (typeid (X));
93 }
94 }
95 }