\section{KJS::Interpreter Class Reference}
\label{classKJS_1_1Interpreter}\index{KJS::Interpreter@{KJS::Interpreter}}
{\bf Interpreter}{\rm (p.\,\pageref{classKJS_1_1Interpreter})} objects can be used to evaluate ECMAScript code.  


{\tt \#include $<$interpreter.h$>$}

\subsection*{Public Types}
\begin{CompactItemize}
\item 
enum {\bf Compat\-Mode} \{ {\bf Native\-Mode}, 
{\bf IECompat}, 
{\bf Netscape\-Compat}
 \}
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Interpreter} (const {\bf Object} \&global)
\item 
{\bf Interpreter} ()
\item 
{\bf Object} \& {\bf global\-Object} () const 
\item 
void {\bf init\-Global\-Object} ()\label{classKJS_1_1Interpreter_a4}

\item 
{\bf Exec\-State} $\ast$ {\bf global\-Exec} ()
\item 
bool {\bf check\-Syntax} (const {\bf UString} \&code, int $\ast$err\-Line, {\bf UString} $\ast$err\-Msg)
\item 
bool {\bf check\-Syntax} (const {\bf UString} \&code)
\item 
{\bf Completion} {\bf evaluate} (const {\bf UString} \&code, const {\bf Value} \&this\-V={\bf Value}())
\item 
Interpreter\-Imp $\ast$ {\bf imp} ()\label{classKJS_1_1Interpreter_a9}

\item 
{\bf Object} {\bf builtin\-Object} () const 
\item 
{\bf Object} {\bf builtin\-Function} () const 
\item 
{\bf Object} {\bf builtin\-Array} () const 
\item 
{\bf Object} {\bf builtin\-Boolean} () const 
\item 
{\bf Object} {\bf builtin\-String} () const 
\item 
{\bf Object} {\bf builtin\-Number} () const 
\item 
{\bf Object} {\bf builtin\-Date} () const 
\item 
{\bf Object} {\bf builtin\-Reg\-Exp} () const 
\item 
{\bf Object} {\bf builtin\-Error} () const 
\item 
{\bf Object} {\bf builtin\-Object\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Function\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Array\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Boolean\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-String\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Number\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Date\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Reg\-Exp\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Error\-Prototype} () const 
\item 
{\bf Object} {\bf builtin\-Eval\-Error} () const 
\item 
{\bf Object} {\bf builtin\-Range\-Error} () const \label{classKJS_1_1Interpreter_a29}

\item 
{\bf Object} {\bf builtin\-Reference\-Error} () const \label{classKJS_1_1Interpreter_a30}

\item 
{\bf Object} {\bf builtin\-Syntax\-Error} () const \label{classKJS_1_1Interpreter_a31}

\item 
{\bf Object} {\bf builtin\-Type\-Error} () const \label{classKJS_1_1Interpreter_a32}

\item 
{\bf Object} {\bf builtin\-URIError} () const \label{classKJS_1_1Interpreter_a33}

\item 
{\bf Object} {\bf builtin\-Eval\-Error\-Prototype} () const \label{classKJS_1_1Interpreter_a34}

\item 
{\bf Object} {\bf builtin\-Range\-Error\-Prototype} () const \label{classKJS_1_1Interpreter_a35}

\item 
{\bf Object} {\bf builtin\-Reference\-Error\-Prototype} () const \label{classKJS_1_1Interpreter_a36}

\item 
{\bf Object} {\bf builtin\-Syntax\-Error\-Prototype} () const \label{classKJS_1_1Interpreter_a37}

\item 
{\bf Object} {\bf builtin\-Type\-Error\-Prototype} () const \label{classKJS_1_1Interpreter_a38}

\item 
{\bf Object} {\bf builtin\-URIError\-Prototype} () const \label{classKJS_1_1Interpreter_a39}

\item 
void {\bf set\-Compat\-Mode} (Compat\-Mode mode)
\item 
Compat\-Mode {\bf compat\-Mode} () const \label{classKJS_1_1Interpreter_a41}

\item 
virtual void {\bf mark} ()
\item 
virtual int {\bf rtti} ()
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static void {\bf lock} ()\label{classKJS_1_1Interpreter_e0}

\item 
static void {\bf unlock} ()\label{classKJS_1_1Interpreter_e1}

\item 
static bool {\bf collect} ()
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKJS_1_1Interpreter_b0}

\end{CompactItemize}


\subsection{Detailed Description}
{\bf Interpreter}{\rm (p.\,\pageref{classKJS_1_1Interpreter})} 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 \char`\"{} Object\char`\"{} and \char`\"{}Number\char`\"{}. 



Definition at line 173 of file interpreter.h.

\subsection{Constructor \& Destructor Documentation}
\index{KJS::Interpreter@{KJS::Interpreter}!Interpreter@{Interpreter}}
\index{Interpreter@{Interpreter}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Interpreter::Interpreter (const {\bf Object} \& {\em global})}\label{classKJS_1_1Interpreter_a0}


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 \char`\"{}Object\char`\"{} and \char`\"{}Number\char`\"{} 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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em global}]The object to use as the global object for this interpreter \end{description}
\end{Desc}


