]> git.tdb.fi Git - libs/core.git/blob - source/debug/demangle.cpp
Make this thing actually compile
[libs/core.git] / source / debug / demangle.cpp
1 /* $Id$
2
3 This file is part of libmspcore
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7 #include "demangle.h"
8
9 using namespace std;
10
11 namespace Msp {
12 namespace Debug {
13
14 string demangle_gcc3(const string &sym)
15 {
16         string result;
17
18         if(sym.compare(0, 2, "_Z"))
19                 return result;
20
21         string::const_iterator i=sym.begin()+2;
22
23         bool nested=(*i=='N');
24         bool first=true;
25         while(first || (nested && *i!='E'))
26         {
27                 unsigned len=0;
28                 for(; isdigit(*i); ++i)
29                         len=len*10+(*i-'0');
30                 string::const_iterator j=i+len;
31
32                 if(!first)
33                         result.append("::");
34                 result.append(i, j);
35
36                 first=false;
37         }
38
39         if(nested)
40                 ++i;
41
42         for(; i!=sym.end(); ++i)
43         {
44                 bool ref=(*i=='R');
45                 if(ref) ++i;
46         }
47
48         return result;
49 }
50
51 } // namespace Debug
52 } // namespace Msp