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:
-
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.
-
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.