FuncNodes.h

Go to the documentation of this file.
00001 /*
00002  *      FuncNodes.h -
00003  *
00004  *  Copyright (C) 2002-2003 The Pentagram Team
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef FUNCNODES_H
00022 #define FUNCNODES_H
00023 
00024 #include "GenericNodes.h"
00025 #include "CallNodes.h"
00026 #include <deque>
00027 #include <string>
00028 
00029 class FuncMutatorNode : public Node
00030 {
00031         public:
00032                 FuncMutatorNode(const uint32 opcode, const uint32 offset, const uint32 newValue1)
00033                         : Node(opcode, offset, Type(Type::T_INVALID)),
00034                         _initsize(newValue1), _linenum(newValue1)
00035                         {
00036                                 assert(acceptOp(opcode, 0x5A, 0x5B));
00037                                 switch(opcode)
00038                                 {
00039                                         case 0x5A: mtype = INIT; break;
00040                                         case 0x5B: mtype = LINE_NUMBER; break;
00041                                         default: assert(false);
00042                                 }
00043                         };
00044                 FuncMutatorNode(const uint32 opcode, const uint32 offset, const uint32 newSymbolOffset,
00045                         const std::string &newClassName)
00046                         : Node(opcode, offset, Type(Type::T_INVALID)),
00047                         _symboloffset(newSymbolOffset), _classname(newClassName)
00048                         {
00049                                 assert(acceptOp(opcode, 0x5C));
00050                                 mtype = SYMBOL_INFO;
00051                         };
00052                 FuncMutatorNode(const uint32 opcode, const uint32 offset)
00053                         : Node(opcode, offset, Type(Type::T_INVALID))
00054                         {
00055                                 assert(acceptOp(opcode, 0x50, 0x53, 0x7A));
00056                                 switch(opcode)
00057                                 {
00058                                         case 0x50: mtype = RET; break;
00059                                         case 0x53: mtype = SUSPEND; break;
00060                                         case 0x7A: mtype = END; break;
00061                                         default: assert(false);
00062                                 }
00063                         };
00064                 ~FuncMutatorNode() {};
00065 
00066                 void print_unk(Console &o, const uint32 isize, const bool comment) const;
00067                 void print_unk(Console &o, const uint32 isize) const { print_unk(o, isize, true); };
00068                 void print_asm(Console &o) const;
00069                 void print_bin(ODequeDataSource &o) const;
00070                 bool fold(DCUnit *unit, std::deque<Node *> &nodes);
00071 
00072         protected:
00073                 enum mutatortype { RET, INIT, LINE_NUMBER, SYMBOL_INFO, SUSPEND, END } mtype;
00074 
00075         private:
00076                 uint32 _initsize; // init
00077                 uint32 _linenum; // line number
00078                 uint32 _symboloffset; // symbol info
00079                 std::string _classname; // symbol info
00080         
00081         public: // wheeefun accessors.
00082                 uint32 a_initsize() const { assert(opcode()==0x5A && mtype==INIT); return _initsize; };
00083 };
00084 
00085 class DCFuncNode : public ColNode
00086 {
00087         public:
00088                 DCFuncNode()
00089                         : ColNode(0xFFFF, 0x0000, Type(Type::T_INVALID)),
00090                         setinfonode(0),
00091                         locals_datasize(0), func_start_offset(0),
00092                         debug_ret_offset(0), debug_end_offset(0),
00093                         process_type(0), debug_processtype_offset(0), debug_thisp(false),
00094                         debug_procexclude_offset(0), has_procexclude(false)
00095                         {
00096                         };
00097                 ~DCFuncNode() {};
00098 
00099                 void print_unk_funcheader(Console &o, const uint32 isize) const;
00100                 void print_unk(Console &o, const uint32 isize) const;
00101                 void print_asm(Console &o) const;
00102                 void print_bin(ODequeDataSource &o) const;
00103                 bool fold(DCUnit *unit, std::deque<Node *> &nodes);
00104                 void addEnd(FuncMutatorNode *n)
00105                 {
00106                         assert(n!=0);
00107                         assert(n->opcode()==0x7A);
00108                         debug_end_offset = n->offset();
00109                         FORGET_OBJECT(n);
00110                 };
00111                 
00112         protected:
00113                 std::deque<Node *> funcnodes;
00114                 DCCallMutatorNode *setinfonode;
00115 
00116                 uint32  locals_datasize; // from 'init' opcode
00117                 uint32  func_start_offset; // from 'init' opcode
00118                 uint32  debug_ret_offset; // from 'ret' opcode, FIXME: debugging only
00119                 uint32  debug_end_offset; // from 'end' opcode, FIXME: debugging only
00120                 
00121                 uint32  process_type; // from 'set info' opcode
00122                 uint32  debug_processtype_offset; // from 'set info' opcode, FIXME: debugging only
00123                 bool    debug_thisp; // from 'set info' opcode.
00124 
00125                 uint32  debug_procexclude_offset; // from 'process exclude' opcode, FIXME: debugging only
00126                 bool    has_procexclude; // from 'process exclude' opcode
00127 
00128         private:
00129                 void fold_init(DCUnit *unit, std::deque<Node *> &nodes);
00130                 void fold_ret(DCUnit *unit, std::deque<Node *> &nodes);
00131                 void fold_setinfo(DCUnit *unit, std::deque<Node *> &nodes);
00132                 void fold_procexclude(DCUnit *unit, std::deque<Node *> &nodes);
00133 };
00134 
00135 #endif
00136 

Generated on Fri Jul 27 22:27:15 2007 for pentagram by  doxygen 1.4.7