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

lcont.hpp

Go to the documentation of this file.
00001 // +-------------------------------------------------------------------------+
00002 // |               I__n__t__e__L__i__b           0.6.10 development          |
00003 // | Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2000-2007. |
00004 // |                                                                         |
00005 // | This is free software. The library part is available under              |
00006 // |                               GNU LESSER GENERAL PUBLIC LICENSE v.2.1.  |
00007 // | GNU LGPL v2.1 is found in docs/gnu_gpl2.txt,  or at  http://www.gnu.org |
00008 // |     Please see also docs/readme.txt and visit http://www.intelib.org    |
00009 // |                                                                         |
00010 // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! |
00011 // +-------------------------------------------------------------------------+
00012 
00013 
00014 
00015 
00025 #ifndef INTELIB_LCONT_HPP_SENTRY
00026 #define INTELIB_LCONT_HPP_SENTRY
00027 
00028 #include "../sexpress/sexpress.hpp"
00029 #include "../sexpress/iexcept.hpp"
00030 #include "../sexpress/sbindtbl.hpp"
00031 #include "../sexpress/gensref.hpp"
00032 #include "../genlisp/conteval.hpp"
00033 #include "lisp.hpp"
00034 
00035 
00036 class LExpressionSymbol;
00037 
00038 class LExpressionContext;
00039 
00041 class IntelibX_lisp_not_a_context : public IntelibX {
00042 public:
00043     IntelibX_lisp_not_a_context(SReference a_param);
00044 };
00045 
00047 typedef GenericSReference<LExpressionContext, IntelibX_lisp_not_a_context> 
00048     LContextRef;
00049 
00051 
00052 class LExpressionContext : public SExpression {  
00053     LContextRef prev;
00054     IntelibBindTable valtbl, funtbl;
00055 public:
00057     static IntelibTypeId TypeId;
00059     LExpressionContext(); 
00061     LExpressionContext(LContextRef a_prev); 
00062 protected:
00063     ~LExpressionContext();    
00064 
00065 public:
00067     void AddBinding(const LExpressionSymbol *symb, const SReference& val);
00069 
00073     SReference* GetBinding(const LExpressionSymbol *symb) const;
00075 
00079     SReference* ProvideBinding(const LExpressionSymbol *symb);
00080 
00082     void AddFunBinding(const LExpressionSymbol *symb, const SReference& val);
00084 
00088     SReference* GetFunBinding(const LExpressionSymbol *symb) const;
00090 
00094     SReference* ProvideFunBinding(const LExpressionSymbol *symb);
00095 
00097     SReference GetAllSymbols() const;
00098 
00099 #if INTELIB_TEXT_REPRESENTATIONS == 1
00100     virtual class SString TextRepresentation() const;
00101 #endif
00102 };
00103 
00105 
00111 class LispContinuation : public IntelibContinuation {
00112 public:
00114     LispContinuation() : IntelibContinuation()
00115         { PTheFalseValue = PTheLispBooleanFalse; }
00116 
00118     LispContinuation(const LispContinuation &other, bool b)
00119         : IntelibContinuation(other, b)
00120         { PTheFalseValue = PTheLispBooleanFalse; }
00121 
00123     ~LispContinuation() {}
00124 
00126     enum CustomInstructions {
00128         take_result_as_form = max_command - 1,
00130         duplicate_last_result = max_command - 2
00131      };
00132 
00134     LContextRef GetContext() const
00135         { return IntelibContinuation::GetContext(); }
00136 
00138     void SetContext(const LContextRef& context)
00139         { IntelibContinuation::SetContext(context); }
00140 
00141 private:
00143     virtual void JustEvaluate(const SReference& expr);
00145     virtual void CustomCommand(int opcode, const SReference& param);
00146 
00147     void EvaluateForm(SExpressionCons *form);
00148     SReference& GetSymbolValue(LExpressionSymbol *sym) const;
00149 };
00150 
00152 class IntelibX_lisp_not_a_function : public IntelibX {
00153 public:
00154     IntelibX_lisp_not_a_function(SReference a_param);
00155 };
00156 
00158 class IntelibX_lisp_symbol_has_no_value : public IntelibX {
00159 public:
00160     IntelibX_lisp_symbol_has_no_value(SReference a_param);
00161 };
00162 
00164 
00168 class IntelibX_no_associated_function : public IntelibX {
00169 public:
00170     IntelibX_no_associated_function(SReference a_param);
00171 };
00172 
00173 #endif

Generated on Tue Dec 18 00:39:43 2007 for InteLib by  doxygen 1.4.1