kjs Library API Documentation

KJS Namespace Reference


Classes

class  ArrayInstanceImp
class  ArrayPrototypeImp
class  ArrayProtoFuncImp
class  ArrayObjectImp
class  BooleanInstanceImp
class  BooleanPrototypeImp
class  BooleanProtoFuncImp
class  BooleanObjectImp
class  Collector
 Garbage collector. More...
class  Completion
 Completion objects are used to convey the return status and value from functions.Handle for a Completion type. More...
class  ContextImp
 Execution context. More...
class  DateInstanceImp
class  DatePrototypeImp
class  DateProtoFuncImp
class  DateObjectImp
class  DateObjectFuncImp
class  Debugger
class  ErrorInstanceImp
class  ErrorPrototypeImp
class  ErrorProtoFuncImp
class  ErrorObjectImp
class  NativeErrorPrototypeImp
class  NativeErrorImp
class  InternalFunctionImp
 Base class for all function objects. More...
class  FunctionPrototypeImp
 The initial value of Function.prototype (and thus all objects created with the Function constructor). More...
class  FunctionProtoFuncImp
class  FunctionObjectImp
class  Identifier
 Represents an Identifier for a Javascript object. More...
class  UndefinedImp
class  NullImp
class  BooleanImp
class  StringImp
class  NumberImp
class  LabelStack
 The "label set" in Ecma-262 spec. More...
class  SourceCode
class  Parser
class  InterpreterImp
class  DebuggerImp
class  FunctionImp
 Implementation class for functions implemented in JS. More...
class  DeclaredFunctionImp
class  ArgumentsImp
class  ActivationImp
class  GlobalFuncImp
class  Context
 Represents an execution context, as specified by section 10 of the ECMA spec. More...
class  Interpreter
 Interpreter objects can be used to evaluate ECMAScript code. More...
class  ExecState
 Represents the current state of script execution. More...
class  Lexer
struct  ListImpBase
class  List
 Native list type. More...
class  ListIterator
 Iterator for KJS::List objects. More...
struct  HashEntry
 An entry in a hash table. More...
struct  HashTable
 A hash table Usually the hashtable is generated by the create_hash_table script, from a .table file. More...
class  Lookup
 Fast keyword lookup. More...
class  MathObjectImp
class  MathFuncImp
class  Node
class  StatementNode
class  NullNode
class  BooleanNode
class  NumberNode
class  StringNode
class  RegExpNode
class  ThisNode
class  ResolveNode
class  GroupNode
class  ElementNode
class  ArrayNode
class  PropertyValueNode
class  PropertyNode
class  ObjectLiteralNode
class  AccessorNode1
class  AccessorNode2
class  ArgumentListNode
class  ArgumentsNode
class  NewExprNode
class  FunctionCallNode
class  PostfixNode
class  DeleteNode
class  VoidNode
class  TypeOfNode
class  PrefixNode
class  UnaryPlusNode
class  NegateNode
class  BitwiseNotNode
class  LogicalNotNode
class  MultNode
class  AddNode
class  AppendStringNode
class  ShiftNode
class  RelationalNode
class  EqualNode
class  BitOperNode
class  BinaryLogicalNode
 expr1 && expr2, expr1 || expr2 More...
class  ConditionalNode
 The ternary operator, "logical ? expr1 : expr2". More...
class  AssignNode
class  CommaNode
class  StatListNode
class  AssignExprNode
class  VarDeclNode
class  VarDeclListNode
class  VarStatementNode
class  BlockNode
class  EmptyStatementNode
class  ExprStatementNode
class  IfNode
class  DoWhileNode
class  WhileNode
class  ForNode
class  ForInNode
class  ContinueNode
class  BreakNode
class  ReturnNode
class  WithNode
class  CaseClauseNode
class  ClauseListNode
class  CaseBlockNode
class  SwitchNode
class  LabelNode
class  ThrowNode
class  CatchNode
class  FinallyNode
class  TryNode
class  ParameterNode
class  FunctionBodyNode
class  FuncDeclNode
class  FuncExprNode
class  SourceElementsNode
class  NumberInstanceImp
class  NumberPrototypeImp
class  NumberProtoFuncImp
class  NumberObjectImp
struct  ClassInfo
 Class Information. More...
