* xmlXPathCompOpEval: * @ctxt: the XPath parser context with the compiled expression * @op: an XPath compiled operation * * Evaluate the Precompiled XPath operation * Returns the number of nodes traversed */
| 11791 | * Returns the number of nodes traversed |
| 11792 | */ |
| 11793 | static int |
| 11794 | xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) |
| 11795 | { |
| 11796 | int total = 0; |
| 11797 | int equal, ret; |
| 11798 | xmlXPathCompExprPtr comp; |
| 11799 | xmlXPathObjectPtr arg1, arg2; |
| 11800 | |
| 11801 | CHECK_ERROR0; |
| 11802 | if (OP_LIMIT_EXCEEDED(ctxt, 1)) |
| 11803 | return(0); |
| 11804 | if (ctxt->context->depth >= XPATH_MAX_RECURSION_DEPTH) |
| 11805 | XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED); |
| 11806 | ctxt->context->depth += 1; |
| 11807 | comp = ctxt->comp; |
| 11808 | switch (op->op) { |
| 11809 | case XPATH_OP_END: |
| 11810 | break; |
| 11811 | case XPATH_OP_AND: |
| 11812 | total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); |
| 11813 | CHECK_ERROR0; |
| 11814 | xmlXPathBooleanFunction(ctxt, 1); |
| 11815 | if ((ctxt->value == NULL) || (ctxt->value->boolval == 0)) |
| 11816 | break; |
| 11817 | arg2 = valuePop(ctxt); |
| 11818 | total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); |
| 11819 | if (ctxt->error) { |
| 11820 | xmlXPathFreeObject(arg2); |
| 11821 | break; |
| 11822 | } |
| 11823 | xmlXPathBooleanFunction(ctxt, 1); |
| 11824 | if (ctxt->value != NULL) |
| 11825 | ctxt->value->boolval &= arg2->boolval; |
| 11826 | xmlXPathReleaseObject(ctxt->context, arg2); |
| 11827 | break; |
| 11828 | case XPATH_OP_OR: |
| 11829 | total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); |
| 11830 | CHECK_ERROR0; |
| 11831 | xmlXPathBooleanFunction(ctxt, 1); |
| 11832 | if ((ctxt->value == NULL) || (ctxt->value->boolval == 1)) |
| 11833 | break; |
| 11834 | arg2 = valuePop(ctxt); |
| 11835 | total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); |
| 11836 | if (ctxt->error) { |
| 11837 | xmlXPathFreeObject(arg2); |
| 11838 | break; |
| 11839 | } |
| 11840 | xmlXPathBooleanFunction(ctxt, 1); |
| 11841 | if (ctxt->value != NULL) |
| 11842 | ctxt->value->boolval |= arg2->boolval; |
| 11843 | xmlXPathReleaseObject(ctxt->context, arg2); |
| 11844 | break; |
| 11845 | case XPATH_OP_EQUAL: |
| 11846 | total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]); |
| 11847 | CHECK_ERROR0; |
| 11848 | total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]); |
| 11849 | CHECK_ERROR0; |
| 11850 | if (op->value) |
no test coverage detected