00001 /* 00002 * Copyright (C) 2001-2002 The Exult Team 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef UCDATA_H 00020 #define UCDATA_H 00021 00022 #include <string> 00023 #include <cstdio> 00024 #include <fstream> 00025 #include <iostream> 00026 00027 #include "ucfunc.h" 00028 00029 class UCData 00030 { 00031 public: 00032 UCData(); 00033 ~UCData(); 00034 00035 void dump_unknown_opcodes(); 00036 void dump_unknown_intrinsics(); 00037 00038 void parse_params(const unsigned int argc, char **argv); 00039 void open_usecode(const std::string &filename); 00040 void load_funcs(); 00041 00042 void disassamble(); 00043 void dump_flags(std::ostream &o); 00044 void output_extern_header(std::ostream &o); 00045 00046 std::string output_redirect() const { return _output_redirect; }; 00047 std::string input_usecode_file() const { return _input_usecode_file; }; 00048 00049 bool fail() const { return _file.fail(); }; 00050 00051 const std::map<unsigned int, UCFuncSet> &funcmap() { return _funcmap; }; 00052 00053 const UCOptions &opt() { return options; }; 00054 00055 UCOptions options; 00056 00057 private: 00058 00059 void file_open(const std::string &filename); 00060 void file_seek_start() { _file.seekg(0, std::ios::beg); }; 00061 void file_seek_end() { _file.seekg(0, std::ios::end); }; 00062 00063 std::ifstream _file; 00064 00065 std::string _output_redirect; 00066 std::string _input_usecode_file; 00067 00068 unsigned int _funcid; 00069 00070 std::vector<UCc> _codes; 00071 00072 std::vector<UCFunc *> _funcs; 00073 00074 /* Just a quick mapping between funcs and basic data on them. 00075 Just something we can quickly pass to the parsing functions 00076 so we don't have to give them an entire function to play with. */ 00077 FuncMap _funcmap; 00078 00079 long _search_opcode; 00080 long _search_intrinsic; 00081 std::vector<unsigned int> search_funcs; 00082 }; 00083 00084 #endif 00085