class  Object
 Represents an Object. More...
class  ObjectImp
class  Error
 Factory methods for error objects. More...
class  ObjectPrototypeImp
class  ObjectProtoFuncImp
class  ObjectObjectImp
class  SavedProperties
 Saved Properties. More...
struct  PropertyMapHashTableEntry
 A hashtable entry for the PropertyMap. More...
class  PropertyMap
 Javascript Property Map. More...
class  Reference
 Defines a Javascript reference. More...
class  ReferenceListIterator
 An iterator for a ReferenceList. More...
class  ReferenceList
 A list of Reference objects. More...
class  RegExp
class  RegExpPrototypeImp
class  RegExpProtoFuncImp
class  RegExpImp
class  RegExpObjectImp
class  ScopeChainNode
 A scope chain node. More...
class  ScopeChain
 A scope chain object. More...
class  SimpleNumber
class  StringInstanceImp
class  StringPrototypeImp
class  StringProtoFuncImp
class  StringObjectImp
class  StringObjectFuncImp
struct  UChar
 Unicode character. More...
class  UCharReference
 Dynamic reference to a string character. More...
class  CString
 8 bit char based string class More...
class  UString
 Unicode string class. More...
class  ValueImp
 ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects in ECMAScript. More...
class  Value
 Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents. More...
class  Undefined
 Represents an primitive Undefined value. More...
class  Null
 Represents an primitive Null value. More...
class  Boolean
 Represents an primitive Boolean value. More...
class  String
 Represents an primitive String value. More...
class  Number
 Represents an primitive Number value. More...

Enumerations

enum  ComplType {
  Normal, Break, Continue, ReturnValue,
  Throw
}
enum  CodeType { GlobalCode = 0, EvalCode = 1, FunctionCode = 2 }
enum  ListImpState { unusedInPool = 0, usedInPool, usedOnHeap, immortal }
enum  Operator {
  OpEqual, OpEqEq, OpNotEq, OpStrEq,
  OpStrNEq, OpPlusEq, OpMinusEq, OpMultEq,
  OpDivEq, OpPlusPlus, OpMinusMinus, OpLess,
  OpLessEq, OpGreater, OpGreaterEq, OpAndEq,
  OpXOrEq, OpOrEq, OpModEq, OpAnd,
  OpOr, OpBitAnd, OpBitXOr, OpBitOr,
  OpLShift, OpRShift, OpURShift, OpIn,
  OpInstanceOf
}
enum  Attribute {
  None = 0, ReadOnly = 1 << 1, DontEnum = 1 << 2, DontDelete = 1 << 3,
  Internal = 1 << 4, Function = 1 << 5
}
enum  ErrorType {
  GeneralError = 0, EvalError = 1, RangeError = 2, ReferenceError = 3,
  SyntaxError = 4, TypeError = 5, URIError = 6
}
enum  Type {
  UnspecifiedType = 0, UndefinedType = 1, NullType = 2, BooleanType = 3,
  StringType = 4, NumberType = 5, ObjectType = 6
}

Functions

