This file is indexed.

/usr/include/xalanc/XSLT/VariablesStack.hpp is in libxalan-c-dev 1.11-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the  "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD)
#define XALAN_VARIABLESSTACK_HEADER_GUARD



// Base include file.  Must be first.
#include <xalanc/XSLT/XSLTDefinitions.hpp>



#include <cassert>



#include <xalanc/Include/XalanVector.hpp>



#include <xalanc/XPath/XalanQName.hpp>
#include <xalanc/XPath/XObject.hpp>



#include <xalanc/XSLT/XSLTProcessorException.hpp>



XALAN_CPP_NAMESPACE_BEGIN



class Arg;
class ElemTemplateElement;
class ElemVariable;
class StylesheetExecutionContext;
class XalanNode;



/**
 * Defines a class to keep track of a stack for macro arguments.
 */
class XALAN_XSLT_EXPORT VariablesStack
{
public:

    typedef unsigned long   size_type;

    /**
     * Constructor for a variable stack.
     */
    explicit
    VariablesStack(MemoryManager& theManager);

    ~VariablesStack();

    /**
     * Reset the stack.
     */
    void
    reset();

    /**
     * Push a frame marker for an element.
     *
     * @param elem the element
     */
    void
    pushElementFrame(const ElemTemplateElement*     elem);

    /**
     * Pop a frame marker for an element.
     *
     * @param elem the element
     */
    void
    popElementFrame();

    /**
     * Push a context marker onto the stack to let us know when to stop
     * searching for a var.
     *
     * @param caller     caller node
     * @param sourceNode source node
     */
    void
    pushContextMarker();

    /**
     * Pop the current context from the current context stack.
     */
    void
    popContextMarker();

    struct ParamsVectorEntry
    {
        ParamsVectorEntry() :
            m_qname(0),
            m_value(),
            m_variable(0)
        {
        }

        ParamsVectorEntry(
                const XalanQName*   qname,
                const XObjectPtr    value) :
            m_qname(qname),
            m_value(value),
            m_variable(0)
        {
        }

        ParamsVectorEntry(
                const XalanQName*       qname,
                const ElemVariable*     variable) :
            m_qname(qname),
            m_value(),
            m_variable(variable)
        {
        }

        const XalanQName*       m_qname;

        XObjectPtr              m_value;

        const ElemVariable*     m_variable;
    };

    typedef XalanVector<ParamsVectorEntry>          ParamsVectorType;
    typedef XalanVector<const ElemVariable*>            RecursionGuardStackType;
    typedef XalanVector<const ElemTemplateElement*> ElemTemplateElementStackType;

    /**
     * Push the provided objects as parameters.  You must call
     * popContextMarker() when you are done with the arguments.
     *
     * @param theParam The vector containing the parameters.
     */
    void
    pushParams(const ParamsVectorType&  theParams);

    /**
     * Given a name, return a string representing the value, but don't look
     * in the global space.  Since the variable may not yet have been
     * evaluated, this may return a null XObjectPtr.
     *
     * @param theName name of variable
     * @param exeuctionContext the current execution context
     * @param fNameFound set to true if the name was found, false if not.
     * @return pointer to XObject for variable
     */
    const XObjectPtr
    getParamVariable(
            const XalanQName&               qname,
            StylesheetExecutionContext&     executionContext,
            bool&                           fNameFound)
    {
        return findXObject(qname, executionContext, true, false, fNameFound);
    }

    /**
     * Given a name, find the corresponding XObject.  If the variable
     * exists, but has not yet been evaluated, the variable will be
     * evaluated and the result returned.  This may return a null XObjectPtr,
     * if the variable was not found.
     *
     * @param qname name of variable
     * @param exeuctionContext the current execution context
     * @param fNameFound set to true if the name was found, false if not.
     * @return pointer to the corresponding XObject
     */
    const XObjectPtr
    getVariable(
            const XalanQName&               qname,
            StylesheetExecutionContext&     executionContext,
            bool&                           fNameFound)
    {
        return findXObject(qname, executionContext, false, true, fNameFound);
    }

