00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef MORE_LANG_CX_LOCATOR_H
00031 #define MORE_LANG_CX_LOCATOR_H
00032
00033 #include <stdexcept>
00034 #include <more/gen/gc_string.h>
00035 #include <more/lang/fwd.h>
00036 #include <more/lang/ct_struct.h>
00037 #include <more/lang/ct_proto.h>
00038 #include <more/lang/cx_expr.h>
00039 #include <more/lang/location.h>
00040
00041
00042 namespace more {
00043 namespace lang {
00044
00045
00046
00047 struct cx_locator : cx_expr
00048 {
00049 typedef std::size_t size_type;
00050 private:
00051 typedef ct_struct::member_const_iterator member_const_iterator;
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 protected:
00062
00063 cx_locator(cx_locator* cxt_locr,
00064 ct_type const* cxt_type,
00065 ct_type const* result_type,
00066 size_type offset_count);
00067
00068
00069 cx_locator(ct_type const* arg0_type,
00070 ct_type const* result_type);
00071
00072 public:
00073
00074 ct_type const* result_type() const
00075 {
00076 return static_cast<ct_proto const*>(type_of())->result_type();
00077 }
00078
00079
00080 ct_type const* arg0_type() const
00081 {
00082 return static_cast<ct_proto const*>(type_of())->arg_type(0);
00083 }
00084
00085 virtual void print_operation_pre(std::ostream&) const = 0;
00086 virtual void print_operation_post(std::ostream&) const = 0;
00087
00088 virtual void append_ctors_to(cx_block*);
00089 virtual void append_dtors_to(cx_block*);
00090
00091
00092
00093
00094 cx_locator const* context_locator() const { return m_cxt_locr; }
00095
00096
00097
00098
00099
00100
00101 friend bool
00102 equal(cx_locator* loc0, cx_locator* loc1)
00103 {
00104 return loc0->offset_count() == loc1->offset_count()
00105 && std::equal(loc0->offset_begin(), loc0->offset_end(),
00106 loc1->offset_begin());
00107 }
00108
00109 protected:
00110
00111
00112
00113 ct_type const* context_type() const { return m_cxt_type; }
00114
00115 public:
00116
00117 void* apply(void* ptr);
00118
00119 void debug_dump(std::ostream& os);
00120
00121 private:
00122 size_type offset_count() const { return m_offset_count; }
00123 size_type const* offset_begin() const { return m_offset_arr; }
00124 size_type const* offset_end() const
00125 {
00126 return m_offset_arr + m_offset_count;
00127 }
00128
00129
00130 cx_locator const* m_cxt_locr;
00131 ct_type const* m_cxt_type;
00132
00133
00134
00135
00136 size_type m_offset_count;
00137 size_type* m_offset_arr;
00138
00139 friend struct cx_member_locator;
00140 friend struct cx_deref_locator;
00141 friend struct rt_arg_locator;
00142 friend struct rt_result_locator;
00143 };
00144
00145
00146 struct cx_member_locator : cx_locator
00147 {
00148 cx_member_locator(ct_struct const*, ct_struct::member_const_iterator);
00149 cx_member_locator(cx_locator*, ct_struct::member_const_iterator);
00150 cx_member_locator(cx_locator*, cx_member_locator const*);
00151
00152 virtual ct_type const* result_type() const;
00153 virtual void print_operation_pre(std::ostream&) const;
00154 virtual void print_operation_post(std::ostream&) const;
00155
00156 ct_struct const* context_type() const
00157 {
00158 return static_cast<ct_struct const*>(m_cxt_type);
00159 }
00160
00161 private:
00162 ct_struct::member_const_iterator m_it_memb;
00163 };
00164
00165
00166 struct cx_deref_locator : cx_locator
00167 {
00168 explicit cx_deref_locator(ct_pointer const*);
00169 explicit cx_deref_locator(cx_locator*);
00170 cx_deref_locator(cx_locator*, cx_deref_locator const*);
00171
00172 virtual ct_type const* result_type() const;
00173 virtual void print_operation_pre(std::ostream&) const;
00174 virtual void print_operation_post(std::ostream&) const;
00175
00176 ct_pointer const* context_type() const
00177 {
00178 return static_cast<ct_pointer const*>(m_cxt_type);
00179 }
00180 };
00181
00182
00183
00184
00185 struct cx_locator_resolver : resolver
00186 {
00187
00188 cx_locator_resolver(resolver* h, cx_locator* lr)
00189 : m_locn(h),
00190 m_locr(lr) {}
00191
00192 virtual ct_type const* resolve_type_of() const;
00193 virtual void* resolve();
00194 virtual bool equal_to(resolver* rhs);
00195
00196 private:
00197 location m_locn;
00198 cx_locator* m_locr;
00199 };
00200
00201 }}
00202
00203 #endif