Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 /* -*-Mode: c++;-*- (Tell emacs to use c++ mode) */ 00037 #ifndef strtab_INCLUDED 00038 #define strtab_INCLUDED 00039 /* ==================================================================== 00040 * ==================================================================== 00041 * 00042 * 00043 * Description: 00044 * 00045 * String table external interface. 00046 * 00047 * ==================================================================== 00048 * ==================================================================== 00049 */ 00050 00051 00052 00053 #ifndef symtab_idx_INCLUDED 00054 #include "symtab_idx.h" 00055 #endif 00056 00057 //#include "HashTable.h" 00058 //using namespace stlCompatibility; 00059 00060 // From a user point of view, the string table is a collection of unique 00061 // strings, each of which can be indentified by STR_IDX. The actual 00062 // implementation is transparent to the user. 00063 00064 // init an empty table; use by producer (e.g., front end) 00065 // size is string buffer size in bytes 00066 extern void 00067 Initialize_Strtab (UINT32 size); 00068 00069 // initialized the string table with the strtab from an input file 00070 extern void 00071 Initialize_Strtab (const char *buf, UINT32 size); 00072 00073 // add string to string table 00074 extern STR_IDX 00075 Save_Str (const char *str); 00076 00077 // concat two strings and then add to string table 00078 extern STR_IDX 00079 Save_Str2 (const char *s1, const char *s2); 00080 00081 // concat two strings and an int and add to string table 00082 extern STR_IDX 00083 Save_Str2i (const char *s1, const char *s2, UINT i); 00084 00085 extern char * 00086 Index_To_Str (STR_IDX idx); 00087 00088 struct STRING_TABLE 00089 { 00090 char &operator[] (STR_IDX idx) { 00091 return *Index_To_Str (idx); 00092 } 00093 }; 00094 00095 // New code should use Str_Table[idx] to get the string from an index 00096 extern STRING_TABLE Str_Table; 00097 00098 extern UINT32 00099 STR_Table_Size (); 00100 00101 // for compatibility 00102 inline char * 00103 Index_To_Str (STR_IDX idx, void *) { return Index_To_Str (idx); } 00104 00105 #define Str_To_Index(s,t) (s) 00106 00107 // for character array table 00108 extern UINT32 00109 TCON_strtab_size (); 00110 00111 extern char * 00112 TCON_strtab_buffer (); 00113 00114 extern void 00115 Initialize_TCON_strtab (UINT32 size); 00116 00117 extern void 00118 Initialize_TCON_strtab (const char *buf, UINT32 size); 00119 00120 // (similar to strncpy) s1 might not be null-termianted 00121 extern UINT32 00122 Save_StrN (const char *s1, UINT32 len); 00123 00124 extern char * 00125 Index_to_char_array (UINT32 idx); 00126 00127 #ifdef MONGOOSE_BE 00128 00129 #include <map> 00130 using namespace std; 00131 00132 #ifndef mempool_allocator_INCLUDED 00133 #include "mempool_allocator.h" 00134 #endif 00135 00136 // merge in a strtab read from an input file with the current string table; 00137 // returns a mapping from the string indices of the "buf" to the 00138 // corresponding string indices in the merged table. 00139 00140 class STR_IDX_MAP { 00141 private: 00142 00143 00144 struct STR_IDX_compare { 00145 bool operator() (const STR_IDX idx1, const STR_IDX idx2) const 00146 { 00147 return idx1 < idx2; 00148 }}; 00149 00150 typedef map<STR_IDX, STR_IDX, STR_IDX_compare, mempool_allocator<pair<const STR_IDX,STR_IDX> > > 00151 rep_type; 00152 00153 rep_type rep; 00154 00155 public: 00156 00157 STR_IDX_MAP ( rep_type::size_type n = 0, 00158 rep_type::key_compare cmp = rep_type::key_compare(), 00159 rep_type::allocator_type a = rep_type::allocator_type() ) 00160 : rep(cmp) 00161 { } 00162 00163 00164 STR_IDX& operator[](STR_IDX idx) { return rep[idx]; } 00165 STR_IDX operator[](STR_IDX idx) const { 00166 rep_type::const_iterator i = rep.find(idx); 00167 return i != rep.end() ? i->second : STR_IDX(0); 00168 } 00169 00170 }; 00171 00172 extern void 00173 Merge_Strtab (const char *buf, UINT32 size, STR_IDX_MAP& map); 00174 00175 extern void 00176 Merge_TCON_Strtab (const char *buf, UINT32 size, STR_IDX_MAP& map); 00177 00178 #endif // MONGOOSE_BE 00179 00180 00181 #endif /* strtab_INCLUDED */