CXXR (C++ R)
|
R function implemented within the interpreter. More...
#include <BuiltInFunction.h>
Public Types | |
enum | Kind { PP_INVALID = 0, PP_ASSIGN = 1, PP_ASSIGN2 = 2, PP_BINARY = 3, PP_BINARY2 = 4, PP_BREAK = 5, PP_CURLY = 6, PP_FOR = 7, PP_FUNCALL = 8, PP_FUNCTION = 9, PP_IF = 10, PP_NEXT = 11, PP_PAREN = 12, PP_RETURN = 13, PP_SUBASS = 14, PP_SUBSET = 15, PP_WHILE = 16, PP_UNARY = 17, PP_DOLLAR = 18, PP_FOREIGN = 19, PP_REPEAT = 20 } |
Kind of function, used mainly in deparsing. | |
enum | Precedence { PREC_FN = 0, PREC_LEFT = 1, PREC_EQ = 2, PREC_RIGHT = 3, PREC_TILDE = 4, PREC_OR = 5, PREC_AND = 6, PREC_NOT = 7, PREC_COMPARE = 8, PREC_SUM = 9, PREC_PROD = 10, PREC_PERCENT = 11, PREC_COLON = 12, PREC_SIGN = 13, PREC_POWER = 14, PREC_DOLLAR = 15, PREC_NS = 16, PREC_SUBSET = 17 } |
Precedence level of function. |
Public Member Functions | |
int | arity () const |
'Arity' of the function. | |
void | checkNumArgs (const PairList *args, const Expression *call) const |
Report error if argument list is wrong length. | |
CCODE | function () const |
C/C++ function implementing this R function. | |
Kind | kind () const |
Kind of built-in function. | |
const char * | name () const |
Name of function. | |
unsigned int | offset () const |
Get table offset. | |
Precedence | precedence () const |
Precedence of built-in function. | |
int | printHandling () const |
(Not for general use.) | |
bool | rightAssociative () const |
Is a built-in function right-associative? | |
unsigned int | variant () const |
Index of variant behaviour. | |
bool | viaDotInternal () const |
Must this function be called via .Internal()? | |
const char * | typeName () const |
Name within R of this type of object. | |
RObject * | apply (ArgList *arglist, Environment *env, const Expression *call) const |
Apply the function. | |
Public Member Functions inherited from CXXR::FunctionBase | |
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? | |
Public Member Functions inherited from CXXR::RObject | |
virtual const PairList * | attributes () const |
Get object attributes. | |
virtual void | clearAttributes () |
Remove all attributes. | |
virtual RObject * | clone () const |
Return pointer to a copy of this object. | |
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 | detachReferents () |
Null out all references from this node to other nodes. | |
void | visitReferents (const_visitor *v) const |
Conduct a visitor to the nodes referred to by this one. | |
Public Member Functions inherited from CXXR::GCNode | |
void | expose () const |
Record that construction of a node is complete. | |
bool | isExposed () const |
Has this node been exposed to garbage collection? | |
Public Member Functions inherited from CXXR::HeterogeneousListBase::Link | |
Link () | |
Default constructor. | |
Link (HeterogeneousListBase *list) | |
Appending constructor. | |
void | freeLink () |
Detach Link from any list. |
Static Public Member Functions | |
static BuiltInFunction * | obtain (const std::string &name) |
Get a pointer to a BuiltInFunction object. | |
static const char * | staticTypeName () |
The names by which this type is known in R. | |
Static Public Member Functions inherited from CXXR::FunctionBase | |
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? | |
Static Public Member Functions inherited from CXXR::RObject | |
template<class T > | |
static T * | clone (const T *pattern) |
Return a pointer to a copy of an object. | |
Static Public Member Functions inherited from CXXR::GCNode | |
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. |
Friends | |
class | boost::serialization::access |
class | SchwarzCounter< BuiltInFunction > |
Additional Inherited Members | |
Protected Member Functions inherited from CXXR::FunctionBase | |
FunctionBase (SEXPTYPE stype) | |
FunctionBase (const FunctionBase &pattern) | |
Copy constructor. | |
Protected Member Functions inherited from CXXR::RObject | |
RObject (SEXPTYPE stype=CXXSXP) | |
RObject (const RObject &pattern) | |
Copy constructor. | |
Protected Member Functions inherited from CXXR::GCNode | |
virtual | ~GCNode () |
Protected Member Functions inherited from CXXR::HeterogeneousListBase::Link | |
virtual | ~Link () |
R function implemented within the interpreter.
A BuiltInFunction object represents an R function that is implemented within the interpreter by a function in C++ or C. These objects are of two kinds, according to whether the arguments passed to BuiltInFunction::apply() are evaluated before being passed on to the encapsulated C/C++ function (CR's BUILTINSXP), or are passed on unevaluated (SPECIALSXP).
A BuiltInFunction object is implemented essentially as an offset into a table of function information, which in CXXR is a private static member (s_function_table
) of this class.
|
virtual |
Apply the function.
arglist | Non-null pointer to the ArgList containing the list of arguments with which the function is to be invoked. |
env | Pointer to the Environment in which the function is to be evaluated. |
call | Pointer to the Expression calling the function. |
Implements CXXR::FunctionBase.
|
inline |
'Arity' of the function.
void BuiltInFunction::checkNumArgs | ( | const PairList * | args, |
const Expression * | call | ||
) | const |
Report error if argument list is wrong length.
This function raises an error if args is not of a permissible length for all call to this BuiltInFunction.
args | Argument list to be checked, possibly null. |
call | The call being processed (for error reporting). |
|
inline |
C/C++ function implementing this R function.
|
inline |
Kind of built-in function.
(Used mainly in deparsing.)
|
inline |
Name of function.
|
static |
Get a pointer to a BuiltInFunction object.
If name is not the name of a built-in function this function will raise a warning and return a null pointer. Otherwise the function will return a pointer to the (unique) BuiltInFunction object embodying that function. If no such object already exists, one will be created.
name | The name of the built-in function. |
|
inline |
Get table offset.
|
inline |
Precedence of built-in function.
|
inline |
(Not for general use.)
This function is used to implement PRIMPRINT, and is likely to be removed in future refactorisation.
R_Visible
within the function, as documented in names.cpp for the eval field of the function table.
|
inline |
Is a built-in function right-associative?
|
inlinestatic |
The names by which this type is known in R.
Reimplemented from CXXR::FunctionBase.
|
virtual |
Name within R of this type of object.
Reimplemented from CXXR::RObject.
|
inline |
Index of variant behaviour.
Where a single C/C++ function implements more than one built-in R function, this function provides the C/C++ code with an index indicating which R function is to be implemented.
|
inline |
Must this function be called via .Internal()?