source: webkit/trunk/JavaScriptCore/kjs/interpreter.h@ 28476

Last change on this file since 28476 was 28468, checked in by [email protected], 17 years ago

JavaScriptCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and
functions accessing data members from Interpreter to JSGlobalObject.
Changed Interpreter member functions to static functions.


This resolves a bug in global object bootstrapping, where the global
ExecState could be used when uninitialized.


This is a big change, but it's mostly code motion and renaming.


Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports
a .7% regression, but Shark sees no difference related to this patch,
and SunSpider reported a .7% speedup from an earlier step in this
refactoring, so I think it's fair to call that a wash.

JavaScriptGlue:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Replaced JSInterpreter
subclass with JSGlobalObject subclass.


  • JSRun.cpp: (JSRun::JSRun): (JSRun::Evaluate): (JSRun::CheckSyntax):
  • JSRun.h: (JSGlueGlobalObject::JSGlueGlobalObject):
  • JSUtils.cpp: (KJSValueToCFTypeInternal):
  • JSValueWrapper.cpp: (getThreadGlobalExecState):

WebCore:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject. Changed Interpreter
member functions to static functions. Same for the subclass,
ScriptInterpreter.


This is a big change, but it's mostly code motion and renaming.

WebKit/mac:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebView/WebFrame.mm: (-[WebFrame _attachScriptDebugger]):

WebKit/win:

Reviewed by Darin Adler.

Third step in refactoring JSGlobalObject: Moved data members and data
member access from Interpreter to JSGlobalObject.


  • WebFrame.cpp: (WebFrame::globalContext): (WebFrame::attachScriptDebugger): (WebFrame::windowObjectCleared):
  • WebScriptDebugger.cpp: (WebScriptDebugger::WebScriptDebugger):
  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
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
26namespace KJS {
27
28 class Completion;
29 class ExecState;
30 class JSValue;
31 class UString;
32
33 struct UChar;
34
35 class Interpreter {
36 public:
37 /**
38 * Parses the supplied ECMAScript code and checks for syntax errors.
39 *
40 * @param code The code to check
41 * @return A normal completion if there were no syntax errors in the code,
42 * otherwise a throw completion with the syntax error as its value.
43 */
44 static Completion checkSyntax(ExecState*, const UString& sourceURL, int startingLineNumber, const UString& code);
45 static Completion checkSyntax(ExecState*, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength);
46
47 /**
48 * Evaluates the supplied ECMAScript code.
49 *
50 * Since this method returns a Completion, you should check the type of
51 * completion to detect an error or before attempting to access the returned
52 * value. For example, if an error occurs during script execution and is not
53 * caught by the script, the completion type will be Throw.
54 *
55 * If the supplied code is invalid, a SyntaxError will be thrown.
56 *
57 * @param code The code to evaluate
58 * @param thisV The value to pass in as the "this" value for the script
59 * execution. This should either be jsNull() or an Object.
60 * @return A completion object representing the result of the execution.
61 */
62 static Completion evaluate(ExecState*, const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV = 0);
63 static Completion evaluate(ExecState*, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV = 0);
64
65 static bool shouldPrintExceptions();
66 static void setShouldPrintExceptions(bool);
67 };
68
69} // namespace KJS
70
71#endif // KJS_Interpreter_h
Note: See TracBrowser for help on using the repository browser.