1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/xslt/xpath/txUnaryExpr.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "txExpr.h" 1.10 +#include "txIXPathContext.h" 1.11 + 1.12 +/* 1.13 + * Evaluates this Expr based on the given context node and processor state 1.14 + * @param context the context node for evaluation of this Expr 1.15 + * @param ps the ContextState containing the stack information needed 1.16 + * for evaluation. 1.17 + * @return the result of the evaluation. 1.18 + */ 1.19 +nsresult 1.20 +UnaryExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult) 1.21 +{ 1.22 + *aResult = nullptr; 1.23 + 1.24 + nsRefPtr<txAExprResult> exprRes; 1.25 + nsresult rv = expr->evaluate(aContext, getter_AddRefs(exprRes)); 1.26 + NS_ENSURE_SUCCESS(rv, rv); 1.27 + 1.28 + double value = exprRes->numberValue(); 1.29 +#ifdef HPUX 1.30 + /* 1.31 + * Negation of a zero doesn't produce a negative 1.32 + * zero on HPUX. Perform the operation by multiplying with 1.33 + * -1. 1.34 + */ 1.35 + return aContext->recycler()->getNumberResult(-1 * value, aResult); 1.36 +#else 1.37 + return aContext->recycler()->getNumberResult(-value, aResult); 1.38 +#endif 1.39 +} 1.40 + 1.41 +TX_IMPL_EXPR_STUBS_1(UnaryExpr, NODESET_RESULT, expr) 1.42 + 1.43 +bool 1.44 +UnaryExpr::isSensitiveTo(ContextSensitivity aContext) 1.45 +{ 1.46 + return expr->isSensitiveTo(aContext); 1.47 +} 1.48 + 1.49 +#ifdef TX_TO_STRING 1.50 +void 1.51 +UnaryExpr::toString(nsAString& str) 1.52 +{ 1.53 + if (!expr) 1.54 + return; 1.55 + str.Append(char16_t('-')); 1.56 + expr->toString(str); 1.57 +} 1.58 +#endif