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 #ifndef TRANSFRMX_TXINSTRUCTIONS_H
7 #define TRANSFRMX_TXINSTRUCTIONS_H
9 #include "mozilla/UniquePtr.h"
13 #include "txXMLUtils.h"
14 #include "txExpandedName.h"
15 #include "txNamespaceMap.h"
16 #include "txXSLTNumber.h"
20 class txExecutionState
;
22 class txInstruction
: public txObject
{
24 MOZ_COUNTED_DEFAULT_CTOR(txInstruction
)
26 ~txInstruction() override
{
27 MOZ_COUNT_DTOR(txInstruction
);
29 mozilla::UniquePtr
<txInstruction
> next(std::move(mNext
));
31 mozilla::UniquePtr
<txInstruction
> destroy(std::move(next
));
32 next
= std::move(destroy
->mNext
);
36 virtual nsresult
execute(txExecutionState
& aEs
) = 0;
38 mozilla::UniquePtr
<txInstruction
> mNext
;
41 #define TX_DECL_TXINSTRUCTION \
42 virtual nsresult execute(txExecutionState& aEs) override;
44 class txApplyDefaultElementTemplate
: public txInstruction
{
49 class txApplyImportsEnd
: public txInstruction
{
54 class txApplyImportsStart
: public txInstruction
{
59 class txApplyTemplates
: public txInstruction
{
61 explicit txApplyTemplates(const txExpandedName
& aMode
);
68 class txAttribute
: public txInstruction
{
70 txAttribute(mozilla::UniquePtr
<Expr
>&& aName
,
71 mozilla::UniquePtr
<Expr
>&& aNamespace
, txNamespaceMap
* aMappings
);
75 mozilla::UniquePtr
<Expr
> mName
;
76 mozilla::UniquePtr
<Expr
> mNamespace
;
77 RefPtr
<txNamespaceMap
> mMappings
;
80 class txCallTemplate
: public txInstruction
{
82 explicit txCallTemplate(const txExpandedName
& aName
);
89 class txCheckParam
: public txInstruction
{
91 explicit txCheckParam(const txExpandedName
& aName
);
96 txInstruction
* mBailTarget
;
99 class txConditionalGoto
: public txInstruction
{
101 txConditionalGoto(mozilla::UniquePtr
<Expr
>&& aCondition
,
102 txInstruction
* aTarget
);
104 TX_DECL_TXINSTRUCTION
106 mozilla::UniquePtr
<Expr
> mCondition
;
107 txInstruction
* mTarget
;
110 class txComment
: public txInstruction
{
112 TX_DECL_TXINSTRUCTION
115 class txCopyBase
: public txInstruction
{
117 nsresult
copyNode(const txXPathNode
& aNode
, txExecutionState
& aEs
);
120 class txCopy
: public txCopyBase
{
124 TX_DECL_TXINSTRUCTION
126 txInstruction
* mBailTarget
;
129 class txCopyOf
: public txCopyBase
{
131 explicit txCopyOf(mozilla::UniquePtr
<Expr
>&& aSelect
);
133 TX_DECL_TXINSTRUCTION
135 mozilla::UniquePtr
<Expr
> mSelect
;
138 class txEndElement
: public txInstruction
{
140 TX_DECL_TXINSTRUCTION
143 class txErrorInstruction
: public txInstruction
{
145 TX_DECL_TXINSTRUCTION
148 class txGoTo
: public txInstruction
{
150 explicit txGoTo(txInstruction
* aTarget
);
152 TX_DECL_TXINSTRUCTION
154 txInstruction
* mTarget
;
157 class txInsertAttrSet
: public txInstruction
{
159 explicit txInsertAttrSet(const txExpandedName
& aName
);
161 TX_DECL_TXINSTRUCTION
163 txExpandedName mName
;
166 class txLoopNodeSet
: public txInstruction
{
168 explicit txLoopNodeSet(txInstruction
* aTarget
);
170 TX_DECL_TXINSTRUCTION
172 txInstruction
* mTarget
;
175 class txLREAttribute
: public txInstruction
{
177 txLREAttribute(int32_t aNamespaceID
, nsAtom
* aLocalName
, nsAtom
* aPrefix
,
178 mozilla::UniquePtr
<Expr
>&& aValue
);
180 TX_DECL_TXINSTRUCTION
182 int32_t mNamespaceID
;
183 RefPtr
<nsAtom
> mLocalName
;
184 RefPtr
<nsAtom
> mLowercaseLocalName
;
185 RefPtr
<nsAtom
> mPrefix
;
186 mozilla::UniquePtr
<Expr
> mValue
;
189 class txMessage
: public txInstruction
{
191 explicit txMessage(bool aTerminate
);
193 TX_DECL_TXINSTRUCTION
198 class txNumber
: public txInstruction
{
200 txNumber(txXSLTNumber::LevelType aLevel
,
201 mozilla::UniquePtr
<txPattern
>&& aCount
,
202 mozilla::UniquePtr
<txPattern
>&& aFrom
,
203 mozilla::UniquePtr
<Expr
>&& aValue
,
204 mozilla::UniquePtr
<Expr
>&& aFormat
,
205 mozilla::UniquePtr
<Expr
>&& aGroupingSeparator
,
206 mozilla::UniquePtr
<Expr
>&& aGroupingSize
);
208 TX_DECL_TXINSTRUCTION
210 txXSLTNumber::LevelType mLevel
;
211 mozilla::UniquePtr
<txPattern
> mCount
;
212 mozilla::UniquePtr
<txPattern
> mFrom
;
213 mozilla::UniquePtr
<Expr
> mValue
;
214 mozilla::UniquePtr
<Expr
> mFormat
;
215 mozilla::UniquePtr
<Expr
> mGroupingSeparator
;
216 mozilla::UniquePtr
<Expr
> mGroupingSize
;
219 class txPopParams
: public txInstruction
{
221 TX_DECL_TXINSTRUCTION
224 class txProcessingInstruction
: public txInstruction
{
226 explicit txProcessingInstruction(mozilla::UniquePtr
<Expr
>&& aName
);
228 TX_DECL_TXINSTRUCTION
230 mozilla::UniquePtr
<Expr
> mName
;
233 class txPushNewContext
: public txInstruction
{
235 explicit txPushNewContext(mozilla::UniquePtr
<Expr
>&& aSelect
);
238 TX_DECL_TXINSTRUCTION
240 void addSort(mozilla::UniquePtr
<Expr
>&& aSelectExpr
,
241 mozilla::UniquePtr
<Expr
>&& aLangExpr
,
242 mozilla::UniquePtr
<Expr
>&& aDataTypeExpr
,
243 mozilla::UniquePtr
<Expr
>&& aOrderExpr
,
244 mozilla::UniquePtr
<Expr
>&& aCaseOrderExpr
);
247 mozilla::UniquePtr
<Expr
> mSelectExpr
;
248 mozilla::UniquePtr
<Expr
> mLangExpr
;
249 mozilla::UniquePtr
<Expr
> mDataTypeExpr
;
250 mozilla::UniquePtr
<Expr
> mOrderExpr
;
251 mozilla::UniquePtr
<Expr
> mCaseOrderExpr
;
254 nsTArray
<SortKey
> mSortKeys
;
255 mozilla::UniquePtr
<Expr
> mSelect
;
256 txInstruction
* mBailTarget
;
259 class txPushNullTemplateRule
: public txInstruction
{
261 TX_DECL_TXINSTRUCTION
264 class txPushParams
: public txInstruction
{
266 TX_DECL_TXINSTRUCTION
269 class txPushRTFHandler
: public txInstruction
{
271 TX_DECL_TXINSTRUCTION
274 class txPushStringHandler
: public txInstruction
{
276 explicit txPushStringHandler(bool aOnlyText
);
278 TX_DECL_TXINSTRUCTION
283 class txRemoveVariable
: public txInstruction
{
285 explicit txRemoveVariable(const txExpandedName
& aName
);
287 TX_DECL_TXINSTRUCTION
289 txExpandedName mName
;
292 class txReturn
: public txInstruction
{
294 TX_DECL_TXINSTRUCTION
297 class txSetParam
: public txInstruction
{
299 txSetParam(const txExpandedName
& aName
, mozilla::UniquePtr
<Expr
>&& aValue
);
301 TX_DECL_TXINSTRUCTION
303 txExpandedName mName
;
304 mozilla::UniquePtr
<Expr
> mValue
;
307 class txSetVariable
: public txInstruction
{
309 txSetVariable(const txExpandedName
& aName
, mozilla::UniquePtr
<Expr
>&& aValue
);
311 TX_DECL_TXINSTRUCTION
313 txExpandedName mName
;
314 mozilla::UniquePtr
<Expr
> mValue
;
317 class txStartElement
: public txInstruction
{
319 txStartElement(mozilla::UniquePtr
<Expr
>&& aName
,
320 mozilla::UniquePtr
<Expr
>&& aNamespace
,
321 txNamespaceMap
* aMappings
);
323 TX_DECL_TXINSTRUCTION
325 mozilla::UniquePtr
<Expr
> mName
;
326 mozilla::UniquePtr
<Expr
> mNamespace
;
327 RefPtr
<txNamespaceMap
> mMappings
;
330 class txStartLREElement
: public txInstruction
{
332 txStartLREElement(int32_t aNamespaceID
, nsAtom
* aLocalName
, nsAtom
* aPrefix
);
334 TX_DECL_TXINSTRUCTION
336 int32_t mNamespaceID
;
337 RefPtr
<nsAtom
> mLocalName
;
338 RefPtr
<nsAtom
> mLowercaseLocalName
;
339 RefPtr
<nsAtom
> mPrefix
;
342 class txText
: public txInstruction
{
344 txText(const nsAString
& aStr
, bool aDOE
);
346 TX_DECL_TXINSTRUCTION
352 class txValueOf
: public txInstruction
{
354 txValueOf(mozilla::UniquePtr
<Expr
>&& aExpr
, bool aDOE
);
356 TX_DECL_TXINSTRUCTION
358 mozilla::UniquePtr
<Expr
> mExpr
;
362 #endif // TRANSFRMX_TXINSTRUCTIONS_H