This file is indexed.

/usr/include/KF5/kjs/ExecState.h is in libkf5kjs-dev 5.28.0-1.

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
/*
 *  This file is part of the KDE libraries
 *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
 *  Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
 *  Copyright (C) 2008 Maksim Orlovich (maksim@kde.org)
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 *
 */

#ifndef ExecState_H
#define ExecState_H

#include "completion.h"
#include "value.h"
#include "types.h"
#include "CommonIdentifiers.h"
#include "scope_chain.h"
#include "LocalStorage.h"
#include "wtf/Vector.h"
#include "PropertyNameArray.h"

namespace KJS
{
class ActivationImp;
class Interpreter;
class FunctionImp;
class FunctionBodyNode;
class ProgramNode;
class JSGlobalObject;

enum CodeType { GlobalCode, EvalCode, FunctionCode };

/**
 * Represents the current state of script execution. This object allows you
 * obtain a handle the interpreter that is currently executing the script,
 * and also the current execution context.
 */
class KJS_EXPORT ExecState : Noncopyable
{
    friend class Interpreter;
    friend class FunctionImp;
    friend class GlobalFuncImp;
public:
    /**
     * Returns the interpreter associated with this execution state
     *
     * @return The interpreter executing the script
     */
    Interpreter *dynamicInterpreter() const
    {
        return m_interpreter;
    }

    /**
     * Returns the interpreter associated with the current scope's
     * global object
     *
     * @return The interpreter currently in scope
     */
    Interpreter *lexicalInterpreter() const;

    /**
     * This describes how an exception should be handled
     */
    enum HandlerType {
        JumpToCatch,     ///< jump to the specified address
        PopScope,        ///< remove a scope chain entry, and run the next handler
        RemoveDeferred,  ///< remove any deferred exception object, and run the next entry
        Silent           ///< just update the exception object. For debugger-type use only
    };

    void pushExceptionHandler(HandlerType type, Addr addr = 0);

    void popExceptionHandler();

    // Cleanup depth entries from the stack, w/o running jumps
    void quietUnwind(int depth);

    void setMachineRegisters(const unsigned char *pcBase, const unsigned char **pcLoc, LocalStorageEntry **machineLocalStoreLoc)
    {
        m_pcBase            = pcBase;
        m_pc                = pcLoc;
        m_machineLocalStore = machineLocalStoreLoc;
    }

    /**
     The below methods deal with deferring of completions inside finally clauses.
     Essentially, we clear any set exceptions and memorize any non-normal completion
     (including the target addresses for the continue/break statements) on
     the m_deferredCompletions stack. If the 'finally' finishes normally,
     we will resume the previous completion. If not, finally's abnormal
     termination is handled as usually; a RemoveDeferred cleanup stack
     entry is added to unwind m_deferredCompletions if that happens.
    */

    void deferCompletion()
    {
        pushExceptionHandler(RemoveDeferred);
        m_deferredCompletions.append(abruptCompletion());
        clearException();
    }

    /**
     This resumes dispatch of a completion that was deferred due to a try ... finally,
     handling it as appropriate for whether it's inside an another try-finally.
     This will handle all the cases itself except for one: return,
     for which it will return the value to return (otherwise returning 0)
    */
    JSValue *reactivateCompletion(bool insideTryFinally);

    /**
     * Set the exception associated with this execution state,
     * updating the program counter appropriately, and executing any relevant EH cleanups.
     * @param e The JSValue of the exception being set
     */
    void setException(JSValue *e);

    /**
     * Records an abrupt completion of code, and jumps to the closest catch or finally.
     * This always happens for exceptions, but can also happen for continue/break/return when
     * they're inside try ... finally, since that case gets routed through the EH machinery.
     */
    void setAbruptCompletion(Completion comp);

    /**
     * Clears the exception or other abnormal completion set on this execution state.
     */
    void clearException()
    {
        m_completion = Completion();
    }

    /**
     * Returns the exception associated with this execution state.
     * @return The current execution state exception
     */
    JSValue *exception() const
    {
        return m_completion.complType() == Throw ? m_completion.value() : 0;
    }

    /**
     * Use this to check if an exception was thrown in the current
     * execution state.
     *
     * @return Whether an exception was thrown
     */
    bool hadException() const
    {
        return m_completion.complType() == Throw;
    }

    Completion abruptCompletion() const
    {
        return m_completion;
    }

    /**
     * Returns the scope chain for this execution context. This is used for
     * variable lookup, with the list being searched from start to end until a
     * variable is found.
     *
     * @return The execution context's scope chain
     */
    const ScopeChain &scopeChain() const
    {
        return scope;
    }

