2
* This file is part of HexEditor plugin for Code::Blocks Studio
3
* Copyright (C) 2008-2009 Bartlomiej Swiecki
5
* HexEditor plugin is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* HexEditor pluging 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
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with HexEditor. If not, see <http://www.gnu.org/licenses/>.
19
* $Id: ExpressionExecutor.h 5445 2009-02-07 00:35:09Z byo $
20
* $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/contrib/HexEditor/ExpressionExecutor.h $
23
#ifndef EXPRESSIONEXECUTOR_H
24
#define EXPRESSIONEXECUTOR_H
26
#include "FileContentBase.h"
27
#include "ExpressionPreprocessed.h"
32
/** \brief Executor of preprocessed expression */
43
/** \brief Execute code */
44
inline bool Execute( const Preprocessed& code, FileContentBase* content, FileContentBase::OffsetT current )
52
/** \brief Get error description */
55
bool GetResult( unsigned long long& val );
56
bool GetResult( long long& val );
57
bool GetResult( long double& val );
63
inline void ExecuteOneOp();
65
inline Value& GetStack( int pos = 0 )
67
if ( (unsigned) pos >= m_Stack.size() ) throw errorStackIndex;
69
return m_Stack[ m_Stack.size() - pos - 1 ];
72
inline void PopStack( )
74
if ( m_Stack.empty() ) throw errorStackIndex;
78
inline void PushStack( const Value& v )
80
m_Stack.push_back( v );
83
inline void ReplaceStack( const Value& v, int pos = 0 )
85
if ( (unsigned) pos >= m_Stack.size() ) throw errorStackIndex;
86
m_Stack[ m_Stack.size() - pos - 1 ] = v;
89
template< typename T > Value Content( long long address )
92
if ( m_Content->Read( &val, address, sizeof(T) ) != sizeof(T) )
94
throw errorContentIndex;
99
inline void PushArgument( const Operation& op, long long address );
101
inline void PushAddress( const Operation& op, long long address );
103
template< template<typename> class T >
104
inline void BinaryOp( const Operation& op );
106
template< template<typename> class T >
107
inline void UnaryOp( const Operation& op );
109
template< template<typename,typename> class T >
110
inline void UnaryOp2( const Operation& op );
112
template< template<typename,typename> class T1, typename T2 >
113
inline void UnaryOp2Helper( const Operation& op, T2 value );
115
std::vector< Value > m_Stack;
116
const Preprocessed* m_Code;
118
FileContentBase* m_Content;
119
FileContentBase::OffsetT m_Current;
120
executionError m_Status;