| 294 | } |
| 295 | |
| 296 | void |
| 297 | instance_type::parse_define_structured_binding(tree_type<token_base *>::iterator it, bool constant, bool link) |
| 298 | { |
| 299 | std::function<void(tree_type<token_base *>::iterator, const var &)> process; |
| 300 | process = [&process, this, constant, link](tree_type<token_base *>::iterator it, const var &val) { |
| 301 | auto &pl = static_cast<token_parallel *>(it.data())->get_parallel(); |
| 302 | if (!val.is_type_of<array>()) |
| 303 | throw runtime_error("Only support structured binding with array while variable definition."); |
| 304 | auto &arr = val.const_val<array>(); |
| 305 | if (pl.size() != arr.size()) |
| 306 | throw runtime_error("Unmatched structured binding while variable definition."); |
| 307 | for (std::size_t i = 0; i < pl.size(); ++i) { |
| 308 | if (pl[i].root().data()->get_type() == token_types::parallel) |
| 309 | process(pl[i].root(), arr[i]); |
| 310 | else |
| 311 | storage.add_var_no_return(static_cast<token_id *>(pl[i].root().data())->get_id(), |
| 312 | constant || link ? arr[i] : copy(arr[i]), constant); |
| 313 | } |
| 314 | }; |
| 315 | const var &val = constant ? static_cast<token_value *>(it.right().data())->get_value() : parse_expr(it.right()); |
| 316 | process(it.left(), val); |
| 317 | } |
| 318 | |
| 319 | void instance_type::parse_using(tree_type<token_base *>::iterator it, bool override) |
| 320 | { |
nothing calls this directly
no test coverage detected