1 // Written in the D programming language.
4 * Demangle D mangled names.
6 * Copyright: Copyright The D Language Foundation 2000 - 2009.
7 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
8 * Authors: $(HTTP digitalmars.com, Walter Bright),
9 * Thomas K$(UUML)hne, Frits van Bommel
10 * Source: $(PHOBOSSRC std/demangle.d)
11 * $(SCRIPT inhibitQuickIndex = 1;)
14 * Copyright The D Language Foundation 2000 - 2009.
15 * Distributed under the Boost Software License, Version 1.0.
16 * (See accompanying file LICENSE_1_0.txt or copy at
17 * http://www.boost.org/LICENSE_1_0.txt)
22 Demangle D mangled names.
25 name = the mangled name
27 A `string`. If it is not a D mangled name, it returns its argument name.
29 string
demangle(string name
) @safe pure nothrow
31 import core
.demangle
: demangle
;
32 import std
.exception
: assumeUnique
;
33 auto ret = demangle(name
);
34 return () @trusted { return ret.assumeUnique
; } ();
41 assert(demangle("_D1a1bi") == "int a.b");
42 // char array foo in module test
43 assert(demangle("_D4test3fooAa") == "char[] test.foo");
47 This program reads standard in and writes it to standard out,
48 pretty-printing any found D mangled names.
52 import std
.ascii
: isAlphaNum
;
53 import std
.algorithm
.iteration
: chunkBy
, joiner
, map
;
54 import std
.algorithm
.mutation
: copy
;
56 import std
.demangle
: demangle
;
57 import std
.functional
: pipe
;
58 import std
.stdio
: stdin
, stdout
;
64 l
=> l
.chunkBy
!(a
=> isAlphaNum(a
) || a
== '_')
65 .map
!(a
=> a
[1].pipe
!(to
!string
, demangle
)).joiner
67 .copy(stdout
.lockingTextWriter
);