| 294 | } |
| 295 | |
| 296 | static value try_builtin_func(context & ctx, const std::string & name, value & input, bool undef_on_missing = false) { |
| 297 | JJ_DEBUG("Trying built-in function '%s' for type %s", name.c_str(), input->type().c_str()); |
| 298 | if (ctx.is_get_stats) { |
| 299 | value_t::stats_t::mark_used(input); |
| 300 | input->stats.ops.insert(name); |
| 301 | } |
| 302 | auto builtins = input->get_builtins(); |
| 303 | auto it = builtins.find(name); |
| 304 | if (it != builtins.end()) { |
| 305 | JJ_DEBUG("Binding built-in '%s'", name.c_str()); |
| 306 | return mk_val<value_func>(name, it->second, input); |
| 307 | } |
| 308 | if (undef_on_missing) { |
| 309 | return mk_val<value_undefined>(name); |
| 310 | } |
| 311 | throw std::runtime_error("Unknown (built-in) filter '" + name + "' for type " + input->type()); |
| 312 | } |
| 313 | |
| 314 | value filter_expression::execute_impl(context & ctx) { |
| 315 | value input = operand ? operand->execute(ctx) : val; |
no test coverage detected