CXXR (C++ R) API
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
CXXR::Evaluator::Context Class Reference

Housekeeping information on R call stack. More...

#include <Evaluator_Context.hpp>

List of all members.

Public Types

enum  Type { BAILOUT = 0, PLAIN, FUNCTION, CLOSURE }
 Context types. More...

Public Member Functions

ContextnextOut () const
 Next Context out.
Type type () const
 Type of the Context.

Static Public Member Functions

static Contextinnermost ()
 The innermost Context.

Protected Member Functions

void setType (Type the_type)
 Set the type of the Context.

Detailed Description

Housekeeping information on R call stack.

Evaluator::Context objects must be declared on the processor stack (i.e. as C++ automatic variables).

This class (together with its derived classes) performs two functions:

  1. The primary function is to maintain an 'Ariadne's thread', recording information about the stack of R function calls currently active. This is to support error reporting, traceback, and the 'sys' R functions. As in CR, calls to 'special' BuiltInFunction objects (SPECIALSXP) are not recorded; however, unlike CR, calls to other BuiltInFunction objects (BUILTINSXP) are always recorded.

  2. Derived classes may also carry out a secondary function, namely to save and restore information about the evaluation state. Certain aspects of the state of the current Evaluator are saved by the derived class's constructor; the state is then restored by the class's destructor. Since Context objects are allocated on the processor stack, this means that the evaluation state will automatically be restored both under the normal flow of control and when the stack is unwound during the propagation of a C++ exception. (Beware however that some of the save/restore functionality that CR's RCNTXT offers is handled separately in CXXR via classes such as Browser; this trend of moving save/restore functionality out of classes derived from Evaluator::Context is likely to continue. Moreover, in cases where save/restore functions continue to be effected by classes inheriting from Evaluator::Context, this is in some cases achieved by incorporating within a Context object an object with more specific save/restore role, such as a ProtectStack::Scope object.


Member Enumeration Documentation

Context types.

Different Context types correspond to different derived classes. This base class contains a type field to allow Context types to be distinguished without the overhead of a dynamic_cast .

Enumerator:
BAILOUT 

Context understanding Bailout objects.

PLAIN 

Lightweight Context neutralising BailoutContext.

FUNCTION 

Context corresponding to a BuiltInFunction.

CLOSURE 

Context corresponding to a Closure.


Member Function Documentation

static Context* CXXR::Evaluator::Context::innermost ( )
inlinestatic

The innermost Context.

Returns:
Pointer to the innermost Context belonging to the current Evaluator.
Context* CXXR::Evaluator::Context::nextOut ( ) const
inline

Next Context out.

Returns:
pointer to the Context object most narrowly enclosing this Context, or a null pointer if this is the outermost Context of the current Evaluator.
void CXXR::Evaluator::Context::setType ( Type  the_type)
inlineprotected

Set the type of the Context.

Parameters:
the_typeThe desired Type of the Context.
Type CXXR::Evaluator::Context::type ( ) const
inline

Type of the Context.

Returns:
The Context's Type.

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