double parseDate (const UString &u)
double makeTime (struct tm *t, double ms, bool utc)
double KRFCDate_parseDate (const UString &_date)
double timeClip (double t)
bool operator== (const Identifier &a, const Identifier &b)
bool operator!= (const Identifier &a, const Identifier &b)
bool operator== (const Identifier &a, const char *b)
double roundValue (ExecState *exec, const Value &v)
void printInfo (ExecState *exec, const char *s, const Value &o, int lineno)
bool operator== (const Context &c1, const Context &c2)
bool operator!= (const Context &c1, const Context &c2)
static ListImp * allocateListImp ()
static void deallocateListImp (ListImp *imp)
template<class FuncImp>
Value lookupOrCreateFunction (ExecState *exec, const Identifier &propertyName, const ObjectImp *thisObj, int token, int params, int attr)
template<class FuncImp, class ThisImp, class ParentImp>
Value lookupGet (ExecState *exec, const Identifier &propertyName, const HashTable *table, const ThisImp *thisObj)
template<class FuncImp, class ParentImp>
Value lookupGetFunction (ExecState *exec, const Identifier &propertyName, const HashTable *table, const ObjectImp *thisObj)
template<class ThisImp, class ParentImp>
Value lookupGetValue (ExecState *exec, const Identifier &propertyName, const HashTable *table, const ThisImp *thisObj)
template<class ThisImp, class ParentImp>
void lookupPut (ExecState *exec, const Identifier &propertyName, const Value &value, int attr, const HashTable *table, ThisImp *thisObj)
template<class ClassCtor>
KJS::Object cacheGlobalObject (ExecState *exec, const Identifier &propertyName)
bool isNaN (double d)
bool isInf (double d)
bool isPosInf (double d)
bool isNegInf (double d)
bool equal (ExecState *exec, const Value &v1, const Value &v2)
bool strictEqual (ExecState *exec, const Value &v1, const Value &v2)
int relation (ExecState *exec, const Value &v1, const Value &v2)
int maxInt (int d1, int d2)
int minInt (int d1, int d2)
Value add (ExecState *exec, const Value &v1, const Value &v2, char oper)
Value mult (ExecState *exec, const Value &v1, const Value &v2, char oper)
bool operator== (const KJS::CString &c1, const KJS::CString &c2)
bool operator== (const UString &s1, const UString &s2)
bool operator== (const UString &s1, const char *s2)
bool operator< (const UString &s1, const UString &s2)
int compare (const UString &s1, const UString &s2)
KJS_EXPORT bool operator== (const UChar &c1, const UChar &c2)
KJS_EXPORT bool operator!= (const UChar &c1, const UChar &c2)
bool operator!= (const UString &s1, const UString &s2)
KJS_EXPORT bool operator!= (const UString &s1, const char *s2)
KJS_EXPORT bool operator== (const char *s1, const UString &s2)
KJS_EXPORT bool operator!= (const char *s1, const UString &s2)
KJS_EXPORT bool operator!= (const CString &s1, const CString &s2)
KJS_EXPORT UString operator+ (const UString &s1, const UString &s2)

Variables

const int MINIMUM_CELL_SIZE = 56
const int BLOCK_SIZE = (8 * 4096)
const int SPARE_EMPTY_BLOCKS = 2
const int MIN_ARRAY_SIZE = 14
const int GROWTH_FACTOR = 2
const int LOW_WATER_FACTOR = 4
const int ALLOCATIONS_PER_COLLECTION = 1000
const int CELL_ARRAY_LENGTH = (MINIMUM_CELL_SIZE / sizeof(double)) + (MINIMUM_CELL_SIZE % sizeof(double) != 0 ? sizeof(double) : 0)
const int CELL_SIZE = CELL_ARRAY_LENGTH * sizeof(double)
const int CELLS_PER_BLOCK = ((BLOCK_SIZE * 8 - sizeof(int) * 8 - sizeof(void *) * 8) / (CELL_SIZE * 8))
static CollectorHeap heap = {NULL, 0, 0, 0, NULL, 0, 0, 0, 0}
const Identifier argumentsPropertyName ("arguments")
const Identifier calleePropertyName ("callee")
const Identifier constructorPropertyName ("constructor")
const Identifier lengthPropertyName ("length")
const Identifier messagePropertyName ("message")
const Identifier namePropertyName ("name")
const Identifier prototypePropertyName ("prototype")
const Identifier specialPrototypePropertyName ("__proto__")
const Identifier toLocaleStringPropertyName ("toLocaleString")
const Identifier toStringPropertyName ("toString")
const Identifier valueOfPropertyName ("valueOf")
static const int _minTableSize = 64
static const kjs_double_t NaN_Bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } }
static const kjs_double_t Inf_Bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }
const double NaN = NaN_Bytes.d
const double Inf = Inf_Bytes.d
static const double D16 = 65536.0
static const double D32 = 4294967296.0
const int poolSize = 32
const int inlineValuesSize = 4
const int poolSizeMask = poolSize - 1
static ListImp pool [poolSize]
static int poolCursor
KJS_EXPORT KJS::UChar KJS_PACKED


