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 00023 #ifndef INTELIB_SCHCONT_HPP_SENTRY 00024 #define INTELIB_SCHCONT_HPP_SENTRY 00025 00026 #include "../sexpress/sexpress.hpp" 00027 #include "../sexpress/iexcept.hpp" 00028 #include "../sexpress/sbindtbl.hpp" 00029 #include "../sexpress/gensref.hpp" 00030 #include "../genlisp/conteval.hpp" 00031 #include "scheme.hpp" 00032 00033 00034 class SchExpressionSymbol; 00035 00036 class SchExpressionContext; 00037 00039 class IntelibX_scheme_not_a_context : public IntelibX { 00040 public: 00041 IntelibX_scheme_not_a_context(SReference a_param); 00042 }; 00043 00045 typedef GenericSReference<SchExpressionContext, IntelibX_scheme_not_a_context> 00046 SchContextRef; 00047 00049 00058 class SchExpressionContext : public SExpression { 00059 SchContextRef prev; 00060 IntelibBindTable tbl; 00061 public: 00063 static IntelibTypeId TypeId; 00064 00066 SchExpressionContext(); 00068 SchExpressionContext(SchContextRef a_prev); 00069 protected: 00070 ~SchExpressionContext(); 00071 00072 public: 00074 void AddBinding(const SchExpressionSymbol *symb, const SReference& val); 00076 00080 SReference* GetBinding(const SchExpressionSymbol *symb) const; 00082 00086 SReference* ProvideBinding(const SchExpressionSymbol *symb); 00087 00089 SReference GetAllSymbols() const; 00090 00091 #if INTELIB_TEXT_REPRESENTATIONS == 1 00092 virtual class SString TextRepresentation() const; 00093 #endif 00094 }; 00095 00096 00098 00104 class SchemeContinuation : public IntelibContinuation { 00105 public: 00107 SchemeContinuation() : IntelibContinuation() 00108 { PTheFalseValue = PTheSchemeBooleanFalse; } 00109 00111 SchemeContinuation(const SchemeContinuation &other, bool b) 00112 : IntelibContinuation(other, b) 00113 { PTheFalseValue = PTheSchemeBooleanFalse; } 00114 00116 ~SchemeContinuation() {} 00117 00119 enum CustomInstructions { case_check = max_command - 1 }; 00120 00122 SchContextRef GetContext() const 00123 { return IntelibContinuation::GetContext(); } 00124 00126 void SetContext(const SchContextRef& context) 00127 { IntelibContinuation::SetContext(context); } 00128 00129 private: 00130 virtual void JustEvaluate(const SReference& expr); 00131 virtual void CustomCommand(int opcode, const SReference& param); 00132 00133 void CaseCheck(const SReference& expr); 00134 00135 void EvaluateForm(SExpressionCons *form); 00136 SReference& GetSymbolValue(SchExpressionSymbol *sym) const; 00137 }; 00138 00140 class IntelibX_scheme_symbol_has_no_value : public IntelibX { 00141 public: 00142 IntelibX_scheme_symbol_has_no_value(SReference a_param); 00143 }; 00144 00145 #endif