| 275 | } |
| 276 | |
| 277 | static value try_builtin_func(context & ctx, const std::string & name, value & input, bool undef_on_missing = false) { |
| 278 | JJ_DEBUG("Trying built-in function '%s' for type %s", name.c_str(), input->type().c_str()); |
| 279 | if (ctx.is_get_stats) { |
| 280 | input->stats.used = true; |
| 281 | input->stats.ops.insert(name); |
| 282 | } |
| 283 | auto builtins = input->get_builtins(); |
| 284 | auto it = builtins.find(name); |
| 285 | if (it != builtins.end()) { |
| 286 | JJ_DEBUG("Binding built-in '%s'", name.c_str()); |
| 287 | return mk_val<value_func>(name, it->second, input); |
| 288 | } |
| 289 | if (undef_on_missing) { |
| 290 | return mk_val<value_undefined>(name); |
| 291 | } |
| 292 | throw std::runtime_error("Unknown (built-in) filter '" + name + "' for type " + input->type()); |
| 293 | } |
| 294 | |
| 295 | value filter_expression::execute_impl(context & ctx) { |
| 296 | value input = operand ? operand->execute(ctx) : val; |
no test coverage detected