tango.core.tools.Demangler

D symbol name demangling
Attempts to demangle D symbols generated by the DMD frontend. (Which is not always technically possible.)

A sample program demangling the names passed as arguments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module demangle;
import tango.core.tools.Demangler;
import tango.io.Stdout;

void usage(){
    Stdout("demangle [--help] [--level 0-9] mangledName1 [mangledName2...]").newline;
}

int main(char[][]args){
    uint start=1;
    if (args.length>1) {
        if (args[start]=="--help"){
            usage();
            ++start;
        }
        if (args[start]=="--level"){
            ++start;
            if (args.length==start || args[start].length!=1 || args[start][0]<'0' || 
                args[start][0]>'9') {
                Stdout("invalid level '")((args.length==start)?"*missing*":args[start])
                    ("' (must be 0-9)").newline;
                usage();
                return 2;
            }
            demangler.verbosity=args[start+1][0]-'0';
            ++start;
        }
    } else {
        usage();
        return 0;
    }
    foreach (n;args[start..$]){
        Stdout(demangler.demangle(n)).newline;
    }
    return 0;
}

License:

tango license, apache 2.0

Authors:

Zygfryd (aka Hxal), Fawzi
char[] decompressSymbol(char[] func, char[]* buf) #
Decompresses a symbol and returns the full symbol, and possibly a reduced buffer space (does something only on windows with DMD.)
class Demangler [public] #
Flexible demangler. Attempts to demangle D symbols generated by the DMD frontend. (Which is not always technically possible.)
uint templateExpansionDepth #
How deeply to recurse printing template parameters, for depths greater than this, an ellipsis is used.
bool foldDefaults #
Skip default members of templates (sole members named after the template.)
bool expandFunctionTypes #
Print types of functions being part of the main symbol.
bool printTypeKind #
For composite types, print the kind (class|struct|etc.) of the type.
void verbosity(uint level) [public] #
Sets the verbosity level of the demangler (template expansion level,...)
this() #
Creates a demangler.
this(uint verbosityLevel) #
Creates a demangler with the given verbosity level.
char[] demangle(char[] input) [public] #
Demangles the given string.
char[] demangle(char[] input, char[] output) [public] #
Demangles the given string using output to hold the result.
struct DemangleInstance #
This represents a single demangling request, and is the place where the real work is done some more cleanup would probably be in order (maybe remove Buffer.)
Demangler demangler [static] #
The default demangler.