KJS::Interpreter Class Reference
#include <interpreter.h>
Detailed Description
Interpreter objects can be used to evaluate ECMAScript code.Each interpreter has a global object which is used for the purposes of code evaluation, and also provides access to built-in properties such as " Object" and "Number".
Definition at line 173 of file interpreter.h.
Constructor & Destructor Documentation
Interpreter::Interpreter | ( | const Object & | global | ) |
Creates a new interpreter.
The supplied object will be used as the global object for all scripts executed with this interpreter. During constuction, all the standard properties such as "Object" and "Number" will be added to the global object.
Note: You should not use the same global object for multiple interpreters.
This is due do the fact that the built-in properties are set in the constructor, and if these objects have been modified from another interpreter (e.g. a script modifying String.prototype), the changes will be overridden.
- Parameters:
-
global The object to use as the global object for this interpreter
Definition at line 113 of file interpreter.cpp.
Interpreter::Interpreter | ( | ) |
Creates a new interpreter.
A global object will be created and initialized with the standard global properties.
Definition at line 118 of file interpreter.cpp.
Member Function Documentation
Object Interpreter::builtinArray | ( | ) | const |
Object Interpreter::builtinArrayPrototype | ( | ) | const |
Object Interpreter::builtinBoolean | ( | ) | const |
Object Interpreter::builtinBooleanPrototype | ( | ) | const |
Object Interpreter::builtinDate | ( | ) | const |
Object Interpreter::builtinDatePrototype | ( | ) | const |
Object Interpreter::builtinError | ( | ) | const |
Object Interpreter::builtinErrorPrototype | ( | ) | const |
Object Interpreter::builtinEvalError | ( | ) | const |
Object Interpreter::builtinFunction | ( | ) | const |
Object Interpreter::builtinFunctionPrototype | ( | ) | const |
Object Interpreter::builtinNumber | ( | ) | const |
Object Interpreter::builtinNumberPrototype | ( | ) | const |
Object Interpreter::builtinObject | ( | ) | const |
Returns the builtin "Object" object.
This is the object that was set as a property of the global object during construction; if the property is replaced by script code, this method will still return the original object.
- Returns:
- The builtin "Object" object
Definition at line 174 of file interpreter.cpp.
Object Interpreter::builtinObjectPrototype | ( | ) | const |
Object Interpreter::builtinRegExp | ( | ) | const |
Object Interpreter::builtinRegExpPrototype | ( | ) | const |
Object Interpreter::builtinString | ( | ) | const |
Object Interpreter::builtinStringPrototype | ( | ) | const |
bool Interpreter::checkSyntax | ( | const UString & | code | ) |
Parses the supplied ECMAScript code and checks for syntax errors.
- Parameters:
-
code The code to check
- Returns:
- true if there were no syntax errors in the code, otherwise false
Definition at line 159 of file interpreter.cpp.
Parses the supplied ECMAScript code and checks for syntax errors.
- Parameters:
-
code The code to check errLine Returns the line the error was on (if there was one). errMsg Returns the error message (if there was one).
- Returns:
- true if there were no syntax errors in the code, otherwise false
Definition at line 154 of file interpreter.cpp.
bool Interpreter::collect | ( | ) | [static] |
Run the garbage collection.
Returns true when at least one object was collected; false otherwise.
Definition at line 334 of file interpreter.cpp.
Completion Interpreter::evaluate | ( | const UString & | code, | |
const Value & | thisV = Value() | |||
) |
Evaluates the supplied ECMAScript code.
Since this method returns a Completion, you should check the type of completion to detect an error or before attempting to access the returned value. For example, if an error occurs during script execution and is not caught by the script, the completion type will be Throw.
If the supplied code is invalid, a SyntaxError will be thrown.
- Parameters:
-
code The code to evaluate thisV The value to pass in as the "this" value for the script execution. This should either be Null() or an Object.
- Returns:
- A completion object representing the result of the execution.
Definition at line 164 of file interpreter.cpp.
ExecState * Interpreter::globalExec | ( | ) |
Returns the execution state object which can be used to execute scripts using this interpreter at a the "global" level, i.e.
one with a execution context that has the global object as the "this" value, and who's scope chain contains only the global object.
Note: this pointer remains constant for the life of the interpreter and should not be manually deleted.
- Returns:
- The interpreter global execution state object
Definition at line 149 of file interpreter.cpp.
Object & Interpreter::globalObject | ( | ) | const |
Returns the object that is used as the global object during all script execution performed by this interpreter.
Definition at line 129 of file interpreter.cpp.
virtual void KJS::Interpreter::mark | ( | ) | [inline, virtual] |
Called by InterpreterImp during the mark phase of the garbage collector Default implementation does nothing, this exist for classes that reimplement Interpreter.
Definition at line 398 of file interpreter.h.
virtual int KJS::Interpreter::rtti | ( | ) | [inline, virtual] |
Provides a way to distinguish derived classes.
Only useful if you reimplement Interpreter and if different kind of interpreters are created in the same process. The base class returns 0, the ECMA-bindings interpreter returns 1.
Definition at line 406 of file interpreter.h.
void Interpreter::setCompatMode | ( | CompatMode | mode | ) |
Call this to enable a compatibility mode with another browser.
(by default konqueror is in "native mode"). Currently, in KJS, this only changes the behavior of Date::getYear() which returns the full year under IE.
Definition at line 324 of file interpreter.cpp.
The documentation for this class was generated from the following files: