| 9789 | } |
| 9790 | |
| 9791 | xpath_node_set_raw eval_node_set(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval) |
| 9792 | { |
| 9793 | switch (_type) |
| 9794 | { |
| 9795 | case ast_op_union: |
| 9796 | { |
| 9797 | xpath_allocator_capture cr(stack.temp); |
| 9798 | |
| 9799 | xpath_stack swapped_stack = {stack.temp, stack.result}; |
| 9800 | |
| 9801 | xpath_node_set_raw ls = _left->eval_node_set(c, swapped_stack, eval); |
| 9802 | xpath_node_set_raw rs = _right->eval_node_set(c, stack, eval); |
| 9803 | |
| 9804 | // we can optimize merging two sorted sets, but this is a very rare operation, so don't bother |
| 9805 | rs.set_type(xpath_node_set::type_unsorted); |
| 9806 | |
| 9807 | rs.append(ls.begin(), ls.end(), stack.result); |
| 9808 | rs.remove_duplicates(); |
| 9809 | |
| 9810 | return rs; |
| 9811 | } |
| 9812 | |
| 9813 | case ast_filter: |
| 9814 | { |
| 9815 | xpath_node_set_raw set = _left->eval_node_set(c, stack, _test == predicate_constant_one ? nodeset_eval_first : nodeset_eval_all); |
| 9816 | |
| 9817 | // either expression is a number or it contains position() call; sort by document order |
| 9818 | if (_test != predicate_posinv) set.sort_do(); |
| 9819 | |
| 9820 | bool once = eval_once(set.type(), eval); |
| 9821 | |
| 9822 | apply_predicate(set, 0, stack, once); |
| 9823 | |
| 9824 | return set; |
| 9825 | } |
| 9826 | |
| 9827 | case ast_func_id: |
| 9828 | return xpath_node_set_raw(); |
| 9829 | |
| 9830 | case ast_step: |
| 9831 | { |
| 9832 | switch (_axis) |
| 9833 | { |
| 9834 | case axis_ancestor: |
| 9835 | return step_do(c, stack, eval, axis_to_type<axis_ancestor>()); |
| 9836 | |
| 9837 | case axis_ancestor_or_self: |
| 9838 | return step_do(c, stack, eval, axis_to_type<axis_ancestor_or_self>()); |
| 9839 | |
| 9840 | case axis_attribute: |
| 9841 | return step_do(c, stack, eval, axis_to_type<axis_attribute>()); |
| 9842 | |
| 9843 | case axis_child: |
| 9844 | return step_do(c, stack, eval, axis_to_type<axis_child>()); |
| 9845 | |
| 9846 | case axis_descendant: |
| 9847 | return step_do(c, stack, eval, axis_to_type<axis_descendant>()); |
| 9848 |
no test coverage detected