00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00025 #ifndef INTELIB_LLAMBDA_HPP_SENTRY
00026 #define INTELIB_LLAMBDA_HPP_SENTRY
00027
00028 #include "../sexpress/sexpress.hpp"
00029 #include "../sexpress/iexcept.hpp"
00030 #include "../genlisp/lispform.hpp"
00031 #include "lcont.hpp"
00032
00033 class LExpressionSymbol;
00034
00036
00039 class LispLambdaBody {
00040 protected:
00041 LContextRef context;
00042 SReference lambda_list;
00043 LExpressionSymbol **lambda_vector;
00044 LExpressionSymbol *lambda_rest;
00045 int lambda_length;
00046 SReference body;
00047
00048 LispLambdaBody(const LContextRef &a_cont,
00049 const SReference &lambda, const SReference& body);
00050 ~LispLambdaBody();
00051
00052 void DoAnalyseLambdaList(const SReference &rest, int n);
00053
00054 public:
00056 SReference& GetBody() { return body; }
00057 };
00058
00060
00063 class LExpressionLambda : public SExpressionFunction, public LispLambdaBody {
00064 public:
00066 static IntelibTypeId TypeId;
00068
00075 LExpressionLambda(const LContextRef &a_cont,
00076 const SReference &lambda, const SReference& body);
00077 protected:
00078 virtual ~LExpressionLambda();
00079
00080 public:
00082
00092 virtual void DoApply(int paramc,
00093 const SReference *paramv,
00094 IntelibContinuation &cont) const;
00095
00096 #if INTELIB_TEXT_REPRESENTATIONS == 1
00097 virtual SString TextRepresentation() const;
00098 #endif
00099 };
00100
00102
00119 class LExpressionMacro : public SExpressionForm, public LispLambdaBody {
00120 public:
00122 static IntelibTypeId TypeId;
00124
00131 LExpressionMacro(const LContextRef &a_cont,
00132 const SReference &lambda, const SReference& body);
00133
00134 protected:
00135 virtual ~LExpressionMacro();
00136
00137 public:
00139
00147 virtual void Call(const SReference &formtail,
00148 IntelibContinuation &cont) const;
00149
00150 #if INTELIB_TEXT_REPRESENTATIONS == 1
00151 virtual SString TextRepresentation() const;
00152 #endif
00153 };
00154
00155
00157
00160 class LExpressionUserCFunction : public SExpressionFunction {
00161 UserLispFunction fun;
00162 public:
00164 static IntelibTypeId TypeId;
00166 LExpressionUserCFunction(UserLispFunction a)
00167 : SExpressionFunction(TypeId, -1, -1), fun(a) {}
00169 virtual void DoApply(int paramsc,
00170 const SReference *paramsv,
00171 IntelibContinuation &lf) const
00172 { lf.RegularReturn(fun(paramsc, paramsv)); }
00173 #if INTELIB_TEXT_REPRESENTATIONS == 1
00174 virtual SString TextRepresentation() const;
00175 #endif
00176 protected:
00177 ~LExpressionUserCFunction() {}
00178 };
00179
00180 #endif