]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | /* |
2 | * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) | |
3 | * Copyright (C) 2001 Peter Kelly (pmk@post.com) | |
4 | * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Library General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Library General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Library General Public License | |
17 | * along with this library; see the file COPYING.LIB. If not, write to | |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
19 | * Boston, MA 02110-1301, USA. | |
20 | * | |
21 | */ | |
22 | ||
23 | #ifndef KJS_Interpreter_h | |
24 | #define KJS_Interpreter_h | |
25 | ||
b5422865 A |
26 | #include <wtf/PassRefPtr.h> |
27 | ||
b37bf2e1 A |
28 | namespace KJS { |
29 | ||
30 | class Completion; | |
31 | class ExecState; | |
32 | class JSValue; | |
b5422865 | 33 | class SourceCode; |
b37bf2e1 A |
34 | class UString; |
35 | ||
36 | struct UChar; | |
37 | ||
38 | class Interpreter { | |
39 | public: | |
40 | /** | |
41 | * Parses the supplied ECMAScript code and checks for syntax errors. | |
42 | * | |
43 | * @param code The code to check | |
44 | * @return A normal completion if there were no syntax errors in the code, | |
45 | * otherwise a throw completion with the syntax error as its value. | |
46 | */ | |
b5422865 | 47 | static Completion checkSyntax(ExecState*, const SourceCode&); |
b37bf2e1 A |
48 | |
49 | /** | |
50 | * Evaluates the supplied ECMAScript code. | |
51 | * | |
52 | * Since this method returns a Completion, you should check the type of | |
53 | * completion to detect an error or before attempting to access the returned | |
54 | * value. For example, if an error occurs during script execution and is not | |
55 | * caught by the script, the completion type will be Throw. | |
56 | * | |
57 | * If the supplied code is invalid, a SyntaxError will be thrown. | |
58 | * | |
59 | * @param code The code to evaluate | |
60 | * @param thisV The value to pass in as the "this" value for the script | |
61 | * execution. This should either be jsNull() or an Object. | |
62 | * @return A completion object representing the result of the execution. | |
63 | */ | |
b5422865 | 64 | static Completion evaluate(ExecState*, const SourceCode&, JSValue* thisV = 0); |
b37bf2e1 A |
65 | |
66 | static bool shouldPrintExceptions(); | |
67 | static void setShouldPrintExceptions(bool); | |
68 | }; | |
69 | ||
70 | } // namespace KJS | |
71 | ||
72 | #endif // KJS_Interpreter_h |