Public Member Functions |
| Closure (const PairList *formal_args, RObject *body, Environment *env=Environment::global()) |
| Closure (const Closure &pattern) |
| Copy constructor.
|
const RObject * | body () const |
| Access the body of the Closure.
|
bool | debugging () const |
| Is debugging enabled?
|
Environment * | environment () const |
| Access the environment of the Closure.
|
RObject * | execute (Environment *env) const |
| Evaluate the Closure's body in a given environment.
|
RObject * | invoke (Environment *env, const ArgList *arglist, const Expression *call, const Frame *method_bindings=0) const |
| Invoke the function.
|
const ArgMatcher * | matcher () const |
| Access the ArgMatcher of this Closure.
|
void | setDebugging (bool on) |
| Set debugging status.
|
void | setEnvironment (Environment *new_env) |
| Replace the environment of the closure.
|
void | stripFormals (Frame *input_frame) const |
| Strip formal argument bindings from a Frame.
|
RObject * | apply (ArgList *arglist, Environment *env, const Expression *call) const |
| Apply the function.
|
Closure * | clone () const |
| Return pointer to a copy of this object.
|
const char * | typeName () const |
| Name within R of this type of object.
|
void | visitReferents (const_visitor *v) const |
| Conduct a visitor to the nodes referred to by this one.
|
void | maybeTrace (const Expression *call) const |
| Produce a tracing report if appropriate.
|
void | setTracing (bool on) |
| Set tracing status.
|
bool | traced () const |
| Is this function being traced?
|
virtual const PairList * | attributes () const |
| Get object attributes.
|
virtual void | clearAttributes () |
| Remove all attributes.
|
void | copyAttribute (const Symbol *name, const RObject *source) |
| Copy an attribute from one RObject to another.
|
void | copyAttributes (const RObject *source, bool copyS4) |
| Copy attributes from one RObject to another.
|
virtual RObject * | evaluate (Environment *env) |
| Evaluate object in a specified Environment.
|
virtual RObject * | getAttribute (const Symbol *name) const |
| Get the value a particular attribute.
|
virtual bool | hasAttributes () const |
| Has this object any attributes?
|
bool | hasClass () const |
| Has this object the class attribute?
|
bool | isS4Object () const |
| Is this an S4 object?
|
void | maybeTraceMemory (const RObject *src) |
| Carry out memory tracing.
|
void | maybeTraceMemory (const RObject *src1, const RObject *src2) |
| Carry out memory tracing.
|
void | maybeTraceMemory (const RObject *src1, const RObject *src2, const RObject *src3) |
| Carry out memory tracing.
|
bool | memoryTraced () const |
| Is copying etc. of this object being traced?
|
virtual unsigned int | packGPBits () const |
| Reproduce the gp bits field used in CR.
|
virtual void | setAttribute (const Symbol *name, RObject *value) |
| Set or remove an attribute.
|
void | setAttributes (const PairList *new_attributes) |
| Replace the attributes of an object.
|
void | setMemoryTracing (bool on) |
| Enable/disable tracing of copying etc.
|
void | setS4Object (bool on) |
| Set the status of this RObject as an S4 object.
|
SEXPTYPE | sexptype () const |
| Get an object's SEXPTYPE.
|
virtual void | unpackGPBits (unsigned int gpbits) |
| Interpret the gp bits field used in CR.
|
void | expose () const |
| Record that construction of a node is complete.
|
bool | isExposed () const |
| Has this node been exposed to garbage collection?
|
| Link () |
| Default constructor.
|
| Link (HeterogeneousListBase *list) |
| Appending constructor.
|
void | freeLink () |
| Detach Link from any list.
|
Static Public Member Functions |
static const char * | staticTypeName () |
| The name by which this type is known in R.
|
static void | enableTracing (bool on) |
| Enable/disable function tracing.
|
static bool | isA (const RObject *obj) |
| Is an RObject a FunctionBase?
|
static bool | tracingEnabled () |
| If function tracing currently enabled?
|
template<class T > |
static T * | clone (const T *pattern) |
| Return a pointer to a copy of an object.
|
static void * | operator new (size_t bytes) |
| Allocate memory.
|
static void * | operator new (size_t, void *where) |
| Placement new for GCNode.
|
static void | operator delete (void *p, size_t bytes) |
| Deallocate memory.
|
static bool | check () |
| Integrity check.
|
template<class T > |
static T * | expose (T *node) |
| Record that construction of a node is complete.
|
static void | gc () |
| Initiate a garbage collection.
|
static void | gclite () |
| Lightweight garbage collection.
|
static void | maybeCheckExposed (const GCNode *node) |
| Subject to configuration, check that a GCNode is exposed.
|
static size_t | numNodes () |
| Number of GCNode objects in existence.
|
Class representing a functional programming closure.
A closure associates a function definition (the body) with a list of formal arguments and an environment. In evaluating the function, non-local variables within the function definition are interpreted by reference to the specified environment (and its enclosing environments).
Closure* CXXR::Closure::clone |
( |
| ) |
const |
|
virtual |
Return pointer to a copy of this object.
This function creates a copy of this object, and returns a pointer to that copy.
Generally this function (and the copy constructors it utilises) will attempt to create a 'deep' copy of the object; this follows standard practice within C++, and it is intended to extend this practice as CXXR development continues.
However, if the pattern object contains unclonable subobjects, then the created copy will at the relevant places simply contain pointers to those subobjects, i.e. to that extent the copy is 'shallow'. This is managed using the smart pointers defined by nested class RObject::Handle.
- Returns:
- a pointer to a clone of this object, or a null pointer if this object cannot be cloned.
- Note:
- Derived classes should exploit the covariant return type facility to return a pointer to the type of object being cloned.
Reimplemented from CXXR::RObject.
void CXXR::Closure::detachReferents |
( |
| ) |
|
|
protectedvirtual |
Null out all references from this node to other nodes.
The referents of this node are those objects (derived from GCNode) designated by a GCEdge within this object. This function changes all GCEdges within this object to encapsulate a null pointer. It is used during the sweep phase of a mark-sweep garbage collection to break up unreachable subgraphs, and in particular to remove reference loops from them. After the application of this method, the GCNode should be regarded as a 'zombie', kept in existence only so other nodes can detach their references to it cleanly (using decRefCount()).
- Note:
- If this method is reimplemented in a derived class, the reimplemented version must remember to invoke detachReferents() for the immediate base class of the derived class, to ensure that all referents of the object get detached.
Reimplemented from CXXR::RObject.