~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/HexEditor/ExpressionExecutor.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of HexEditor plugin for Code::Blocks Studio
 
3
* Copyright (C) 2008-2009 Bartlomiej Swiecki
 
4
*
 
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.
 
9
*
 
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.
 
14
*
 
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/>.
 
17
*
 
18
* $Revision: 5445 $
 
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 $
 
21
*/
 
22
 
 
23
#ifndef EXPRESSIONEXECUTOR_H
 
24
#define EXPRESSIONEXECUTOR_H
 
25
 
 
26
#include "FileContentBase.h"
 
27
#include "ExpressionPreprocessed.h"
 
28
 
 
29
namespace Expression
 
30
{
 
31
 
 
32
    /** \brief Executor of preprocessed expression */
 
33
    class Executor
 
34
    {
 
35
        public:
 
36
 
 
37
            /** \brief Ctor */
 
38
            Executor();
 
39
 
 
40
            /** \brief Dctor */
 
41
            ~Executor();
 
42
 
 
43
            /** \brief Execute code */
 
44
            inline bool Execute( const Preprocessed& code, FileContentBase* content, FileContentBase::OffsetT current )
 
45
            {
 
46
                m_Code = &code;
 
47
                m_Content = content;
 
48
                m_Current = current;
 
49
                return Run();
 
50
            }
 
51
 
 
52
            /** \brief Get error description */
 
53
            wxString ErrorDesc();
 
54
 
 
55
            bool GetResult( unsigned long long& val );
 
56
            bool GetResult( long long& val );
 
57
            bool GetResult( long double& val );
 
58
            Value GetResult();
 
59
 
 
60
        private:
 
61
 
 
62
            bool Run();
 
63
            inline void ExecuteOneOp();
 
64
 
 
65
            inline Value& GetStack( int pos = 0 )
 
66
            {
 
67
                if ( (unsigned) pos >= m_Stack.size() ) throw errorStackIndex;
 
68
 
 
69
                return m_Stack[ m_Stack.size() - pos - 1 ];
 
70
            }
 
71
 
 
72
            inline void PopStack( )
 
73
            {
 
74
                if ( m_Stack.empty() ) throw errorStackIndex;
 
75
                m_Stack.pop_back();
 
76
            }
 
77
 
 
78
            inline void PushStack( const Value& v )
 
79
            {
 
80
                m_Stack.push_back( v );
 
81
            }
 
82
 
 
83
            inline void ReplaceStack( const Value& v, int pos = 0 )
 
84
            {
 
85
                if ( (unsigned) pos >= m_Stack.size() ) throw errorStackIndex;
 
86
                m_Stack[ m_Stack.size() - pos - 1 ] = v;
 
87
            }
 
88
 
 
89
            template< typename T > Value Content( long long address )
 
90
            {
 
91
                T val;
 
92
                if ( m_Content->Read( &val, address, sizeof(T) ) != sizeof(T) )
 
93
                {
 
94
                    throw errorContentIndex;
 
95
                }
 
96
                return Value( val );
 
97
            }
 
98
 
 
99
            inline void PushArgument( const Operation& op, long long address );
 
100
 
 
101
            inline void PushAddress( const Operation& op, long long address );
 
102
 
 
103
            template< template<typename> class T >
 
104
            inline void BinaryOp( const Operation& op );
 
105
 
 
106
            template< template<typename> class T >
 
107
            inline void UnaryOp( const Operation& op );
 
108
 
 
109
            template< template<typename,typename> class T >
 
110
            inline void UnaryOp2( const Operation& op );
 
111
 
 
112
            template<  template<typename,typename> class T1, typename T2 >
 
113
            inline void UnaryOp2Helper( const Operation& op, T2 value );
 
114
 
 
115
            std::vector< Value >        m_Stack;
 
116
            const Preprocessed*         m_Code;
 
117
            int                         m_OperationPos;
 
118
            FileContentBase*            m_Content;
 
119
            FileContentBase::OffsetT    m_Current;
 
120
            executionError              m_Status;
 
121
 
 
122
    };
 
123
}
 
124
 
 
125
#endif