MCPcopy Create free account
hub / github.com/covscript/covscript / do_inherit

Method do_inherit

sources/instance/statement.cpp:155–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

run_implMethod · 0.80

Calls 5

runtime_errorClass · 0.85
parse_exprMethod · 0.80
usableMethod · 0.45
rootMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected