CXXR (C++ R) API
|
Representation of a binding of a Symbol to an RObject. More...
#include <Frame.hpp>
Public Types | |
enum | Origin { EXPLICIT = 0, MISSING, DEFAULTED } |
How the binding arrived at its current setting. More... |
Public Member Functions | |
Binding () | |
Default constructor. | |
PairList * | asPairList (PairList *tail=0) const |
Represent this Binding as a PairList element. | |
void | assign (RObject *new_value, Origin origin=EXPLICIT) |
Bind value to Symbol. | |
std::pair< RObject *, bool > | forcedValue () |
Look up bound value, forcing Promises if necessary. | |
const Frame * | frame () const |
Get pointer to Frame. | |
void | fromPairList (PairList *pl) |
Get binding information from a PairList element. | |
void | initialize (Frame *frame, const Symbol *sym) |
Initialize the Binding. | |
bool | isActive () const |
Is this an active Binding? | |
bool | isLocked () const |
Is this Binding locked? | |
Origin | origin () const |
Origin of this Binding. | |
RObject * | rawValue () const |
Get raw value bound to the Symbol. | |
void | setFunction (FunctionBase *function, Origin origin=EXPLICIT) |
Sets this to be an active Binding encapsulating a specified function. | |
void | setLocking (bool on) |
Lock/unlock this Binding. | |
void | setValue (RObject *new_value, Origin origin=EXPLICIT, bool quiet=false) |
Define the object to which this Binding's Symbol is bound. | |
const Symbol * | symbol () const |
Bound symbol. | |
RObject * | value () const |
Get value bound to the Symbol. | |
void | visitReferents (const_visitor *v) const |
Auxiliary function to Frame::visitReferents(). |
Friends | |
class | boost::serialization::access |
Representation of a binding of a Symbol to an RObject.
A binding may be identified as 'active', in which case it encapsulates a function (i.e. an object of type FunctionBase). The value of the binding, as returned by value(), is then determined by evaluating this function with no arguments. Setting the value of the binding, by calling assign(), simply invokes that same function with the supplied value as its single argument: the encapsulated function is not altered.
How the binding arrived at its current setting.
EXPLICIT |
The Binding was specified explicitly, e.g. by supplying an actual argument to a function, or by direct assignment into the relevant Environment. |
MISSING |
The Binding corresponds to a formal argument of a function, for which no actual value was supplied, and which has no default value. This is the default for newly created Binding objects. |
DEFAULTED |
The Binding represents the default value of the formal argument of a function call, no actual argument having been supplied. |
|
inline |
Default constructor.
initialize() must be called before the Binding object can be used.
Represent this Binding as a PairList element.
This function creates a new PairList element which represents the information in the Binding in the form returned by CR's FRAME() function.
If the Binding is active, then the 'car' of the created PairList element will contain a pointer to the encapsulated function.
tail | Value to be set as the tail (CDR) of the created PairList element. |
Bind value to Symbol.
In the case of non-active bindings, this function has exactly the same effect as setValue(): it changes the value to which this Binding's symbol is bound to new_value.
For active bindings, it invokes the encapsulated function with new_value as its sole argument.
Raises an error if the Binding is locked.
new_value | Pointer (possibly null) to the new value. See function description. |
origin | Origin of the newly-assigned value. |
std::pair<RObject*, bool> CXXR::Frame::Binding::forcedValue | ( | ) |
Look up bound value, forcing Promises if necessary.
If the value of this Binding is anything other than a Promise, this function returns a pointer to that bound value. However, if the value is a Promise, the function forces the Promise if necessary, and returns a pointer to the value of the Promise.
|
inline |
void CXXR::Frame::Binding::fromPairList | ( | PairList * | pl | ) |
Get binding information from a PairList element.
This function sets the value of this Binding, and its active, locked and missing status, from the corresponding fields of a PairList element.
If the PairList element defines the Binding as active, then its 'car' is considered to contain a pointer to the active binding function.
Raises an error if the Binding is locked.
|
inline |
|
inline |
|
inline |
|
inline |
void CXXR::Frame::Binding::setFunction | ( | FunctionBase * | function, |
Origin | origin = EXPLICIT |
||
) |
Sets this to be an active Binding encapsulating a specified function.
When invoked for an existing active Binding, this function simply replaces the encapsulated function.
Raises an error if the Binding is locked.
Also raises an error if the Binding is not currently marked active but has a non-null value. (This is slightly less strict than CR, which only allows active status to be set on a newly created binding.)
function | The function used to implement the active binding. |
origin | Origin now to be associated with this Binding. |
|
inline |
|
inline |
RObject* CXXR::Frame::Binding::value | ( | ) | const |
void CXXR::Frame::Binding::visitReferents | ( | const_visitor * | v | ) | const |
Auxiliary function to Frame::visitReferents().
This function conducts a visitor to those objects derived from GCNode which become 'children' of this Binding's Frame as a result of its containing this Binding.
v | Pointer to the visitor object. |