KJS::Context Class Reference

`#include <interpreter.h>`

## Public Member Functions

| Context (ContextImp *i)
ContextImp * | imp () const
const ScopeChain & | scopeChain () const
Object | variableObject () const
Object | thisValue () const
const Context | callingContext () const
CodeType | codeType () const
int | sourceId () const
int | curStmtFirstLine () const
int | curStmtLastLine () const
Object | function () const
Identifier | functionName () const
List | args () const

## Detailed Description

Represents an execution context, as specified by section 10 of the ECMA spec.

An execution context contains information about the current state of the script - the scope for variable lookup, the value of "this", etc. A new execution context is entered whenever global code is executed (e.g. with Interpreter::evaluate()), a function is called (see Object::call()), or the builtin "eval" function is executed.

Most inheritable functions in the KJS api take a ExecState pointer as their first parameter. This can be used to obtain a handle to the current execution context.

Note: Context objects are wrapper classes/smart pointers for the internal KJS ContextImp type. When one context variable is assigned to another, it is still referencing the same internal object.

Definition at line 73 of file interpreter.h.

## Member Function Documentation

List Context::args | ( |  | ) | const

In the case of FunctionCode, the arguments passed to the function.

Definition at line 96 of file interpreter.cpp.

const Context Context::callingContext | ( |  | ) | const

Returns the context from which the current context was invoked.

For global code this will be a null context (i.e. one for which isNull() returns true). You should check isNull() on the returned value before calling any of it's methods.

Returns
  The calling execution context

Definition at line 61 of file interpreter.cpp.

CodeType Context::codeType | ( |  | ) | const

The type of code being executed in this context.

One of GlobalCode, EvalCode or FunctionCode

Definition at line 66 of file interpreter.cpp.

int Context::curStmtFirstLine | ( |  | ) | const

The line number on which the current statement begins.

Definition at line 76 of file interpreter.cpp.

int Context::curStmtLastLine | ( |  | ) | const

The line number on which the current statement ends.

Definition at line 81 of file interpreter.cpp.

Object Context::function | ( |  | ) | const

In the case of FunctionCode, the function objects being called.

Definition at line 86 of file interpreter.cpp.

Identifier Context::functionName | ( |  | ) | const

In the case of FunctionCode, the name of the function being called.

Definition at line 91 of file interpreter.cpp.

const ScopeChain & Context::scopeChain | ( |  | ) | const

Returns the scope chain for this execution context.

This is used for variable lookup, with the list being searched from start to end until a variable is found.

Returns
  The execution context's scope chain

Definition at line 46 of file interpreter.cpp.

int Context::sourceId | ( |  | ) | const

The identifier of the source code fragment containing the code being executed.

Definition at line 71 of file interpreter.cpp.

Object Context::thisValue | ( |  | ) | const

Returns the "this" value for the execution context.

This is the value returned when a script references the special variable "this". It should always be an Object, unless application-specific code has passed in a different type.

The object that is used as the "this" value depends on the type of execution context - for global contexts, the global object is used. For function objewcts, the value is given by the caller (e.g. in the case of obj.func(), obj would be the "this" value). For code executed by the built-in "eval" function, the this value is the same as the calling context.

Returns
  The execution context's "this" value

Definition at line 56 of file interpreter.cpp.

Object Context::variableObject | ( |  | ) | const

Returns the variable object for the execution context.

This contains a property for each variable declared in the execution context.

Returns
  The execution context's variable object

Definition at line 51 of file interpreter.cpp.

The documentation for this class was generated from the following files:

- interpreter.h
- interpreter.cpp

KDE Home | KDE Accessibility Home | Description of Access Keys