Patch corresponding to previous attachment (against file from v1.005)
text/plain
1998
Comments
Comment #0 by thomas-dloop — 2006-11-23T15:09:10Z
The attachment is DMD-0.174's std.demangle with added support for lazy arguments and nested symbols.
Comment #1 by thomas-dloop — 2006-11-23T15:09:55Z
Created attachment 80
demangle.d
Comment #2 by fvbommel — 2006-11-23T16:58:57Z
I was recently working on nested symbol support for std.demangle as well, and ran into a bug. Your version has that same bug:
urxae@ubuntu:~/tmp$ cat test.d
int intfunc() {
void inner() {
}
return 0;
}
class UDT {}
UDT udtfunc() {
void inner () {
}
return new UDT;
}
urxae@ubuntu:~/tmp$ dmd -c test.d
urxae@ubuntu:~/tmp$ nm test.o | grep inner
00000000 T _D4test7intfuncFZi5innerFZv
00000000 T _D4test7udtfuncFZC4test3UDT5innerFZv
urxae@ubuntu:~/tmp$ nm test.o | grep inner | ./demangle
00000000 T int test.intfunc() . void inner()
00000000 T class test.UDT.inner test.udtfunc() . void function()
(same effect for struct UDT & typedef UDT, IIRC)
It's caused by an ambiguity in the mangling. It is caused by several factors:
* Functions have their name first, and their return type last.
* UDTs (structs, classes and typedefs) have a mangled name of multiple parts with no terminator.
* Inner functions are mangled as <mangled outer function> ~ <inner function>
* Inner function names (which comes directly after the mangled outer function) have the same syntax as one part of an UDT name.
All of this causes the name of the inner function to be mistaken for the last part of the return type.
The easiest fix would be for the mangling to change :). A simple terminator char after an UDT name would do it.
Comment #3 by fvbommel — 2007-02-08T10:13:18Z
Created attachment 96
std.demangle with Thomas' patch and some modifications by me.
I've been working a bit on std.demangle again, based on this patch and the latest version from Phobos.
I've made these changes:
* bit -> bool
* Added support for 'M' attribute to functions (which indicates a 'this' or context pointer as last argument)
Comment #4 by fvbommel — 2007-02-08T10:14:09Z
Created attachment 97
Patch corresponding to previous attachment (against file from v1.005)