Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "txExpr.h"
7 : #include "txIXPathContext.h"
8 :
9 : /*
10 : * Evaluates this Expr based on the given context node and processor state
11 : * @param context the context node for evaluation of this Expr
12 : * @param ps the ContextState containing the stack information needed
13 : * for evaluation.
14 : * @return the result of the evaluation.
15 : */
16 : nsresult
17 0 : UnaryExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
18 : {
19 0 : *aResult = nullptr;
20 :
21 0 : RefPtr<txAExprResult> exprRes;
22 0 : nsresult rv = expr->evaluate(aContext, getter_AddRefs(exprRes));
23 0 : NS_ENSURE_SUCCESS(rv, rv);
24 :
25 0 : double value = exprRes->numberValue();
26 : #ifdef HPUX
27 : /*
28 : * Negation of a zero doesn't produce a negative
29 : * zero on HPUX. Perform the operation by multiplying with
30 : * -1.
31 : */
32 : return aContext->recycler()->getNumberResult(-1 * value, aResult);
33 : #else
34 0 : return aContext->recycler()->getNumberResult(-value, aResult);
35 : #endif
36 : }
37 :
38 0 : TX_IMPL_EXPR_STUBS_1(UnaryExpr, NODESET_RESULT, expr)
39 :
40 : bool
41 0 : UnaryExpr::isSensitiveTo(ContextSensitivity aContext)
42 : {
43 0 : return expr->isSensitiveTo(aContext);
44 : }
45 :
46 : #ifdef TX_TO_STRING
47 : void
48 0 : UnaryExpr::toString(nsAString& str)
49 : {
50 0 : if (!expr)
51 0 : return;
52 0 : str.Append(char16_t('-'));
53 0 : expr->toString(str);
54 : }
55 : #endif
|