28 #include <boost/format.hpp>
29 #include <boost/multi_index_container.hpp>
30 #include <boost/multi_index/sequenced_index.hpp>
31 #include <boost/multi_index/ordered_index.hpp>
32 #include <boost/multi_index/member.hpp>
39 using boost::multi_index_container;
40 using namespace boost::multi_index;
50 static void reset() { n_next = 0; }
53 std::cout <<
'\t' <<
n <<
" " <<
key <<
'\n';
84 static bool interpret_typeletter(
const char c, std::string &type) {
86 case 'v': type =
"void";
return true;
87 case 'w': type =
"wchar_t";
return true;
88 case 'b': type =
"bool";
return true;
89 case 'c': type =
"char";
return true;
90 case 'a': type =
"schar";
return true;
91 case 'h': type =
"uchar";
return true;
92 case 's': type =
"short";
return true;
93 case 't': type =
"ushort";
return true;
94 case 'i': type =
"int";
return true;
95 case 'j': type =
"uint";
return true;
96 case 'l': type =
"long";
return true;
97 case 'm': type =
"ulong";
return true;
98 case 'x': type =
"long long";
return true;
99 case 'y': type =
"ulong long";
return true;
100 case 'n': type =
"__int128";
return true;
101 case 'o': type =
"__uint128";
return true;
102 case 'f': type =
"float";
return true;
103 case 'd': type =
"double";
return true;
104 case 'e': type =
"long double";
return true;
105 case 'g': type =
"__float128";
return true;
106 case 'z': type =
"...";
return true;
107 case 'u': type =
"vendor extended type";
return true;
108 default:
return false;
115 typedef multi_index_container<
118 ordered_unique<tag<n>,
119 member<Symbol, int, &Symbol::n> >,
120 ordered_unique<tag<key>,
121 member<Symbol, std::string, &Symbol::key> >
124 typedef SymbolTable::index<n>::type::iterator nIterator;
125 typedef SymbolTable::index<key>::type::iterator keyIterator;
131 SymbolTable::index<n>::type &nIndex = st.get<
n>();
132 SymbolTable::index<key>::type &keyIndex = st.get<
key>();
136 std::string typeName(
"");
137 const char *ptr = _typeName.c_str();
139 if (*ptr ==
'r' || *ptr ==
'V' || *ptr ==
'K') {
143 if (*ptr ==
'P') ptr++;
145 std::string currentSymbol =
"";
146 std::stack<char> typeStack;
148 int lastTokenWasType = 0;
149 while (*ptr !=
'\0') {
156 if (typeStack.empty()) {
157 typeStack.push(
'\a');
160 if (typeStack.top() ==
'I') {
162 }
else if (typeStack.top() ==
'L') {
164 }
else if (typeStack.top() ==
'N') {
169 if (!typeStack.empty() && typeStack.top() ==
'I') {
170 if (*ptr !=
'E' && typeName[typeName.size() - 1] !=
'<') {
177 typeStack.push(*ptr++);
183 typeStack.push(*ptr++);
187 if (interpret_typeletter(*ptr, type)) {
188 typeName +=
"(" + type +
')';
195 typeName +=
'-'; ptr++;
197 while (*ptr !=
'\0' && *ptr !=
'E') {
202 typeStack.push(*ptr++);
208 case 't': typeName +=
"::std::";
break;
209 case 'a': typeName +=
"::std::allocator";
break;
210 case 'b': typeName +=
"::std::basic_string";
break;
211 case 's': typeName +=
"::std::basic_string<char,::std::char_traits<char>,::std::allocator<char>>";
break;
212 case 'i': typeName +=
"::std::basic_istream<char, std::char_traits<char> >";
break;
213 case 'o': typeName +=
"::std::basic_ostream<char,std::char_traits<char>>";
break;
214 case 'd': typeName +=
"::std::basic_iostream<char,std::char_traits<char>>";
break;
221 }
else if (isdigit(*ptr) || isupper(*ptr)) {
222 while (isdigit(*ptr) || isupper(*ptr)) {
224 subst = 36*subst + (*ptr -
'0');
226 subst = 36*subst + 10 + (*ptr -
'A');
231 assert (*ptr ==
'_');
235 nIterator sym = nIndex.find(subst);
236 if (sym == nIndex.end()) {
239 typeName += sym->key;
247 case '0':
case '1':
case '2':
case '3':
case '4':
248 case '5':
case '6':
case '7':
case '8':
case '9':
250 const int len = atoi(ptr++);
251 while (isdigit(*ptr)) ptr++;
253 std::string
name =
"";
254 for (
int i = 0; *ptr !=
'\0' && i < len; i++) {
258 if (currentSymbol !=
"") {
259 currentSymbol +=
"::";
263 currentSymbol +=
name;
266 if (keyIndex.find(currentSymbol) == keyIndex.end()) {
267 st.insert(currentSymbol);
274 if (interpret_typeletter(*ptr, type)) {
275 if (lastTokenWasType > 0) {
279 lastTokenWasType = 2;
288 static volatile bool dumpSymbolTable =
false;
289 if (dumpSymbolTable) {
292 for (
unsigned int i = 0; i < st.size(); i++) {
293 nIterator el = nIndex.find(2);
294 if (el != nIndex.end()) {
std::string demangleType(std::string const _typeName)
table::Key< std::string > name