| 7530 | } |
| 7531 | |
| 7532 | double eval_number(const xpath_context& c, const xpath_stack& stack) |
| 7533 | { |
| 7534 | switch (_type) |
| 7535 | { |
| 7536 | case ast_op_add: |
| 7537 | return _left->eval_number(c, stack) + _right->eval_number(c, stack); |
| 7538 | |
| 7539 | case ast_op_subtract: |
| 7540 | return _left->eval_number(c, stack) - _right->eval_number(c, stack); |
| 7541 | |
| 7542 | case ast_op_multiply: |
| 7543 | return _left->eval_number(c, stack) * _right->eval_number(c, stack); |
| 7544 | |
| 7545 | case ast_op_divide: |
| 7546 | return _left->eval_number(c, stack) / _right->eval_number(c, stack); |
| 7547 | |
| 7548 | case ast_op_mod: |
| 7549 | return fmod(_left->eval_number(c, stack), _right->eval_number(c, stack)); |
| 7550 | |
| 7551 | case ast_op_negate: |
| 7552 | return -_left->eval_number(c, stack); |
| 7553 | |
| 7554 | case ast_number_constant: |
| 7555 | return _data.number; |
| 7556 | |
| 7557 | case ast_func_last: |
| 7558 | return (double)c.size; |
| 7559 | |
| 7560 | case ast_func_position: |
| 7561 | return (double)c.position; |
| 7562 | |
| 7563 | case ast_func_count: |
| 7564 | { |
| 7565 | xpath_allocator_capture cr(stack.result); |
| 7566 | |
| 7567 | return (double)_left->eval_node_set(c, stack).size(); |
| 7568 | } |
| 7569 | |
| 7570 | case ast_func_string_length_0: |
| 7571 | { |
| 7572 | xpath_allocator_capture cr(stack.result); |
| 7573 | |
| 7574 | return (double)string_value(c.n, stack.result).length(); |
| 7575 | } |
| 7576 | |
| 7577 | case ast_func_string_length_1: |
| 7578 | { |
| 7579 | xpath_allocator_capture cr(stack.result); |
| 7580 | |
| 7581 | return (double)_left->eval_string(c, stack).length(); |
| 7582 | } |
| 7583 | |
| 7584 | case ast_func_number_0: |
| 7585 | { |
| 7586 | xpath_allocator_capture cr(stack.result); |
| 7587 | |
| 7588 | return convert_string_to_number(string_value(c.n, stack.result).c_str()); |
| 7589 | } |
no test coverage detected