    /**
     * Returns the variable object for the execution context. This contains a
     * property for each variable declared in the execution context.
     *
     * @return The execution context's variable object
     */
    JSObject *variableObject() const
    {
        return m_variable;
    }
    void setVariableObject(JSObject *v)
    {
        m_variable = v;
    }

    /**
     * Returns the "this" value for the execution context. This is the value
     * returned when a script references the special variable "this". It should
     * always be an Object, unless application-specific code has passed in a
     * different type.
     *
     * The object that is used as the "this" value depends on the type of
     * execution context - for global contexts, the global object is used. For
     * function objewcts, the value is given by the caller (e.g. in the case of
     * obj.func(), obj would be the "this" value). For code executed by the
     * built-in "eval" function, the this value is the same as the calling
     * context.
     *
     * @return The execution context's "this" value
     */
    JSObject *thisValue() const
    {
        return m_thisVal;
    }

    /**
     * Returns the context from which the current context was invoked. For
     * global code this will be a null context (i.e. one for which
     * isNull() returns true). You should check isNull() on the returned
     * value before calling any of its methods.
     *
     * @return The calling execution context
     */
    ExecState *callingExecState()
    {
        return m_callingExec;
    }

    /**
     * Returns the execState of a previous nested evaluation session, if any.
     */
    ExecState *savedExecState()
    {
        return m_savedExec;
    }

    JSObject *activationObject()
    {
        assert(m_codeType == FunctionCode);
        return m_variable;
    }

    CodeType codeType()
    {
        return m_codeType;
    }
    FunctionBodyNode *currentBody()
    {
        return m_currentBody;
    }
    FunctionImp *function() const
    {
        return m_function;
    }

    void pushVariableObjectScope(JSVariableObject *s)
    {
        scope.pushVariableObject(s);
    }
    void pushScope(JSObject *s)
    {
        scope.push(s);
    }
    void popScope()
    {
        scope.pop();
    }

    void mark();

    void initLocalStorage(LocalStorageEntry *store, size_t size)
    {
        m_localStore = store;
        m_localStoreSize = size;
    }

    void updateLocalStorage(LocalStorageEntry *newStore)
    {
        m_localStore         = newStore;
        *m_machineLocalStore = newStore;
    }

    LocalStorageEntry *localStorage()
    {
        return m_localStore;
    }

    // This is a workaround to avoid accessing the global variables for these identifiers in
    // important property lookup functions, to avoid taking PIC branches in Mach-O binaries
    const CommonIdentifiers &propertyNames() const
    {
        return *m_propertyNames;
    }

    // Compatibility stuff:
    ExecState *context()
    {
        return this;
    }
    ExecState *callingContext()
    {
        return callingExecState();
    }
protected:
    ExecState(Interpreter *intp, ExecState *save);
    ~ExecState();
    void markSelf();

    Interpreter *m_interpreter;
    Completion   m_completion;
    CommonIdentifiers *m_propertyNames;
    ExecState *m_callingExec;
    ExecState *m_savedExec; // in case of recursion of evaluation. Needed to mark things properly;
    // note that this is disjoint from the above, since that's only used for
    // eval/function, while this is for global.

    FunctionBodyNode *m_currentBody;
    FunctionImp *m_function;

    ScopeChain scope;
    JSObject *m_variable;
    JSObject *m_thisVal;

    LocalStorageEntry      *m_localStore;
    size_t                  m_localStoreSize;

    struct ExceptionHandler {
        ExceptionHandler() {}
        ExceptionHandler(HandlerType type, Addr dest):
            type(type), dest(dest) {}

        HandlerType type;
        Addr        dest;
    };

    const unsigned char  *m_pcBase;  // The address of pc = 0
    const unsigned char **m_pc;      // Where the current fetch address is stored
    LocalStorageEntry **m_machineLocalStore; // Machine's copy of m_localStore
    WTF::Vector<ExceptionHandler, 4> m_exceptionHandlers;
    WTF::Vector<Completion, 4>       m_deferredCompletions;

    CodeType m_codeType;
};

typedef ExecState Context; // Compatibility only

class GlobalExecState : public ExecState
{
public:
    GlobalExecState(Interpreter *intp, JSGlobalObject *global);
};

class InterpreterExecState : public ExecState
{
public:
    InterpreterExecState(Interpreter *intp, JSGlobalObject *global, JSObject *thisObject, ProgramNode *);
};

class EvalExecState : public ExecState
{
public:
    EvalExecState(Interpreter *intp, JSGlobalObject *global, ProgramNode *body, ExecState *callingExecState);
};

// Note: this does not push the activation on the scope chain,
// as the activation is not initialized at this point.
class FunctionExecState : public ExecState
{
public:
    FunctionExecState(Interpreter *intp, JSObject *thisObject,
                      FunctionBodyNode *, ExecState *callingExecState, FunctionImp *);
};

} // namespace KJS

#endif // ExecState_H