Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / xslt / xpath / txNumberResult.cpp
blob370a7523d8e76e06b2faa2095c17f4d81d4a4808
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 /**
7 * NumberResult
8 * Represents the a number as the result of evaluating an Expr
9 **/
11 #include "mozilla/FloatingPoint.h"
13 #include "txExprResult.h"
15 /**
16 * Default Constructor
17 **/
19 /**
20 * Creates a new NumberResult with the value of the given double parameter
21 * @param dbl the double to use for initialization of this NumberResult's value
22 **/
23 NumberResult::NumberResult(double aValue, txResultRecycler* aRecycler)
24 : txAExprResult(aRecycler), value(aValue) {} //-- NumberResult
27 * Virtual Methods from ExprResult
30 short NumberResult::getResultType() {
31 return txAExprResult::NUMBER;
32 } //-- getResultType
34 void NumberResult::stringValue(nsString& aResult) {
35 txDouble::toString(value, aResult);
38 const nsString* NumberResult::stringValuePointer() { return nullptr; }
40 bool NumberResult::booleanValue() {
41 // OG+
42 // As per the XPath spec, the boolean value of a number is true if and only if
43 // it is neither positive 0 nor negative 0 nor NaN
44 return (bool)(value != 0.0 && !std::isnan(value));
45 // OG-
46 } //-- booleanValue
48 double NumberResult::numberValue() { return this->value; } //-- numberValue