    /**
     * Push a named variable onto the processor variable stack. Don't forget
     * to call startContext before pushing a series of arguments for a given
     * template.
     *
     * @param name    name of variable
     * @param val     pointer to ElemVariable
     * @param e       element marker for variable
     */
    void
    pushVariable(
            const XalanQName&           name,
            const ElemVariable*         var,
            const ElemTemplateElement*  e);

    /**
     * Push a named variable onto the processor variable stack. Don't forget
     * to call startContext before pushing a series of arguments for a given
     * template.
     *
     * @param name    name of variable
     * @param val     pointer to XObject value
     * @param e       element marker for variable
     */
    void
    pushVariable(
            const XalanQName&           name,
            const XObjectPtr&           val,
            const ElemTemplateElement*  e);

    /**
     * Mark the top of the stack.
     */
    void
    start();

    /**
     * Reset all params in the current stack frame.
     */
    void
    resetParams();

    /**
     * Mark the top of the global stack frame.
     */
    void
    markGlobalStackFrame();

    /**
     * Clear the marking of the global stack frame.
     */
    void
    unmarkGlobalStackFrame();

    /**
     * Set the top of the stack frame from where a search for a variable or
     * param should take place.  Calling with no parameter will cause the
     * index to be set to the size of the stack.
     *
     * @param currentStackFrameIndex new value of index
     */
    void
    setCurrentStackFrameIndex(size_type     currentStackFrameIndex = ~0u)
    {
        if (currentStackFrameIndex == ~0u)
        {
            assert(size_type(m_stack.size()) == m_stack.size());

            m_currentStackFrameIndex = size_type(m_stack.size());
        }
        else
        {
            m_currentStackFrameIndex = currentStackFrameIndex;
        }
    }

    /**
     * Get the top of the stack frame from where a search 
     * for a variable or param should take place.
     *
     * @return current value of index
     */
    size_type
    getCurrentStackFrameIndex() const
    {
        return m_currentStackFrameIndex;
    }

    /**
     * Get the top of the global stack frame.
     *
     * @return current value of index
     */
    size_type
    getGlobalStackFrameIndex() const
    {
        return m_globalStackFrameIndex;
    }

    class InvalidStackContextException : public XSLTProcessorException
    {
    public:

        InvalidStackContextException(XalanDOMString& theResult);

        virtual
        ~InvalidStackContextException();


        virtual const XalanDOMChar*
            getType() const
        {
            return m_type;
        }
        
    private:
        
        static const XalanDOMChar   m_type[];

    };

    class PushParamFunctor
    {
    public:

        PushParamFunctor(VariablesStack&    theVariablesStack) :
            m_variablesStack(theVariablesStack)
        {
        }

        void
        operator()(const ParamsVectorType::value_type&  theEntry) const;

    private:

        VariablesStack&     m_variablesStack;
    };

    class XALAN_XSLT_EXPORT StackEntry
    {
    public:

        /**
         * Enumeration for types of stack entries, one of context state, context
         * marker, element marker, or argument.
         */
        enum eType { eContextMarker,
                    eVariable,
                    eParam,
                    eActiveParam,
                    eElementFrameMarker,
                    eNextValue };

        /**
         * Construct a context marker.
         */
        explicit
        StackEntry();

        /**
         * Construct a variable that is already evaluated.
         */
        StackEntry(
            const XalanQName*   name,
            const XObjectPtr&   val,
            bool                isParam = false);

        /**
         * Construct a variable that has not been evaluated yet.
         */
        StackEntry(
            const XalanQName*       name,
            const ElemVariable*     var,
            bool                    isParam = false);

        /**
         * Construct an element frame marker.
         */
        StackEntry(const ElemTemplateElement*   elem);


        /**
         * Copy constructor...
         */
        StackEntry(const StackEntry&    theSource);

        /**
         * Destructor...
         */
        ~StackEntry();

        /**
         * Determine type of stack entry
         * 
         * @return enumeration value for type
         */
        eType
        getType() const
        {
            return m_type;
        }

