Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / xslt / xpath / txVariableRefExpr.cpp
blob48369131355123f6e8a7c05439445fae6686ddae
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 #include "txExpr.h"
7 #include "nsAtom.h"
8 #include "txNodeSet.h"
9 #include "nsGkAtoms.h"
10 #include "txIXPathContext.h"
12 //-------------------/
13 //- VariableRefExpr -/
14 //-------------------/
16 /**
17 * Creates a VariableRefExpr with the given variable name
18 **/
19 VariableRefExpr::VariableRefExpr(nsAtom* aPrefix, nsAtom* aLocalName,
20 int32_t aNSID)
21 : mPrefix(aPrefix), mLocalName(aLocalName), mNamespace(aNSID) {
22 NS_ASSERTION(mLocalName, "VariableRefExpr without local name?");
23 if (mPrefix == nsGkAtoms::_empty) mPrefix = nullptr;
26 /**
27 * Evaluates this Expr based on the given context node and processor state
28 * @param context the context node for evaluation of this Expr
29 * @param ps the ContextState containing the stack information needed
30 * for evaluation
31 * @return the result of the evaluation
32 **/
33 nsresult VariableRefExpr::evaluate(txIEvalContext* aContext,
34 txAExprResult** aResult) {
35 nsresult rv = aContext->getVariable(mNamespace, mLocalName, *aResult);
36 if (NS_FAILED(rv)) {
37 // XXX report error, undefined variable
38 return rv;
40 return NS_OK;
43 TX_IMPL_EXPR_STUBS_0(VariableRefExpr, ANY_RESULT)
45 bool VariableRefExpr::isSensitiveTo(ContextSensitivity aContext) {
46 return !!(aContext & VARIABLES_CONTEXT);
49 #ifdef TX_TO_STRING
50 void VariableRefExpr::toString(nsAString& aDest) {
51 aDest.Append(char16_t('$'));
52 if (mPrefix) {
53 nsAutoString prefix;
54 mPrefix->ToString(prefix);
55 aDest.Append(prefix);
56 aDest.Append(char16_t(':'));
58 nsAutoString lname;
59 mLocalName->ToString(lname);
60 aDest.Append(lname);
62 #endif