.TH "KJS::Interpreter" 3 "28 Jan 2004" "kjs Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KJS::Interpreter \- \fBInterpreter\fP objects can be used to evaluate ECMAScript code.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <interpreter.h>\fP
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "enum \fBCompatMode\fP { \fBNativeMode\fP, \fBIECompat\fP, \fBNetscapeCompat\fP }"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBInterpreter\fP (const  \fBObject\fP &global)"
.br
.RI "\fICreates a new interpreter. \fP"
.ti -1c
.RI "\fBInterpreter\fP ()"
.br
.RI "\fICreates a new interpreter. \fP"
.ti -1c
.RI "\fBObject\fP \fBglobalObject\fP () const "
.br
.RI "\fIReturns the object that is used as the global object during all script execution performed by this interpreter. \fP"
.ti -1c
.RI "void \fBinitGlobalObject\fP ()"
.br
.ti -1c
.RI "\fBExecState\fP * \fBglobalExec\fP ()"
.br
.RI "\fIReturns the execution state object which can be used to execute scripts using this interpreter at a the 'global' level, i.e. \fP"
.ti -1c
.RI "bool \fBcheckSyntax\fP (const  \fBUString\fP &code)"
.br
.RI "\fIParses the supplied ECMAScript code and checks for syntax errors. \fP"
.ti -1c
.RI "\fBCompletion\fP \fBevaluate\fP (const  \fBUString\fP &code, const  \fBValue\fP &thisV=\fBValue\fP())"
.br
.RI "\fIEvaluates the supplied ECMAScript code. \fP"
.ti -1c
.RI "InterpreterImp * \fBimp\fP ()"
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinObject\fP () const "
.br
.RI "\fIReturns the builtin 'Object' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinFunction\fP () const "
.br
.RI "\fIReturns the builtin 'Function' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinArray\fP () const "
.br
.RI "\fIReturns the builtin 'Array' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinBoolean\fP () const "
.br
.RI "\fIReturns the builtin 'Boolean' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinString\fP () const "
.br
.RI "\fIReturns the builtin 'String' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinNumber\fP () const "
.br
.RI "\fIReturns the builtin 'Number' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinDate\fP () const "
.br
.RI "\fIReturns the builtin 'Date' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinRegExp\fP () const "
.br
.RI "\fIReturns the builtin 'RegExp' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinError\fP () const "
.br
.RI "\fIReturns the builtin 'Error' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinObjectPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Object.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinFunctionPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Function.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinArrayPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Array.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinBooleanPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Boolean.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinStringPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'String.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinNumberPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Number.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinDatePrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Date.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinRegExpPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'RegExp.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinErrorPrototype\fP () const "
.br
.RI "\fIReturns the builtin 'Error.prototype' object. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinEvalError\fP () const "
.br
.RI "\fIThe initial value of 'Error' global property. \fP"
.ti -1c
.RI "\fBObject\fP \fBbuiltinRangeError\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinReferenceError\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinSyntaxError\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinTypeError\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinURIError\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinEvalErrorPrototype\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinRangeErrorPrototype\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinReferenceErrorPrototype\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinSyntaxErrorPrototype\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinTypeErrorPrototype\fP () const "
.br
.ti -1c
.RI "\fBObject\fP \fBbuiltinURIErrorPrototype\fP () const "
.br
.ti -1c
.RI "void \fBsetCompatMode\fP (CompatMode mode)"
.br
.RI "\fICall this to enable a compatibility mode with another browser. \fP"
.ti -1c
.RI "CompatMode \fBcompatMode\fP () const "
.br
.ti -1c
.RI "virtual void \fBmark\fP ()"
.br
.RI "\fICalled by InterpreterImp during the mark phase of the garbage collector Default implementation does nothing, this exist for classes that reimplement \fBInterpreter\fP. \fP"
.ti -1c
.RI "virtual int \fBrtti\fP ()"
.br
.RI "\fIProvides a way to distinguish derived classes. \fP"
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "bool \fBcollect\fP ()"
.br
.RI "\fIRun the garbage collection. \fP"
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
\fBInterpreter\fP 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'. 
.PP
Definition at line 119 of file interpreter.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "Interpreter::Interpreter (const \fBObject\fP & global)"
.PP
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.
.PP
Note: You should not use the same global object for multiple interpreters.
.PP
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.
.PP
\fBParameters:\fP
.RS 4
\fIglobal\fP The object to use as the global object for this interpreter 
.RE
.PP
Definition at line 96 of file interpreter.cpp.
.SS "Interpreter::Interpreter ()"
.PP
Creates a new interpreter. A global object will be created and initialized with the standard global properties. Definition at line 101 of file interpreter.cpp.
.SH "Member Function Documentation"
.PP 
.SS "\fBObject\fP Interpreter::globalObject () const"
.PP
Returns the object that is used as the global object during all script execution performed by this interpreter. Definition at line 112 of file interpreter.cpp.
.SS "\fBExecState\fP * Interpreter::globalExec ()"
.PP
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.
.PP
Note: this pointer remains constant for the life of the interpreter and should not be manually deleted.
.PP
\fBReturns:\fP
.RS 4
The interpreter global execution state object 
.RE
.PP
Definition at line 122 of file interpreter.cpp.
.SS "bool Interpreter::checkSyntax (const \fBUString\fP & code)"
.PP
Parses the supplied ECMAScript code and checks for syntax errors. \fBParameters:\fP
.RS 4
\fIcode\fP The code to check 
.RE
.PP
\fBReturns:\fP
.RS 4
true if there were no syntax errors in the code, otherwise false 
.RE
.PP
Definition at line 127 of file interpreter.cpp.
.SS "\fBCompletion\fP Interpreter::evaluate (const \fBUString\fP & code, const \fBValue\fP & thisV = \fBValue\fP())"
.PP
Evaluates the supplied ECMAScript code. Since this method returns a \fBCompletion\fP, 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.
.PP
If the supplied code is invalid, a SyntaxError will be thrown.
.PP
\fBParameters:\fP
.RS 4
\fIcode\fP The code to evaluate 
.br
\fIthisV\fP The value to pass in as the 'this' value for the script execution. This should either be Null() or an \fBObject\fP. 
.RE
.PP
\fBReturns:\fP
.RS 4
A completion object representing the result of the execution. 
.RE
.PP
Definition at line 132 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinObject () const"
.PP
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.
.PP
\fBReturns:\fP
.RS 4
The builtin 'Object' object 
.RE
.PP
Definition at line 142 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinFunction () const"
.PP
Returns the builtin 'Function' object. Definition at line 147 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinArray () const"
.PP
Returns the builtin 'Array' object. Definition at line 152 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinBoolean () const"
.PP
Returns the builtin 'Boolean' object. Definition at line 157 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinString () const"
.PP
Returns the builtin 'String' object. Definition at line 162 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinNumber () const"
.PP
Returns the builtin 'Number' object. Definition at line 167 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinDate () const"
.PP
Returns the builtin 'Date' object. Definition at line 172 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinRegExp () const"
.PP
Returns the builtin 'RegExp' object. Definition at line 177 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinError () const"
.PP
Returns the builtin 'Error' object. Definition at line 182 of file interpreter.cpp.
.PP
Referenced by KJS::Error::create().
.SS "\fBObject\fP Interpreter::builtinObjectPrototype () const"
.PP
Returns the builtin 'Object.prototype' object. Definition at line 187 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinFunctionPrototype () const"
.PP
Returns the builtin 'Function.prototype' object. Definition at line 192 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinArrayPrototype () const"
.PP
Returns the builtin 'Array.prototype' object. Definition at line 197 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinBooleanPrototype () const"
.PP
Returns the builtin 'Boolean.prototype' object. Definition at line 202 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinStringPrototype () const"
.PP
Returns the builtin 'String.prototype' object. Definition at line 207 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinNumberPrototype () const"
.PP
Returns the builtin 'Number.prototype' object. Definition at line 212 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinDatePrototype () const"
.PP
Returns the builtin 'Date.prototype' object. Definition at line 217 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinRegExpPrototype () const"
.PP
Returns the builtin 'RegExp.prototype' object. Definition at line 222 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinErrorPrototype () const"
.PP
Returns the builtin 'Error.prototype' object. Definition at line 227 of file interpreter.cpp.
.SS "\fBObject\fP Interpreter::builtinEvalError () const"
.PP
The initial value of 'Error' global property. Definition at line 232 of file interpreter.cpp.
.PP
Referenced by KJS::Error::create().
.SS "void Interpreter::setCompatMode (CompatMode mode)"
.PP
Call this to enable a compatibility mode with another browser. (by default konqueror is in 'native mode'). Currently, in KJS, this only changes the behaviour of Date::getYear() which returns the full year under IE. Definition at line 292 of file interpreter.cpp.
.SS "bool Interpreter::collect ()\fC [static]\fP"
.PP
Run the garbage collection. Returns true when at least one object was collected; false otherwise. Definition at line 302 of file interpreter.cpp.
.SS "virtual void KJS::Interpreter::mark ()\fC [inline, virtual]\fP"
.PP
Called by InterpreterImp during the mark phase of the garbage collector Default implementation does nothing, this exist for classes that reimplement \fBInterpreter\fP. Definition at line 332 of file interpreter.h.
.SS "virtual int KJS::Interpreter::rtti ()\fC [inline, virtual]\fP"
.PP
Provides a way to distinguish derived classes. Only useful if you reimplement \fBInterpreter\fP 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 340 of file interpreter.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kjs Library from the source code.
