www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 588] New: lazy argument and nested symbol support to std.demangle

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=588

           Summary: lazy argument and nested symbol support to std.demangle
           Product: D
           Version: 0.174
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: patch
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn


The attachment is DMD-0.174's std.demangle with added support for lazy
arguments and nested symbols.


-- 
Nov 23 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=588






Created an attachment (id=80)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=80&action=view)
demangle.d


-- 
Nov 23 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=588






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.


-- 
Nov 23 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=588


fvbommel wxs.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------

           obsolete|                            |





Created an attachment (id=96)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=96&action=view)
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)


-- 
Feb 08 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=588






Created an attachment (id=97)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=97&action=view)
Patch corresponding to previous attachment (against file from v1.005)


-- 
Feb 08 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=588


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 1.019 and 2.003


-- 
Jul 30 2007