| 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 | { |
nothing calls this directly
no test coverage detected