CXXR (C++ R) API
Classes | Public Member Functions | Static Public Member Functions | Friends
CXXR::Evaluator Class Reference

Framework for R command evaluation. More...

#include <Evaluator.h>

List of all members.

Classes

class  Context
 Housekeeping information on R call stack. More...

Public Member Functions

ContextinnermostContext () const
 Innermost Context belonging to this Evaluator.

Static Public Member Functions

static Evaluatorcurrent ()
 The current Evaluator.
static unsigned int depth ()
 (Not for general use.)
static unsigned int depthLimit ()
 Maximum depth of R expression nesting.
static void enableExtraDepth (bool on)
 (Not for general use.)
static void enableProfiling (bool on)
 (Not for general use.)
static void enableResultPrinting (bool on)
 Specify whether the result of top-level expression be printed.
static RObjectevaluate (RObject *object, Environment *env)
 Evaluate RObject in a specified Environment.
static bool profiling ()
 Is profiling currently enabled?
static bool resultPrinted ()
 Is the result of top-level expression evaluation printed?
static void setDepth (unsigned int depth)
 (Not for general use.)
static void setDepthLimit (int depth)
 Set maximum depth of R expression nesting.

Friends

class Context

Detailed Description

Framework for R command evaluation.

An object of this class provides a framework within which evaluation of R commands (i.e. top-level R expressions) takes place, and provides various housekeeping services to control and support that evaluation. Evaluator objects conceptually form a stack, so they must be destroyed in the reverse order of creation: it is therefore recommended that they always be declared on the processor stack, i.e. as C++ automatic variables. The Evaluator at the top of the stack is the current Evaluator.

If an error occurs during R expression evaluation, the resulting exception is caught within the scope of the current Evaluator; the relevant code will then typically request another R command (if interactive), or terminate the scope of the current Evaluator, thus popping it off the Evaluator stack, and return control to code within the scope of the next Evaluator down.

Each Evaluator object contains a nested sequence of zero or more Contexts. A newly created Context is added to the sequence belonging to the current Evaluator. It is therefore an error to declare a Context object outside the scope of any Evaluator object.

Note:
Evaluator objects fulfil many of the roles of TOPLEVEL contexts within CR (which do not exist within CXXR). Note that in CXXR, each Evaluator has its own singly-linked list of Context objects (starting with the innermost); there is no overall list of Context objects spanning different Evaluator objects.

Member Function Documentation

static Evaluator* CXXR::Evaluator::current ( )
inlinestatic

The current Evaluator.

Returns:
Pointer to the current (innermost) Evaluator.
static unsigned int CXXR::Evaluator::depth ( )
inlinestatic

(Not for general use.)

Used in context.cpp to save the evaluation depth associated with an RCNTXT. Also used in do_Cstack_info() in platform.cpp.

Returns:
The current evaluation depth.
static unsigned int CXXR::Evaluator::depthLimit ( )
inlinestatic

Maximum depth of R expression nesting.

Returns:
The current maximum nesting depth (disregarding any extra depth that may have been introduced by extraDepth() ).
static void CXXR::Evaluator::enableExtraDepth ( bool  on)
inlinestatic

(Not for general use.)

Parameters:
onIf true, and extra depth is not already enabled, an increase is applied to the permissible depth of nested evaluations to allow error reporting to be carried out. If false, any such extra depth currently in force is removed.
static void CXXR::Evaluator::enableProfiling ( bool  on)
inlinestatic

(Not for general use.)

This function is for use by the profiling code in eval.cpp to record whether profiling is currently enabled.

Parameters:
ontrue iff printing is required.
static void CXXR::Evaluator::enableResultPrinting ( bool  on)
inlinestatic

Specify whether the result of top-level expression be printed.

Parameters:
ontrue iff printing is required.
static RObject* CXXR::Evaluator::evaluate ( RObject object,
Environment env 
)
static

Evaluate RObject in a specified Environment.

For most types of RObject, this simply returns a pointer to the RObject itself.

Parameters:
objectPointer to the RObject to be evaluated. May be null, in which case the function returns a null pointer.
envPointer to the environment in which evaluation is to take place. May be null only if object is null.
Returns:
Pointer to the result of evaluation.
Context* CXXR::Evaluator::innermostContext ( ) const
inline

Innermost Context belonging to this Evaluator.

Returns:
Pointer to the innermost Context belonging to this Evaluator.
static bool CXXR::Evaluator::profiling ( )
inlinestatic

Is profiling currently enabled?

Returns:
true iff profiling is currently in progress.
static bool CXXR::Evaluator::resultPrinted ( )
inlinestatic

Is the result of top-level expression evaluation printed?

Returns:
true iff it is currently specified that the result of a top-level R expression evaluation should be printed.
static void CXXR::Evaluator::setDepth ( unsigned int  depth)
inlinestatic

(Not for general use.)

Used in context.cpp to restore the evaluation depth associated with an RCNTXT. Also used in main.cpp to reset the evaluation depth to zero.

Parameters:
depthThe required depth.
static void CXXR::Evaluator::setDepthLimit ( int  depth)
static

Set maximum depth of R expression nesting.

Parameters:
depthThe required maximum nesting depth. If the supplied value lies outside the permissible range, an error is reported and the nesting depth is left unchanged.

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