1 /* "CodeWorker": a scripting language for parsing and generating text. 2 3 Copyright (C) 1996-1997, 1999-2002 C�dric Lemaire 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 To contact the author: codeworker@free.fr 20 */ 21 22 #ifndef _GrfExecutionContext_h_ 23 #define _GrfExecutionContext_h_ 24 25 #include "GrfBlock.h" 26 27 namespace CodeWorker { 28 class UtlException; 29 class BNFClauseCall; 30 31 class GrfExecutionContext : public GrfBlock { 32 private: 33 GrfCommand* _pLastCommand; 34 GrfExecutionContext* _pLastExecutionContext; 35 36 protected: 37 std::list<GrfCommand*> _stack; 38 39 protected: 40 GrfExecutionContext(GrfBlock* pParent = NULL); 41 getLastCommand()42 inline GrfCommand* getLastCommand() const { return _pLastCommand; } getCounter(GrfCommand * pCommand)43 inline unsigned int getCounter(GrfCommand* pCommand) const { return pCommand->_iCounter; } getTimeInMillis(GrfCommand * pCommand)44 inline long getTimeInMillis(GrfCommand* pCommand) const { return pCommand->getTimeInMillis(); } incrementCounter(GrfCommand * pCommand)45 inline void incrementCounter(GrfCommand* pCommand) { pCommand->_iCounter++; } getParsingFilePtr(GrfCommand * pCommand)46 inline const char* getParsingFilePtr(GrfCommand* pCommand) const { return pCommand->_sParsingFilePtr; } getFileLocation(GrfCommand * pCommand)47 inline int getFileLocation(GrfCommand* pCommand) const { return pCommand->_iFileLocation; } 48 49 virtual SEQUENCE_INTERRUPTION_LIST openSession(DtaScriptVariable& visibility) = 0; 50 51 // must be 'final'! 52 virtual SEQUENCE_INTERRUPTION_LIST executeInternal(DtaScriptVariable& visibility); 53 54 public: 55 virtual ~GrfExecutionContext(); 56 getLastExecutionContext()57 inline GrfExecutionContext* getLastExecutionContext() { return _pLastExecutionContext; } 58 59 // to call into redefined methods if symbols information 60 virtual void handleBeforeExecutionCBK(GrfCommand* pCommand, DtaScriptVariable& /*visibility*/); 61 virtual void handleAfterExecutionCBK(GrfCommand* pCommand, DtaScriptVariable& /*visibility*/) = 0; 62 virtual void handleAfterExceptionCBK(GrfCommand* pCommand, DtaScriptVariable& visibility, UtlException& exception) = 0; 63 virtual void handleStartingFunction(GrfFunction* pFunction); 64 virtual void handleEndingFunction(GrfFunction* pFunction); 65 virtual void handleStartingBNFClause(BNFClauseCall* pClauseCall); 66 virtual void handleEndingBNFClause(BNFClauseCall* pClauseCall); 67 virtual void handleBeforeScriptExecutionCBK(GrfCommand* /*pCommand*/, DtaScriptVariable& /*visibility*/); 68 virtual void handleAfterScriptExecutionCBK(GrfCommand* /*pCommand*/, DtaScriptVariable& /*visibility*/); 69 70 private: 71 static void clearRecursively(GrfCommand* pCommand); 72 }; 73 } 74 75 #endif 76