2005-11-02 07:42:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-11-02 07:36:37 +00:00
|
|
|
|
2005-11-02 17:34:14 +00:00
|
|
|
#include "txExpr.h"
|
2005-11-02 07:40:48 +00:00
|
|
|
#include "txIXPathContext.h"
|
2005-11-02 07:36:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Evaluates this Expr based on the given context node and processor state
|
|
|
|
* @param context the context node for evaluation of this Expr
|
|
|
|
* @param ps the ContextState containing the stack information needed
|
|
|
|
* for evaluation.
|
|
|
|
* @return the result of the evaluation.
|
|
|
|
*/
|
2005-11-02 07:40:48 +00:00
|
|
|
nsresult
|
|
|
|
UnaryExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
|
2005-11-02 07:36:37 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*aResult = nullptr;
|
2005-11-02 07:40:48 +00:00
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<txAExprResult> exprRes;
|
2005-11-02 07:40:48 +00:00
|
|
|
nsresult rv = expr->evaluate(aContext, getter_AddRefs(exprRes));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2005-11-02 07:36:37 +00:00
|
|
|
double value = exprRes->numberValue();
|
2005-11-02 07:36:58 +00:00
|
|
|
#ifdef HPUX
|
|
|
|
/*
|
|
|
|
* Negation of a zero doesn't produce a negative
|
|
|
|
* zero on HPUX. Perform the operation by multiplying with
|
|
|
|
* -1.
|
|
|
|
*/
|
2005-11-02 07:40:48 +00:00
|
|
|
return aContext->recycler()->getNumberResult(-1 * value, aResult);
|
2005-11-02 07:36:58 +00:00
|
|
|
#else
|
2005-11-02 07:40:48 +00:00
|
|
|
return aContext->recycler()->getNumberResult(-value, aResult);
|
2005-11-02 07:36:58 +00:00
|
|
|
#endif
|
2005-11-02 07:36:37 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 01:50:30 +00:00
|
|
|
TX_IMPL_EXPR_STUBS_1(UnaryExpr, NODESET_RESULT, expr)
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2006-01-26 01:50:30 +00:00
|
|
|
UnaryExpr::isSensitiveTo(ContextSensitivity aContext)
|
|
|
|
{
|
|
|
|
return expr->isSensitiveTo(aContext);
|
|
|
|
}
|
|
|
|
|
2005-11-02 07:42:10 +00:00
|
|
|
#ifdef TX_TO_STRING
|
|
|
|
void
|
|
|
|
UnaryExpr::toString(nsAString& str)
|
2005-11-02 07:36:37 +00:00
|
|
|
{
|
|
|
|
if (!expr)
|
|
|
|
return;
|
2014-01-04 15:02:17 +00:00
|
|
|
str.Append(char16_t('-'));
|
2005-11-02 07:36:37 +00:00
|
|
|
expr->toString(str);
|
|
|
|
}
|
2005-11-02 07:42:10 +00:00
|
|
|
#endif
|