Definition at line 113 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!Interpreter@{Interpreter}}
\index{Interpreter@{Interpreter}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Interpreter::Interpreter ()}\label{classKJS_1_1Interpreter_a1}


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.

\subsection{Member Function Documentation}
\index{KJS::Interpreter@{KJS::Interpreter}!globalObject@{globalObject}}
\index{globalObject@{globalObject}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} \& Interpreter::global\-Object () const}\label{classKJS_1_1Interpreter_a3}


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.\index{KJS::Interpreter@{KJS::Interpreter}!globalExec@{globalExec}}
\index{globalExec@{globalExec}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Exec\-State} $\ast$ Interpreter::global\-Exec ()}\label{classKJS_1_1Interpreter_a5}


Returns the execution state object which can be used to execute scripts using this interpreter at a the \char`\"{}global\char`\"{} level, i.e. 

one with a execution context that has the global object as the \char`\"{}this\char`\"{} 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.

\begin{Desc}
\item[Returns:]The interpreter global execution state object \end{Desc}


Definition at line 149 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!checkSyntax@{checkSyntax}}
\index{checkSyntax@{checkSyntax}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Interpreter::check\-Syntax (const {\bf UString} \& {\em code}, int $\ast$ {\em err\-Line}, {\bf UString} $\ast$ {\em err\-Msg})}\label{classKJS_1_1Interpreter_a6}


Parses the supplied ECMAScript code and checks for syntax errors. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em code}]The code to check \item[{\em err\-Line}]Returns the line the error was on (if there was one). \item[{\em err\-Msg}]Returns the error message (if there was one). \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if there were no syntax errors in the code, otherwise false \end{Desc}


Definition at line 154 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!checkSyntax@{checkSyntax}}
\index{checkSyntax@{checkSyntax}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Interpreter::check\-Syntax (const {\bf UString} \& {\em code})}\label{classKJS_1_1Interpreter_a7}


Parses the supplied ECMAScript code and checks for syntax errors. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em code}]The code to check \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if there were no syntax errors in the code, otherwise false \end{Desc}


Definition at line 159 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!evaluate@{evaluate}}
\index{evaluate@{evaluate}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Completion} Interpreter::evaluate (const {\bf UString} \& {\em code}, const {\bf Value} \& {\em this\-V} = {\tt {\bf Value}()})}\label{classKJS_1_1Interpreter_a8}


Evaluates the supplied ECMAScript code. 

Since this method returns a {\bf Completion}{\rm (p.\,\pageref{classKJS_1_1Completion})}, 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 Syntax\-Error will be thrown.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em code}]The code to evaluate \item[{\em this\-V}]The value to pass in as the \char`\"{}this\char`\"{} value for the script execution. This should either be Null() or an {\bf Object}{\rm (p.\,\pageref{classKJS_1_1Object})}. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A completion object representing the result of the execution. \end{Desc}


Definition at line 164 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinObject@{builtinObject}}
\index{builtinObject@{builtinObject}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Object () const}\label{classKJS_1_1Interpreter_a10}


Returns the builtin \char`\"{}Object\char`\"{} 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.

\begin{Desc}
\item[Returns:]The builtin \char`\"{}Object\char`\"{} object \end{Desc}


Definition at line 174 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinFunction@{builtinFunction}}
\index{builtinFunction@{builtinFunction}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Function () const}\label{classKJS_1_1Interpreter_a11}


Returns the builtin \char`\"{}Function\char`\"{} object. 



Definition at line 179 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinArray@{builtinArray}}
\index{builtinArray@{builtinArray}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Array () const}\label{classKJS_1_1Interpreter_a12}


Returns the builtin \char`\"{}Array\char`\"{} object. 



Definition at line 184 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinBoolean@{builtinBoolean}}
\index{builtinBoolean@{builtinBoolean}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Boolean () const}\label{classKJS_1_1Interpreter_a13}


Returns the builtin \char`\"{}Boolean\char`\"{} object. 



Definition at line 189 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinString@{builtinString}}
\index{builtinString@{builtinString}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-String () const}\label{classKJS_1_1Interpreter_a14}


Returns the builtin \char`\"{}String\char`\"{} object. 



Definition at line 194 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinNumber@{builtinNumber}}
\index{builtinNumber@{builtinNumber}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Number () const}\label{classKJS_1_1Interpreter_a15}


Returns the builtin \char`\"{}Number\char`\"{} object. 



Definition at line 199 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinDate@{builtinDate}}
\index{builtinDate@{builtinDate}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Date () const}\label{classKJS_1_1Interpreter_a16}


Returns the builtin \char`\"{}Date\char`\"{} object. 



Definition at line 204 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinRegExp@{builtinRegExp}}
\index{builtinRegExp@{builtinRegExp}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Reg\-Exp () const}\label{classKJS_1_1Interpreter_a17}


Returns the builtin \char`\"{}Reg\-Exp\char`\"{} object. 



Definition at line 209 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinError@{builtinError}}
\index{builtinError@{builtinError}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Error () const}\label{classKJS_1_1Interpreter_a18}


