MADNESS  version 0.9
muParserBytecode.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2008 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 #ifndef MU_PARSER_BYTECODE_H
26 #define MU_PARSER_BYTECODE_H
27 
28 #include <cassert>
29 #include <string>
30 #include <stack>
31 #include <vector>
32 #include <locale>
33 
34 #include "muParserDef.h"
35 #include "muParserError.h"
36 #include "muParserToken.h"
37 
43 namespace mu
44 {
45 
46 
57 {
58 public:
66 
67 private:
68 
71 
73  typedef std::vector<map_type> storage_type;
74 
76  unsigned m_iStackPos;
77 
79  storage_type m_vBase;
80 
82  const int mc_iSizeVal;
83 
88  const int mc_iSizePtr;
89 
101  const int mc_iSizeValEntry;
102 
103  void StorePtr(void *a_pAddr);
104 
105 public:
106  ParserByteCode();
107  ~ParserByteCode();
108  ParserByteCode(const ParserByteCode &a_ByteCode);
109  ParserByteCode& operator=(const ParserByteCode &a_ByteCode);
110  void Assign(const ParserByteCode &a_ByteCode);
111 
112  void AddVar(value_type *a_pVar);
113  void AddVal(value_type a_fVal);
114  void AddOp(ECmdCode a_Oprt);
116  void AddFun(void *a_pFun, int a_iArgc);
117  void AddStrFun(void *a_pFun, int a_iArgc, int a_iIdx);
118 
119  void Finalize();
120  void clear();
121 
122  std::size_t GetBufSize() const;
123 
124  const map_type* GetRawData() const;
125 
132  unsigned GetValSize() const
133  {
134  return mc_iSizeVal;
135  }
136 
143  unsigned GetPtrSize() const
144  {
145  return mc_iSizePtr;
146  }
147 
148  void RemoveValEntries(unsigned a_iNumber);
149  void AsciiDump();
150 };
151 
152 } // namespace mu
153 
154 #endif
155 
156 
std::size_t GetBufSize() const
Definition: muParserBytecode.cpp:281
~ParserByteCode()
Destructor (trivial).
Definition: muParserBytecode.cpp:59
void AddAssignOp(value_type *a_pVar)
Add an assignement operator.
Definition: muParserBytecode.cpp:207
const muChar_t muFloat_t a_fVal
Definition: muParserDLL.h:107
void AddStrFun(void *a_pFun, int a_iArgc, int a_iIdx)
Add Strung function entry to the parser bytecode.
Definition: muParserBytecode.cpp:246
void Assign(const ParserByteCode &a_ByteCode)
Copy state of another object to this.
Definition: muParserBytecode.cpp:127
const muChar_t muFun0_t a_pFun
Definition: muParserDLL.h:84
bytecode_type map_type
Underlying type of the container.
Definition: muParserBytecode.h:65
void AddOp(ECmdCode a_Oprt)
Add an operator identifier to bytecode.
Definition: muParserBytecode.cpp:190
unsigned const muChar_t muFloat_t ** a_pVar
Definition: muParserDLL.h:145
MUP_BYTECODE_TYPE bytecode_type
The bytecode type used by the parser.
Definition: muParserDef.h:234
void AsciiDump()
Dump bytecode (for debugging only!).
Definition: muParserBytecode.cpp:318
ParserByteCode()
Definition: muParserBytecode.cpp:47
void AddVal(value_type a_fVal)
Add a Variable pointer to bytecode.
Definition: muParserBytecode.cpp:170
unsigned GetValSize() const
Return size of a value entry.
Definition: muParserBytecode.h:132
ECmdCode
Bytecode values.
Definition: muParserDef.h:154
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:222
void RemoveValEntries(unsigned a_iNumber)
Remove a value number of entries from the bytecode.
Definition: muParserBytecode.cpp:306
Namespace for mathematical applications.
Definition: muParser.cpp:47
unsigned GetPtrSize() const
Return size of a pointer entry.
Definition: muParserBytecode.h:143
Bytecode implementation of the Math Parser.
Definition: muParserBytecode.h:56
This file contains the parser token definition.
void clear()
Delete the bytecode.
Definition: muParserBytecode.cpp:295
void AddVar(value_type *a_pVar)
Add a Variable pointer to bytecode.
Definition: muParserBytecode.cpp:141
void AddFun(void *a_pFun, int a_iArgc)
Add function to bytecode.
Definition: muParserBytecode.cpp:220
ParserByteCode & operator=(const ParserByteCode &a_ByteCode)
Assignment operator.
Definition: muParserBytecode.cpp:80
const map_type * GetRawData() const
Get Pointer to bytecode data storage.
Definition: muParserBytecode.cpp:274
void Finalize()
Add end marker to bytecode.
Definition: muParserBytecode.cpp:262
This file defines the error class used by the parser.
This file contains standard definitions used by the parser.