Enumeration Type Documentation

enum KJS::ComplType
 

Completion types.

Definition at line 36 of file completion.h.

enum KJS::CodeType
 

The three different types of code that can be executed in a Context.

These are:

  • GlobalCode - code executed as a result of a call to Interpreter::evaluate().
  • EvalCode - executed by a call to the builtin eval() function
  • FunctionCode - inside a function call (ECMAScript functions only; does not include builtin native functions or funcitons supplied by the host environment

Definition at line 49 of file interpreter.h.

enum KJS::ErrorType
 

Types of Native Errors available.

For custom errors, GeneralError should be used.

Definition at line 614 of file object.h.

enum KJS::Type
 

Primitive types.

Definition at line 62 of file value.h.


Function Documentation

template<class FuncImp, class ThisImp, class ParentImp>
Value KJS::lookupGet ExecState *  exec,
const Identifier &  propertyName,
const HashTable *  table,
const ThisImp *  thisObj
[inline]
 

Helper method for property lookups.

This method does it all (looking in the hashtable, checking for function overrides, creating the function or retrieving from cache, calling getValueProperty in case of a non-function property, forwarding to parent if unknown property).

Template arguments:

Parameters:
FuncImp the class which implements this object's functions
ThisImp the class of "this". It must implement the getValueProperty(exec,token) method, for non-function properties.
ParentImp the class of the parent, to propagate the lookup.
Method arguments:
Parameters:
exec execution state, as usual
propertyName the property we're looking for
table the static hashtable for this class
thisObj "this"

Definition at line 175 of file lookup.h.

References KJS::HashEntry::attr, KJS::Lookup::findEntry(), KJS::HashEntry::params, and KJS::HashEntry::value.

template<class FuncImp, class ParentImp>
Value KJS::lookupGetFunction ExecState *  exec,
const Identifier &  propertyName,
const HashTable *  table,
const ObjectImp *  thisObj
[inline]
 

Simplified version of lookupGet in case there are only functions.

Using this instead of lookupGet prevents 'this' from implementing a dummy getValueProperty.

Definition at line 194 of file lookup.h.

References KJS::HashEntry::attr, KJS::Lookup::findEntry(), KJS::HashEntry::params, and KJS::HashEntry::value.

template<class ThisImp, class ParentImp>
Value KJS::lookupGetValue ExecState *  exec,
const Identifier &  propertyName,
const HashTable *  table,
const ThisImp *  thisObj
[inline]
 

Simplified version of lookupGet in case there are no functions, only "values".

Using this instead of lookupGet removes the need for a FuncImp class.

Definition at line 214 of file lookup.h.

References KJS::Identifier::ascii(), KJS::HashEntry::attr, KJS::Lookup::findEntry(), and KJS::HashEntry::value.

template<class ThisImp, class ParentImp>
void KJS::lookupPut ExecState *  exec,
const Identifier &  propertyName,
const Value &  value,
int  attr,
const HashTable *  table,
ThisImp *  thisObj
[inline]
 

This one is for "put".

Lookup hash entry for property to be set, and set the value.

Definition at line 232 of file lookup.h.

References KJS::Identifier::ascii(), KJS::HashEntry::attr, KJS::Lookup::findEntry(), and KJS::HashEntry::value.

template<class ClassCtor>
KJS::Object KJS::cacheGlobalObject ExecState *  exec,
const Identifier &  propertyName
[inline]
 

This template method retrieves or create an object that is unique (for a given interpreter) The first time this is called (for a given property name), the Object will be constructed, and set as a property of the interpreter's global object.

Later calls will simply retrieve that cached object. Note that the object constructor must take 1 argument, exec.

Definition at line 261 of file lookup.h.

References KJS::Object::dynamicCast(), KJS::Interpreter::globalObject(), KJS::Object::imp(), and KJS::ExecState::interpreter().

bool KJS::isNaN double  d  ) 
 

