| 153 | } |
| 154 | |
| 155 | void struct_builder::do_inherit() |
| 156 | { |
| 157 | if (mParent.root().usable()) { |
| 158 | var builder = mContext->instance->parse_expr(mParent.root()); |
| 159 | if (builder.is_type_of<type_t>()) { |
| 160 | const auto &t = builder.const_val<type_t>(); |
| 161 | if (mTypeId == t.id) |
| 162 | throw runtime_error("Can not inherit itself."); |
| 163 | if (t.id.type_hash) { |
| 164 | for (std::size_t it = t.id.type_hash;;) { |
| 165 | type_id::inherit_map[it].insert(mTypeId.type_hash); |
| 166 | auto map_it = mParentMap.find(it); |
| 167 | if (map_it != mParentMap.end()) |
| 168 | it = map_it->second; |
| 169 | else |
| 170 | break; |
| 171 | } |
| 172 | mParentMap[mTypeId.type_hash] = t.id.type_hash; |
| 173 | } |
| 174 | else |
| 175 | throw runtime_error("Target is not a struct."); |
| 176 | } |
| 177 | else |
| 178 | throw runtime_error("Target is not a type."); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | var struct_builder::operator()() |
| 183 | { |
no test coverage detected