Returns the builtin \char`\"{}Error\char`\"{} object. 



Definition at line 214 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinObjectPrototype@{builtinObjectPrototype}}
\index{builtinObjectPrototype@{builtinObjectPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Object\-Prototype () const}\label{classKJS_1_1Interpreter_a19}


Returns the builtin \char`\"{}Object.prototype\char`\"{} object. 



Definition at line 219 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinFunctionPrototype@{builtinFunctionPrototype}}
\index{builtinFunctionPrototype@{builtinFunctionPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Function\-Prototype () const}\label{classKJS_1_1Interpreter_a20}


Returns the builtin \char`\"{}Function.prototype\char`\"{} object. 



Definition at line 224 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinArrayPrototype@{builtinArrayPrototype}}
\index{builtinArrayPrototype@{builtinArrayPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Array\-Prototype () const}\label{classKJS_1_1Interpreter_a21}


Returns the builtin \char`\"{}Array.prototype\char`\"{} object. 



Definition at line 229 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinBooleanPrototype@{builtinBooleanPrototype}}
\index{builtinBooleanPrototype@{builtinBooleanPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Boolean\-Prototype () const}\label{classKJS_1_1Interpreter_a22}


Returns the builtin \char`\"{}Boolean.prototype\char`\"{} object. 



Definition at line 234 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinStringPrototype@{builtinStringPrototype}}
\index{builtinStringPrototype@{builtinStringPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-String\-Prototype () const}\label{classKJS_1_1Interpreter_a23}


Returns the builtin \char`\"{}String.prototype\char`\"{} object. 



Definition at line 239 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinNumberPrototype@{builtinNumberPrototype}}
\index{builtinNumberPrototype@{builtinNumberPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Number\-Prototype () const}\label{classKJS_1_1Interpreter_a24}


Returns the builtin \char`\"{}Number.prototype\char`\"{} object. 



Definition at line 244 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinDatePrototype@{builtinDatePrototype}}
\index{builtinDatePrototype@{builtinDatePrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Date\-Prototype () const}\label{classKJS_1_1Interpreter_a25}


Returns the builtin \char`\"{}Date.prototype\char`\"{} object. 



Definition at line 249 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinRegExpPrototype@{builtinRegExpPrototype}}
\index{builtinRegExpPrototype@{builtinRegExpPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Reg\-Exp\-Prototype () const}\label{classKJS_1_1Interpreter_a26}


Returns the builtin \char`\"{}Reg\-Exp.prototype\char`\"{} object. 



Definition at line 254 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinErrorPrototype@{builtinErrorPrototype}}
\index{builtinErrorPrototype@{builtinErrorPrototype}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Error\-Prototype () const}\label{classKJS_1_1Interpreter_a27}


Returns the builtin \char`\"{}Error.prototype\char`\"{} object. 



Definition at line 259 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!builtinEvalError@{builtinEvalError}}
\index{builtinEvalError@{builtinEvalError}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Interpreter::builtin\-Eval\-Error () const}\label{classKJS_1_1Interpreter_a28}


The initial value of \char`\"{}Error\char`\"{} global property. 



Definition at line 264 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!setCompatMode@{setCompatMode}}
\index{setCompatMode@{setCompatMode}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Interpreter::set\-Compat\-Mode (Compat\-Mode {\em mode})}\label{classKJS_1_1Interpreter_a40}


Call this to enable a compatibility mode with another browser. 

(by default konqueror is in \char`\"{}native mode\char`\"{}). Currently, in KJS, this only changes the behavior of Date::get\-Year() which returns the full year under IE. 

Definition at line 324 of file interpreter.cpp.\index{KJS::Interpreter@{KJS::Interpreter}!collect@{collect}}
\index{collect@{collect}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Interpreter::collect ()\hspace{0.3cm}{\tt  [static]}}\label{classKJS_1_1Interpreter_e2}


Run the garbage collection. 

Returns true when at least one object was collected; false otherwise. 

Definition at line 334 of file interpreter.cpp.

References KJS::Collector::collect().\index{KJS::Interpreter@{KJS::Interpreter}!mark@{mark}}
\index{mark@{mark}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual void KJS::Interpreter::mark ()\hspace{0.3cm}{\tt  [inline, virtual]}}\label{classKJS_1_1Interpreter_a42}


Called by Interpreter\-Imp during the mark phase of the garbage collector Default implementation does nothing, this exist for classes that reimplement {\bf Interpreter}{\rm (p.\,\pageref{classKJS_1_1Interpreter})}. 



Definition at line 398 of file interpreter.h.\index{KJS::Interpreter@{KJS::Interpreter}!rtti@{rtti}}
\index{rtti@{rtti}!KJS::Interpreter@{KJS::Interpreter}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual int KJS::Interpreter::rtti ()\hspace{0.3cm}{\tt  [inline, virtual]}}\label{classKJS_1_1Interpreter_a43}


Provides a way to distinguish derived classes. 

Only useful if you reimplement {\bf Interpreter}{\rm (p.\,\pageref{classKJS_1_1Interpreter})} 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.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
interpreter.h\item 
interpreter.cpp\end{CompactItemize}
