MCPcopy Create free account
hub / github.com/covscript/covscript / operator()

Method operator()

sources/instance/statement.cpp:182–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180 }
181
182 var struct_builder::operator()()
183 {
184 scope_guard scope(mContext);
185 if (mParent.root().usable()) {
186 var builder = mContext->instance->parse_expr(mParent.root());
187 if (builder.is_type_of<type_t>()) {
188 const auto &t = builder.const_val<type_t>();
189 if (mTypeId == t.id)
190 throw runtime_error("Can not inherit itself.");
191 var parent = t.constructor();
192 if (parent.is_type_of<structure>()) {
193 parent.mark_protect();
194 mContext->instance->storage.involve_domain(parent.const_val<structure>().get_domain());
195 mContext->instance->storage.add_var_no_return("parent", parent, true);
196 }
197 else
198 throw runtime_error("Target is not a struct.");
199 }
200 else
201 throw runtime_error("Target is not a type.");
202 }
203 for (auto &ptr : this->mMethod) {
204 try {
205 ptr->run();
206 }
207 catch (const cs::exception &e) {
208 throw e;
209 }
210 catch (const std::exception &e) {
211 throw exception(ptr->get_line_num(), ptr->get_file_path(), ptr->get_raw_code(), e.what());
212 }
213 }
214 return var::make<structure>(this->mTypeId, this->mName, scope.get());
215 }
216
217 void statement_expression::run_impl()
218 {

Callers

nothing calls this directly

Calls 12

runtime_errorClass · 0.85
parse_exprMethod · 0.80
mark_protectMethod · 0.80
involve_domainMethod · 0.80
add_var_no_returnMethod · 0.80
exceptionFunction · 0.70
usableMethod · 0.45
rootMethod · 0.45
runMethod · 0.45
get_line_numMethod · 0.45
whatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected