• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • KJS
  • Interpreter
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
KJS::Interpreter Class Reference

#include <interpreter.h>

Public Types

enum  CompatMode { NativeMode , IECompat , NetscapeCompat }
 

Public Member Functions

 Interpreter (const Object &global)
 
 Interpreter ()
 
Object & globalObject () const
 
void initGlobalObject ()
 
ExecState * globalExec ()
 
bool checkSyntax (const UString &code, int *errLine, UString *errMsg)
 
bool checkSyntax (const UString &code)
 
Completion evaluate (const UString &code, const Value &thisV=Value())
 
InterpreterImp * imp ()
 
Object builtinObject () const
 
Object builtinFunction () const
 
Object builtinArray () const
 
Object builtinBoolean () const
 
Object builtinString () const
 
Object builtinNumber () const
 
Object builtinDate () const
 
Object builtinRegExp () const
 
Object builtinError () const
 
Object builtinObjectPrototype () const
 
Object builtinFunctionPrototype () const
 
Object builtinArrayPrototype () const
 
Object builtinBooleanPrototype () const
 
Object builtinStringPrototype () const
 
Object builtinNumberPrototype () const
 
Object builtinDatePrototype () const
 
Object builtinRegExpPrototype () const
 
Object builtinErrorPrototype () const
 
Object builtinEvalError () const
 
Object builtinRangeError () const
 
Object builtinReferenceError () const
 
Object builtinSyntaxError () const
 
Object builtinTypeError () const
 
Object builtinURIError () const
 
Object builtinEvalErrorPrototype () const
 
Object builtinRangeErrorPrototype () const
 
Object builtinReferenceErrorPrototype () const
 
Object builtinSyntaxErrorPrototype () const
 
Object builtinTypeErrorPrototype () const
 
Object builtinURIErrorPrototype () const
 
void setCompatMode (CompatMode mode)
 
CompatMode compatMode () const
 
virtual void mark ()
 
virtual int rtti ()
 

Static Public Member Functions

static void lock ()
 
static void unlock ()
 
static bool collect ()
 

Protected Member Functions

virtual void virtual_hook (int id, void *data)
 

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 172 of file interpreter.h.

Member Enumeration Documentation

◆ CompatMode

enum KJS::Interpreter::CompatMode

Definition at line 377 of file interpreter.h.

Constructor & Destructor Documentation

◆ Interpreter() [1/2]

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
globalThe object to use as the global object for this interpreter

Definition at line 112 of file interpreter.cpp.

◆ Interpreter() [2/2]

Interpreter::Interpreter ( )

Creates a new interpreter.

A global object will be created and initialized with the standard global properties.

Definition at line 117 of file interpreter.cpp.

◆ ~Interpreter()

Interpreter::~Interpreter ( )
virtual

Definition at line 123 of file interpreter.cpp.

Member Function Documentation

◆ builtinArray()

Object Interpreter::builtinArray ( ) const

Returns the builtin "Array" object.

Definition at line 183 of file interpreter.cpp.

◆ builtinArrayPrototype()

Object Interpreter::builtinArrayPrototype ( ) const

Returns the builtin "Array.prototype" object.

Definition at line 228 of file interpreter.cpp.

◆ builtinBoolean()

Object Interpreter::builtinBoolean ( ) const

Returns the builtin "Boolean" object.

Definition at line 188 of file interpreter.cpp.

◆ builtinBooleanPrototype()

Object Interpreter::builtinBooleanPrototype ( ) const

Returns the builtin "Boolean.prototype" object.

Definition at line 233 of file interpreter.cpp.

◆ builtinDate()

Object Interpreter::builtinDate ( ) const

Returns the builtin "Date" object.

Definition at line 203 of file interpreter.cpp.

◆ builtinDatePrototype()

Object Interpreter::builtinDatePrototype ( ) const

Returns the builtin "Date.prototype" object.

Definition at line 248 of file interpreter.cpp.

◆ builtinError()

Object Interpreter::builtinError ( ) const

Returns the builtin "Error" object.

Definition at line 213 of file interpreter.cpp.

◆ builtinErrorPrototype()

Object Interpreter::builtinErrorPrototype ( ) const

Returns the builtin "Error.prototype" object.

Definition at line 258 of file interpreter.cpp.

◆ builtinEvalError()

Object Interpreter::builtinEvalError ( ) const

The initial value of "Error" global property.

Definition at line 263 of file interpreter.cpp.

◆ builtinEvalErrorPrototype()

Object Interpreter::builtinEvalErrorPrototype ( ) const

Definition at line 293 of file interpreter.cpp.

◆ builtinFunction()

Object Interpreter::builtinFunction ( ) const

Returns the builtin "Function" object.

Definition at line 178 of file interpreter.cpp.

◆ builtinFunctionPrototype()

Object Interpreter::builtinFunctionPrototype ( ) const

Returns the builtin "Function.prototype" object.

Definition at line 223 of file interpreter.cpp.

◆ builtinNumber()

Object Interpreter::builtinNumber ( ) const

Returns the builtin "Number" object.

Definition at line 198 of file interpreter.cpp.

◆ builtinNumberPrototype()

Object Interpreter::builtinNumberPrototype ( ) const

Returns the builtin "Number.prototype" object.

Definition at line 243 of file interpreter.cpp.

◆ builtinObject()

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 173 of file interpreter.cpp.

◆ builtinObjectPrototype()

Object Interpreter::builtinObjectPrototype ( ) const

Returns the builtin "Object.prototype" object.

Definition at line 218 of file interpreter.cpp.

◆ builtinRangeError()

Object Interpreter::builtinRangeError ( ) const

Definition at line 268 of file interpreter.cpp.

◆ builtinRangeErrorPrototype()

Object Interpreter::builtinRangeErrorPrototype ( ) const

Definition at line 298 of file interpreter.cpp.

◆ builtinReferenceError()

Object Interpreter::builtinReferenceError ( ) const

Definition at line 273 of file interpreter.cpp.

◆ builtinReferenceErrorPrototype()

Object Interpreter::builtinReferenceErrorPrototype ( ) const

Definition at line 303 of file interpreter.cpp.

◆ builtinRegExp()

Object Interpreter::builtinRegExp ( ) const

Returns the builtin "RegExp" object.

Definition at line 208 of file interpreter.cpp.

◆ builtinRegExpPrototype()

Object Interpreter::builtinRegExpPrototype ( ) const

Returns the builtin "RegExp.prototype" object.

Definition at line 253 of file interpreter.cpp.

◆ builtinString()

Object Interpreter::builtinString ( ) const

Returns the builtin "String" object.

Definition at line 193 of file interpreter.cpp.

◆ builtinStringPrototype()

Object Interpreter::builtinStringPrototype ( ) const

Returns the builtin "String.prototype" object.

Definition at line 238 of file interpreter.cpp.

◆ builtinSyntaxError()

Object Interpreter::builtinSyntaxError ( ) const

Definition at line 278 of file interpreter.cpp.

◆ builtinSyntaxErrorPrototype()

Object Interpreter::builtinSyntaxErrorPrototype ( ) const

Definition at line 308 of file interpreter.cpp.

◆ builtinTypeError()

Object Interpreter::builtinTypeError ( ) const

Definition at line 283 of file interpreter.cpp.

◆ builtinTypeErrorPrototype()

Object Interpreter::builtinTypeErrorPrototype ( ) const

Definition at line 313 of file interpreter.cpp.

◆ builtinURIError()

Object Interpreter::builtinURIError ( ) const

Definition at line 288 of file interpreter.cpp.

◆ builtinURIErrorPrototype()

Object Interpreter::builtinURIErrorPrototype ( ) const

Definition at line 318 of file interpreter.cpp.

◆ checkSyntax() [1/2]

bool Interpreter::checkSyntax ( const UString &  code)

Parses the supplied ECMAScript code and checks for syntax errors.

Parameters
codeThe code to check
Returns
true if there were no syntax errors in the code, otherwise false

Definition at line 158 of file interpreter.cpp.

◆ checkSyntax() [2/2]

bool Interpreter::checkSyntax ( const UString &  code,
int *  errLine,
UString *  errMsg 
)

Parses the supplied ECMAScript code and checks for syntax errors.

Parameters
codeThe code to check
errLineReturns the line the error was on (if there was one).
errMsgReturns the error message (if there was one).
Returns
true if there were no syntax errors in the code, otherwise false

Definition at line 153 of file interpreter.cpp.

◆ collect()

bool Interpreter::collect ( )
static

Run the garbage collection.

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

Definition at line 333 of file interpreter.cpp.

◆ compatMode()

Interpreter::CompatMode Interpreter::compatMode ( ) const

Definition at line 328 of file interpreter.cpp.

◆ evaluate()

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
codeThe code to evaluate
thisVThe 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 163 of file interpreter.cpp.

◆ globalExec()

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 148 of file interpreter.cpp.

◆ globalObject()

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 128 of file interpreter.cpp.

◆ imp()

InterpreterImp * Interpreter::imp ( )

Definition at line 168 of file interpreter.cpp.

◆ initGlobalObject()

void Interpreter::initGlobalObject ( )

Definition at line 133 of file interpreter.cpp.

◆ lock()

void Interpreter::lock ( )
static

Definition at line 138 of file interpreter.cpp.

◆ mark()

virtual void KJS::Interpreter::mark ( )
inlinevirtual

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 397 of file interpreter.h.

◆ rtti()

virtual int KJS::Interpreter::rtti ( )
inlinevirtual

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 405 of file interpreter.h.

◆ setCompatMode()

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 323 of file interpreter.cpp.

◆ unlock()

void Interpreter::unlock ( )
static

Definition at line 143 of file interpreter.cpp.

◆ virtual_hook()

void Interpreter::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Definition at line 390 of file interpreter.cpp.


The documentation for this class was generated from the following files:
  • interpreter.h
  • interpreter.cpp

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.