KJS
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 52 of file interpreter.h.
Member Enumeration Documentation
Constructor & Destructor Documentation
| KJS::Interpreter::Interpreter | ( | JSObject * | globalObject | ) |
Creates a new interpreter.
The supplied object will be used as the global object for all scripts executed with this interpreter. During construction, 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 216 of file interpreter.cpp.
| KJS::Interpreter::Interpreter | ( | ) |
Creates a new interpreter.
A global object will be created and initialized with the standard global properties.
Definition at line 224 of file interpreter.cpp.
| KJS::Interpreter::~Interpreter | ( | ) | [protected, virtual] |
Definition at line 262 of file interpreter.cpp.
Member Function Documentation
| JSObject * KJS::Interpreter::globalObject | ( | ) | const |
Returns the object that is used as the global object during all script execution performed by this interpreter.
Definition at line 285 of file interpreter.cpp.
| void KJS::Interpreter::initGlobalObject | ( | ) |
Definition at line 290 of file interpreter.cpp.
| ExecState * KJS::Interpreter::globalExec | ( | ) | [virtual] |
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 406 of file interpreter.cpp.
| void KJS::Interpreter::setGlobalPackage | ( | Package * | p | ) |
Sets the package instance that will be used to resolve the first level of identifiers of import statements.
If no package is set which will make any "import" script statement fail with an error. This is the default in e.g. a Web browser where package imports should be disabled for security reasons.
Definition at line 411 of file interpreter.cpp.
| Package * KJS::Interpreter::globalPackage | ( | ) |
Returns the package that was installed to handle top level package requests.
Returns 0, the default, when no package was set.
- Returns:
- The global package
Definition at line 416 of file interpreter.cpp.
| Completion KJS::Interpreter::checkSyntax | ( | const UString & | sourceURL, | |
| int | startingLineNumber, | |||
| const UString & | code | |||
| ) |
Parses the supplied ECMAScript code and checks for syntax errors.
- Parameters:
-
code The code to check
- Returns:
- A normal completion if there were no syntax errors in the code, otherwise a throw completion with the syntax error as its value.
Definition at line 421 of file interpreter.cpp.
| Completion KJS::Interpreter::checkSyntax | ( | const UString & | sourceURL, | |
| int | startingLineNumber, | |||
| const UChar * | code, | |||
| int | codeLength | |||
| ) |
Definition at line 426 of file interpreter.cpp.
| Completion KJS::Interpreter::evaluate | ( | const UString & | sourceURL, | |
| int | startingLineNumber, | |||
| const UChar * | code, | |||
| int | codeLength, | |||
| JSValue * | thisV = 0 | |||
| ) |
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 jsNull() or an Object.
- Returns:
- A completion object representing the result of the execution.
Definition at line 443 of file interpreter.cpp.
| Completion KJS::Interpreter::evaluate | ( | const UString & | sourceURL, | |
| int | startingLineNumber, | |||
| const UString & | code, | |||
| JSValue * | thisV = 0 | |||
| ) |
Definition at line 438 of file interpreter.cpp.
| JSObject * KJS::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 516 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinFunction | ( | ) | const |
| JSObject * KJS::Interpreter::builtinArray | ( | ) | const |
| JSObject * KJS::Interpreter::builtinBoolean | ( | ) | const |
| JSObject * KJS::Interpreter::builtinString | ( | ) | const |
| JSObject * KJS::Interpreter::builtinNumber | ( | ) | const |
| JSObject * KJS::Interpreter::builtinDate | ( | ) | const |
| JSObject * KJS::Interpreter::builtinRegExp | ( | ) | const |
| JSObject * KJS::Interpreter::builtinError | ( | ) | const |
| JSObject * KJS::Interpreter::builtinObjectPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinFunctionPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinArrayPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinBooleanPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinStringPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinNumberPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinDatePrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinRegExpPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinErrorPrototype | ( | ) | const |
| JSObject * KJS::Interpreter::builtinEvalError | ( | ) | const |
| JSObject * KJS::Interpreter::builtinRangeError | ( | ) | const |
Definition at line 611 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinReferenceError | ( | ) | const |
Definition at line 616 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinSyntaxError | ( | ) | const |
Definition at line 621 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinTypeError | ( | ) | const |
Definition at line 626 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinURIError | ( | ) | const |
Definition at line 631 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinEvalErrorPrototype | ( | ) | const |
Definition at line 636 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinRangeErrorPrototype | ( | ) | const |
Definition at line 641 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinReferenceErrorPrototype | ( | ) | const |
Definition at line 646 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinSyntaxErrorPrototype | ( | ) | const |
Definition at line 651 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinTypeErrorPrototype | ( | ) | const |
Definition at line 656 of file interpreter.cpp.
| JSObject * KJS::Interpreter::builtinURIErrorPrototype | ( | ) | const |
Definition at line 661 of file interpreter.cpp.
| void KJS::Interpreter::setCompatMode | ( | CompatMode | mode | ) | [inline] |
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 266 of file interpreter.h.
| CompatMode KJS::Interpreter::compatMode | ( | ) | const [inline] |
Definition at line 267 of file interpreter.h.
| bool KJS::Interpreter::collect | ( | ) | [static] |
Run the garbage collection.
Returns true when at least one object was collected; false otherwise.
Definition at line 666 of file interpreter.cpp.
| void KJS::Interpreter::mark | ( | bool | currentThreadIsMainThread | ) | [virtual] |
Called during the mark phase of the garbage collector.
Subclasses implementing custom mark methods must make sure to chain to this one.
Definition at line 671 of file interpreter.cpp.
| 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 287 of file interpreter.h.
| bool KJS::Interpreter::shouldPrintExceptions | ( | ) | [static] |
Definition at line 699 of file interpreter.cpp.
| void KJS::Interpreter::setShouldPrintExceptions | ( | bool | ) | [static] |
Definition at line 704 of file interpreter.cpp.
| void KJS::Interpreter::saveBuiltins | ( | SavedBuiltins & | builtins | ) | const |
Definition at line 731 of file interpreter.cpp.
| void KJS::Interpreter::restoreBuiltins | ( | const SavedBuiltins & | builtins | ) |
Definition at line 771 of file interpreter.cpp.
Determine if the value is a global object (for any interpreter).
This may be difficult to determine for multiple uses of JSC in a process that are logically independent of each other. In the case of a Web browser, this method is used to determine if an object is the Window object so we can perform security checks.
Definition at line 302 of file interpreter.h.
| virtual Interpreter* KJS::Interpreter::interpreterForGlobalObject | ( | const JSValue * | ) | [inline, virtual] |
Find the interpreter for a particular global object.
This should really be a static method, but we can't do that is C++. Again, as with isGlobalObject() implementation really need to know about all instances of Interpreter created in an application to correctly implement this method. The only override of this method is currently in WebCore.
Definition at line 311 of file interpreter.h.
| virtual bool KJS::Interpreter::isSafeScript | ( | const Interpreter * | ) | [inline, virtual] |
Determine if the it is 'safe' to execute code in the target interpreter from an object that originated in this interpreter.
This check is used to enforce WebCore cross frame security rules. In particular, attempts to access 'bound' objects are not allowed unless isSafeScript returns true.
Definition at line 319 of file interpreter.h.
| static Interpreter* KJS::Interpreter::firstInterpreter | ( | ) | [inline, static] |
Definition at line 326 of file interpreter.h.
| Interpreter* KJS::Interpreter::nextInterpreter | ( | ) | const [inline] |
Definition at line 327 of file interpreter.h.
| Interpreter* KJS::Interpreter::prevInterpreter | ( | ) | const [inline] |
Definition at line 328 of file interpreter.h.
| Debugger* KJS::Interpreter::debugger | ( | ) | const [inline] |
Definition at line 330 of file interpreter.h.
| void KJS::Interpreter::setDebugger | ( | Debugger * | d | ) | [inline] |
Definition at line 331 of file interpreter.h.
| void KJS::Interpreter::setContext | ( | Context * | c | ) | [inline] |
Definition at line 333 of file interpreter.h.
| Context* KJS::Interpreter::context | ( | ) | const [inline] |
Definition at line 334 of file interpreter.h.
| Interpreter * KJS::Interpreter::interpreterWithGlobalObject | ( | JSObject * | globalObject | ) | [static] |
Definition at line 681 of file interpreter.cpp.
| void KJS::Interpreter::setTimeoutTime | ( | unsigned | timeoutTime | ) | [inline] |
Definition at line 338 of file interpreter.h.
| void KJS::Interpreter::startTimeoutCheck | ( | ) |
Definition at line 811 of file interpreter.cpp.
| void KJS::Interpreter::stopTimeoutCheck | ( | ) |
Definition at line 819 of file interpreter.cpp.
| void KJS::Interpreter::restartTimeoutCheck | ( | ) |
Definition at line 826 of file interpreter.cpp.
| void KJS::Interpreter::pauseTimeoutCheck | ( | ) |
Definition at line 836 of file interpreter.cpp.
| void KJS::Interpreter::resumeTimeoutCheck | ( | ) |
Definition at line 843 of file interpreter.cpp.
| bool KJS::Interpreter::checkTimeout | ( | ) | [inline] |
Definition at line 437 of file interpreter.h.
| void KJS::Interpreter::ref | ( | ) | [inline] |
Definition at line 351 of file interpreter.h.
| void KJS::Interpreter::deref | ( | ) | [inline] |
Definition at line 352 of file interpreter.h.
| int KJS::Interpreter::refCount | ( | ) | const [inline] |
Definition at line 353 of file interpreter.h.
| virtual bool KJS::Interpreter::shouldInterruptScript | ( | ) | const [inline, protected, virtual] |
Definition at line 357 of file interpreter.h.
Friends And Related Function Documentation
friend class Collector [friend] |
Definition at line 53 of file interpreter.h.
friend class TimeoutChecker [friend] |
Definition at line 54 of file interpreter.h.
Member Data Documentation
long KJS::Interpreter::m_timeoutTime [protected] |
Definition at line 359 of file interpreter.h.
The documentation for this class was generated from the following files:
KDE 4.0 API Reference