1 | /*
|
---|
2 | * This file is part of the KDE libraries
|
---|
3 | * Copyright (C) 1999-2001 Harri Porten ([email protected])
|
---|
4 | * Copyright (C) 2001 Peter Kelly ([email protected])
|
---|
5 | * Copyright (C) 2003 Apple Computer, Inc.
|
---|
6 | *
|
---|
7 | * This library is free software; you can redistribute it and/or
|
---|
8 | * modify it under the terms of the GNU Library General Public
|
---|
9 | * License as published by the Free Software Foundation; either
|
---|
10 | * version 2 of the License, or (at your option) any later version.
|
---|
11 | *
|
---|
12 | * This library is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | * Library General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU Library General Public License
|
---|
18 | * along with this library; see the file COPYING.LIB. If not, write to
|
---|
19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
---|
20 | * Boston, MA 02110-1301, USA.
|
---|
21 | *
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef ExecState_H
|
---|
25 | #define ExecState_H
|
---|
26 |
|
---|
27 | #include "value.h"
|
---|
28 | #include "types.h"
|
---|
29 |
|
---|
30 | namespace KJS {
|
---|
31 | class Context;
|
---|
32 | class Interpreter;
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Represents the current state of script execution. This object allows you
|
---|
36 | * obtain a handle the interpreter that is currently executing the script,
|
---|
37 | * and also the current execution context.
|
---|
38 | */
|
---|
39 | class ExecState {
|
---|
40 | friend class Interpreter;
|
---|
41 | friend class FunctionImp;
|
---|
42 | friend class RuntimeMethodImp;
|
---|
43 | friend class GlobalFuncImp;
|
---|
44 | public:
|
---|
45 | /**
|
---|
46 | * Returns the interpreter associated with this execution state
|
---|
47 | *
|
---|
48 | * @return The interpreter executing the script
|
---|
49 | */
|
---|
50 | Interpreter* dynamicInterpreter() const { return m_interpreter; }
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Returns the interpreter associated with the current scope's
|
---|
54 | * global object
|
---|
55 | *
|
---|
56 | * @return The interpreter currently in scope
|
---|
57 | */
|
---|
58 | Interpreter* lexicalInterpreter() const;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Returns the execution context associated with this execution state
|
---|
62 | *
|
---|
63 | * @return The current execution state context
|
---|
64 | */
|
---|
65 | Context* context() const { return m_context; }
|
---|
66 |
|
---|
67 | void setException(JSValue* e) { m_exception = e; }
|
---|
68 | void clearException() { m_exception = 0; }
|
---|
69 | JSValue* exception() const { return m_exception; }
|
---|
70 | bool hadException() const { return m_exception; }
|
---|
71 |
|
---|
72 | private:
|
---|
73 | ExecState(Interpreter* interp, Context* con)
|
---|
74 | : m_interpreter(interp)
|
---|
75 | , m_context(con)
|
---|
76 | , m_exception(0)
|
---|
77 | {
|
---|
78 | }
|
---|
79 | Interpreter* m_interpreter;
|
---|
80 | Context* m_context;
|
---|
81 | JSValue* m_exception;
|
---|
82 | };
|
---|
83 |
|
---|
84 | } // namespace KJS
|
---|
85 |
|
---|
86 | #endif // ExecState_H
|
---|