Returns:
True if d is not a number (platform support required).

Definition at line 56 of file operations.cpp.

Referenced by KJS::StringProtoFuncImp::call(), KJS::NumberProtoFuncImp::call(), KJS::MathFuncImp::call(), KJS::GlobalFuncImp::call(), KJS::DateObjectFuncImp::call(), KJS::DateProtoFuncImp::call(), KJS::DateObjectImp::construct(), KJS::NumberImp::create(), equal(), relation(), roundValue(), strictEqual(), KJS::NumberNode::toBoolean(), KJS::NumberImp::toBoolean(), KJS::ValueImp::toInt32(), KJS::ValueImp::toUInt32(), KJS::UString::toUInt32(), and KJS::UString::toULong().

bool KJS::isInf double  d  ) 
 

Returns:
True if d is infinite (platform support required).

Definition at line 67 of file operations.cpp.

Referenced by KJS::NumberProtoFuncImp::call(), KJS::GlobalFuncImp::call(), KJS::Number::isInf(), roundValue(), timeClip(), KJS::ValueImp::toInt32(), KJS::ValueImp::toInteger(), and KJS::ValueImp::toUInt32().

int KJS::relation ExecState exec,
const Value v1,
const Value v2
 

This operator performs an abstract relational comparison of the two arguments that can be of arbitrary type.

If possible, conversions to the string or number type will take place before the comparison.

Returns:
1 if v1 is "less-than" v2, 0 if the relation is "greater-than-or- equal". -1 if the result is undefined.

Definition at line 189 of file operations.cpp.

References isNaN(), isNegInf(), isPosInf(), KJS::Value::toNumber(), KJS::Value::toPrimitive(), KJS::Value::toString(), and KJS::Value::type().

Referenced by KJS::RelationalNode::evaluate().

Value KJS::add ExecState exec,
const Value v1,
const Value v2,
char  oper
 

Additive operator.

Either performs an addition or substraction of v1 and v2.

Parameters:
oper '+' or '-' for an addition or substraction, respectively.
Returns:
The result of the operation.

Definition at line 226 of file operations.cpp.

References KJS::Value::toNumber(), KJS::Value::toPrimitive(), KJS::Value::toString(), and KJS::Value::type().

Referenced by KJS::AssignNode::evaluate(), and KJS::AddNode::evaluate().

Value KJS::mult ExecState exec,
const Value v1,
const Value v2,
char  oper
 

Multiplicative operator.

Either multiplies/divides v1 and v2 or calculates the remainder from an division.

Parameters:
oper '*', '/' or '' for a multiplication, division or modulo operation.
Returns:
The result of the operation.

Definition at line 250 of file operations.cpp.

References KJS::Value::toNumber().

Referenced by KJS::AssignNode::evaluate(), and KJS::MultNode::evaluate().


Variable Documentation

struct KJS_EXPORT KJS::UChar KJS::KJS_PACKED
 

Unicode character.

UChar represents a 16 bit Unicode character. It's internal data representation is compatible to XChar2b and QChar. It's therefore possible to exchange data with X and Qt with shallow copies.

KDE Logo
This file is part of the documentation for kjs Library Version 3.4.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 9 07:58:01 2005 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003