        /**
         * Retrieve object name.  Valid only for variables
         * 
         * @return qualified name of object
         */
        const XalanQName*
        getName() const
        {
            return m_qname;
        }

        /**
         * Retrieve object's XObject pointer.  Valid only for variables
         * 
         * @return pointer to XObject
         */
        const XObjectPtr&
        getValue() const
        {
            return m_value;
        }

        /**
         * Retrieve object's XObject pointer.  Valid only for variables
         * 
         * @return pointer to XObject
         */
        void
        setValue(const XObjectPtr&  theValue)
        {
            m_value = theValue;
        }

        /**
         * Retrieve object's XObject pointer.  Valid only for variables
         * 
         * @return pointer to XObject
         */
        const ElemVariable*
        getVariable() const
        {
            return m_variable;
        }

        void
        activate();

        void
        deactivate();

        /**
         * Retrieve the ElemTemplateElem where frame begins.  Valid only for element frame markers
         *
         * @return ElemTemplateElement corresponding to marker
         */
        const ElemTemplateElement*
        getElement() const
        {
            return m_element;
        }

        StackEntry&
        operator=(const StackEntry&     theRHS);

        bool
        operator==(const StackEntry&    theRHS) const;

    private:

        // Data members...
        eType                       m_type;

        const XalanQName*           m_qname;

        XObjectPtr                  m_value;

        const ElemVariable*         m_variable;

        const ElemTemplateElement*  m_element;
    };

    typedef XalanVector<StackEntry>         VariableStackStackType;

    size_type
    getStackSize() const
    {
        return size_type(m_stack.size());
    }

    enum { eDefaultStackSize = 100 };

private:

    class CommitPushParams
    {
    public:

        CommitPushParams(VariablesStack&    theVariablesStack);

        ~CommitPushParams();

        void
        commit()
        {
            m_variablesStack = 0;
        }

    private:

        VariablesStack*     m_variablesStack;

        size_type           m_stackSize;
    };

    friend class CommitPushParams;

    /**
     * Check to see if an element frame for the particular element has already
     * been pushed.
     * 
     * @param elem element in question
     * @return true if it has been pushed already
     */
    bool
    elementFrameAlreadyPushed(const ElemTemplateElement*    elem) const;

    /**
     * Push an entry onto the stack.
     *
     * @param stack entry to push
     */
    void
    push(const StackEntry&  theEntry);

    /**
     * Pop an entry from the top of the stack.
     */
    void
    pop();

    /**
     * Get a reference to the entry at the back (top) of the stack.
     *
     * @return a reference to the back of the stack.
     */
    const StackEntry&
    back() const
    {
        assert(m_stack.empty() == false);

        return m_stack.back();
    }

    friend class CommitPushElementFrame;
    friend class EnsurePop;
    friend class PushParamFunctor;
    friend class SetAndRestoreForceGlobalSearch;

    const XObjectPtr
    findXObject(
            const XalanQName&               name,
            StylesheetExecutionContext&     executionContext,
            bool                            fIsParam,
            bool                            fSearchGlobalSpace,
            bool&                           fNameFound);

    size_type
    findEntry(
            const XalanQName&   name,
            bool                fIsParam,
            bool                fSearchGlobalSpace);


    VariableStackStackType      m_stack;

    size_type                   m_globalStackFrameIndex;

    bool                        m_globalStackFrameMarked;

    /**
     * This is the top of the stack frame from where a search 
     * for a variable or param should take place.  It may not 
     * be the real stack top.
     */
    size_type                   m_currentStackFrameIndex;   

    /**
     * This will be a stack for any variable definitions
     * that are being evaluated dynamically, to protect
     * against circular definitions.
     */
    RecursionGuardStackType         m_guardStack;

    /**
     * This will be a stack for tracking element frames.
     * This is only used in debug builds.
     */
    ElemTemplateElementStackType    m_elementFrameStack;
};



XALAN_CPP_NAMESPACE_END



#endif  // #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD)