michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "txExpr.h" michael@0: #include "txIXPathContext.h" michael@0: michael@0: /* michael@0: * Evaluates this Expr based on the given context node and processor state michael@0: * @param context the context node for evaluation of this Expr michael@0: * @param ps the ContextState containing the stack information needed michael@0: * for evaluation. michael@0: * @return the result of the evaluation. michael@0: */ michael@0: nsresult michael@0: UnaryExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult) michael@0: { michael@0: *aResult = nullptr; michael@0: michael@0: nsRefPtr exprRes; michael@0: nsresult rv = expr->evaluate(aContext, getter_AddRefs(exprRes)); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: double value = exprRes->numberValue(); michael@0: #ifdef HPUX michael@0: /* michael@0: * Negation of a zero doesn't produce a negative michael@0: * zero on HPUX. Perform the operation by multiplying with michael@0: * -1. michael@0: */ michael@0: return aContext->recycler()->getNumberResult(-1 * value, aResult); michael@0: #else michael@0: return aContext->recycler()->getNumberResult(-value, aResult); michael@0: #endif michael@0: } michael@0: michael@0: TX_IMPL_EXPR_STUBS_1(UnaryExpr, NODESET_RESULT, expr) michael@0: michael@0: bool michael@0: UnaryExpr::isSensitiveTo(ContextSensitivity aContext) michael@0: { michael@0: return expr->isSensitiveTo(aContext); michael@0: } michael@0: michael@0: #ifdef TX_TO_STRING michael@0: void michael@0: UnaryExpr::toString(nsAString& str) michael@0: { michael@0: if (!expr) michael@0: return; michael@0: str.Append(char16_t('-')); michael@0: expr->toString(str); michael@0: } michael@0: #endif