00001 /* 00002 __________ 00003 _____ __ __\______ \_____ _______ ______ ____ _______ 00004 / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ 00005 | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ 00006 |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| 00007 \/ \/ \/ \/ 00008 Copyright (C) 2004-2008 Ingo Berg 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy of this 00011 software and associated documentation files (the "Software"), to deal in the Software 00012 without restriction, including without limitation the rights to use, copy, modify, 00013 merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 00014 permit persons to whom the Software is furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in all copies or 00017 substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 00020 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00021 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00022 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 */ 00025 #ifndef MU_PARSER_BYTECODE_H 00026 #define MU_PARSER_BYTECODE_H 00027 00028 #include <cassert> 00029 #include <string> 00030 #include <stack> 00031 #include <vector> 00032 00033 #include "muParserDef.h" 00034 #include "muParserError.h" 00035 #include "muParserToken.h" 00036 00042 namespace mu 00043 { 00044 00045 00055 class ParserByteCode 00056 { 00057 public: 00064 typedef bytecode_type map_type; 00065 00066 private: 00067 00069 typedef ParserToken<value_type, string_type> token_type; 00070 00072 typedef std::vector<map_type> storage_type; 00073 00075 unsigned m_iStackPos; 00076 00078 storage_type m_vBase; 00079 00081 const int mc_iSizeVal; 00082 00087 const int mc_iSizePtr; 00088 00100 const int mc_iSizeValEntry; 00101 00102 void StorePtr(void *a_pAddr); 00103 00104 public: 00105 ParserByteCode(); 00106 ~ParserByteCode(); 00107 ParserByteCode(const ParserByteCode &a_ByteCode); 00108 ParserByteCode& operator=(const ParserByteCode &a_ByteCode); 00109 void Assign(const ParserByteCode &a_ByteCode); 00110 00111 void AddVar(value_type *a_pVar); 00112 void AddVal(value_type a_fVal); 00113 void AddOp(ECmdCode a_Oprt); 00114 void AddAssignOp(value_type *a_pVar); 00115 void AddFun(void *a_pFun, int a_iArgc); 00116 void AddStrFun(void *a_pFun, int a_iArgc, int a_iIdx); 00117 00118 void Finalize(); 00119 void clear(); 00120 00121 std::size_t GetBufSize() const; 00122 00123 const map_type* GetRawData() const; 00124 00131 unsigned GetValSize() const 00132 { 00133 return mc_iSizeVal; 00134 } 00135 00142 unsigned GetPtrSize() const 00143 { 00144 return mc_iSizePtr; 00145 } 00146 00147 void RemoveValEntries(unsigned a_iNumber); 00148 void AsciiDump(); 00149 }; 00150 00151 } // namespace mu 00152 00153 #endif 00154 00155