Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

LExpressionMacro Class Reference

#include <llambda.hpp>

Inheritance diagram for LExpressionMacro:

Inheritance graph
[legend]
Collaboration diagram for LExpressionMacro:

Collaboration graph
[legend]
List of all members.

Detailed Description

A macro (in the sence of Common Lisp).

InteLib models the Common Lisp's flavor of macros. They aren't really macros though because they're always expanded at the execution time, so they perhaps should be terribly slow. Actually, the LExpressionMacro is a kind of special form which, like a Lambda, has a lambda list, a body and acts as a closure (remembering all the lexical bindings that were in effect on the moment the macro has been created). A call to such a macro evaluates as follows:

Definition at line 119 of file llambda.hpp.

Public Member Functions

 LExpressionMacro (const LContextRef &a_cont, const SReference &lambda, const SReference &body)
 The constructor.
virtual void Call (const SReference &formtail, IntelibContinuation &cont) const
 Perform macro expansion and evaluate the result.
virtual SString TextRepresentation () const
 Text representation of the S-expression.
const IntelibTypeIdTermType () const
 Actual S-expression type.
bool IsChangeable () const
 Can it be changed during the lifetime of the object?
virtual SExpressionClone () const
 Clone a changeable object.
virtual bool SpecificEql (const SExpression *) const
 Are the two objects EQL (while not EQ).
SReferenceGetBody ()
 Get the body.

Static Public Attributes

static IntelibTypeId TypeId
 The type identifier.

Protected Member Functions

virtual ~LExpressionMacro ()
bool CanDie ()
 Is it OK to delete the object now?
void DoAnalyseLambdaList (const SReference &rest, int n)

Protected Attributes

LContextRef context
SReference lambda_list
LExpressionSymbol ** lambda_vector
LExpressionSymbollambda_rest
int lambda_length
SReference body


Constructor & Destructor Documentation

LExpressionMacro::LExpressionMacro const LContextRef a_cont,
const SReference lambda,
const SReference body
 

The constructor.

Parameters:
a_cont is the lexical context within which the closure is created
lambda is the list of symbols to be used as formal parameters
body is the list of forms that is to be used as the function's body

Definition at line 133 of file llambda.cpp.

LExpressionMacro::~LExpressionMacro  )  [protected, virtual]
 

Definition at line 139 of file llambda.cpp.


Member Function Documentation

void LExpressionMacro::Call const SReference formtail,
IntelibContinuation cont
const [virtual]
 

Perform macro expansion and evaluate the result.

This method actually does all the job; however, you generally won't need to do so; better construct the appropriate form and LReference::Evaluate() it. This is because the expansion and evaluation is actually only scheduled to be done within the given continuation, and you'll need yourself to make the continuation run to get the result of the application.

Implements SExpressionForm.

Definition at line 142 of file llambda.cpp.

References SReference::Car(), SReference::Cdr(), and SReference::IsEmptyList().

SString LExpressionMacro::TextRepresentation  )  const [virtual]
 

Text representation of the S-expression.

Returns the text string which represents the given S-expression as for real Lisp (for example, (25 36 49))

Implements SExpression.

Definition at line 168 of file llambda.cpp.

const IntelibTypeId& SExpression::TermType  )  const [inherited]
 

Actual S-expression type.

Definition at line 195 of file sexpress.hpp.

Referenced by SReference::DynamicCastGetPtr(), SchReference::IsEql(), LReference::IsEql(), SReference::SimpleCastGetPtr(), SchReference::TextRepresentation(), and LReference::TextRepresentation().

bool SExpression::IsChangeable  )  const [inherited]
 

Can it be changed during the lifetime of the object?

Definition at line 198 of file sexpress.hpp.

References IntelibTypeId::IsChangeable().

virtual SExpression* SExpression::Clone  )  const [virtual, inherited]
 

Clone a changeable object.

The method should return the pointer created with new

Note:
It can (and should) return null pointer for non-changeables
Warning:
This method will hang your program being called for a looped data structure, including looped lists, a hash table which references a list in which it is a member, etc.

If you create a changeable S-expression, you MUST make sure this method duplicates your object in such a way that nothing is shared between the old and new objects, that is, changing the new object can not in any way change the old object.

Reimplemented in SExpressionBacklink, SExpressionCons, SExpressionHashTable, SExpressionRawBuffer, and SExpressionVector.

Definition at line 214 of file sexpress.hpp.

virtual bool SExpression::SpecificEql const SExpression  )  const [virtual, inherited]
 

Are the two objects EQL (while not EQ).

This function is overriden by those SExpressions able to be EQL while being not EQ.

Warning:
It is not demanded that this function return true if it's arguments are the same SExpression (that is, they're EQ). It is only called by the EQL predicate implementation when it has been checked that the operands are not the same object.

Reimplemented in SExpressionInt, SExpressionFloat, SExpressionChar, and SExpressionString.

Definition at line 235 of file sexpress.hpp.

Referenced by SchReference::IsEql(), and LReference::IsEql().

bool GarbageSafe::CanDie  )  [protected, inherited]
 

Is it OK to delete the object now?

Our children have no access to the private attribute RefCount and should never need it except when checking if the destruction is not an error. This solves the problem.

Definition at line 53 of file refcount.hpp.

void LispLambdaBody::DoAnalyseLambdaList const SReference rest,
int  n
[protected, inherited]
 

Definition at line 36 of file llambda.cpp.

References SExpressionCons::Car(), SExpressionCons::Cdr(), SReference::DynamicCastGetPtr(), SReference::GetPtr(), INTELIB_ASSERT, LispLambdaBody::lambda_length, LispLambdaBody::lambda_rest, and LispLambdaBody::lambda_vector.

Referenced by LispLambdaBody::LispLambdaBody().

SReference& LispLambdaBody::GetBody  )  [inherited]
 

Get the body.

Definition at line 56 of file llambda.hpp.

References LispLambdaBody::body.


Member Data Documentation

IntelibTypeId LExpressionMacro::TypeId [static]
 

The type identifier.

Reimplemented from SExpressionForm.

LContextRef LispLambdaBody::context [protected, inherited]
 

Definition at line 41 of file llambda.hpp.

SReference LispLambdaBody::lambda_list [protected, inherited]
 

Definition at line 42 of file llambda.hpp.

LExpressionSymbol** LispLambdaBody::lambda_vector [protected, inherited]
 

Definition at line 43 of file llambda.hpp.

Referenced by LispLambdaBody::DoAnalyseLambdaList(), and LispLambdaBody::~LispLambdaBody().

LExpressionSymbol* LispLambdaBody::lambda_rest [protected, inherited]
 

Definition at line 44 of file llambda.hpp.

Referenced by LispLambdaBody::DoAnalyseLambdaList().

int LispLambdaBody::lambda_length [protected, inherited]
 

Definition at line 45 of file llambda.hpp.

Referenced by LispLambdaBody::DoAnalyseLambdaList().

SReference LispLambdaBody::body [protected, inherited]
 

Definition at line 46 of file llambda.hpp.

Referenced by LispLambdaBody::GetBody().


The documentation for this class was generated from the following files:
Generated on Tue Dec 18 00:41:24 2007 for InteLib by  doxygen 1.4.1