Comment #0 by lutger.blijdestijn — 2009-09-20T11:11:41Z
There are four 'attributes' defined in the ABI which std.demangle currently doesn't parse: pure, nothrow, ref and property:
import std.demangle;
void main()
{
assert(demangle("_D3fooFNaNbZv") == "pure nothrow void foo()");
}
I've attached a patch (my first), feedback appreciated if something is not right.
I didn't know how property is supposed to be demangled, so that one is just ignored. Also, this patch assumes all attributes are valid for functions and delegates and just ignores attributes for calling conventions other that D. Again, not sure if that's ok.
Comment #1 by lutger.blijdestijn — 2009-09-20T11:21:53Z
Created attachment 460
support pure,ref,nothrow in std.demangle
Comment #2 by clugdbug — 2009-09-20T11:27:25Z
(In reply to comment #0)
> I didn't know how property is supposed to be demangled, so that one is just
> ignored.
Congratulations, you've found the Easter egg! From the code in mtype.c, it's currently @property.
assert(demangle("_D3fooFNdNaNbZv") == "@property pure nothrow void foo()");
Interesting, eh? But you're quite right to ignore it. It might well change.
Comment #3 by lutger.blijdestijn — 2009-10-05T10:32:14Z
(In reply to comment #2)
> (In reply to comment #0)
> > I didn't know how property is supposed to be demangled, so that one is just
> > ignored.
>
> Congratulations, you've found the Easter egg! From the code in mtype.c, it's
> currently @property.
>
> assert(demangle("_D3fooFNdNaNbZv") == "@property pure nothrow void foo()");
>
> Interesting, eh? But you're quite right to ignore it. It might well change.
Very. Seeing the last release it should be changed to "pure nothrow void foo() @property". I'm curious to see how the property / attribute thing pans out.
Comment #4 by kennytm — 2011-04-23T02:16:46Z
Looks like this has been fixed.
--------------------------
module x;
import core.demangle, std.traits;
@property ref pure nothrow int foo(ref int z) {
return z;
}
@safe void bar() {
}
@trusted void baz() {
}
void main() {
assert(demangle(mangledName!foo) == "pure nothrow ref @property int x.foo(ref int)");
assert(demangle(mangledName!bar) == "@safe void x.bar()");
assert(demangle(mangledName!baz) == "@trusted void x.baz()");
}
--------------------------