MCPcopy Create free account
hub / github.com/WheretIB/nullc / eval_number

Method eval_number

external/pugixml/pugixml.cpp:7532–7667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 }

Callers 5

compare_eqMethod · 0.80
compare_relMethod · 0.80
apply_predicateMethod · 0.80
eval_stringMethod · 0.80
evaluate_numberMethod · 0.80

Calls 15

string_valueFunction · 0.85
convert_string_to_numberFunction · 0.85
floorFunction · 0.85
ceilFunction · 0.85
round_nearest_nzeroFunction · 0.85
assertFunction · 0.85
eval_node_setMethod · 0.80
lengthMethod · 0.80
eval_stringMethod · 0.80
c_strMethod · 0.80
get_numberMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected