Demangler prototype
Martin von Loewis
loewis at informatik.hu-berlin.de
Fri Mar 10 20:07:07 UTC 2000
To see whether the mangling mechanism is well-specified, I put a
demangler together, which I'll attach below. It is very rough code, so
excuse the missing documentation :-) I believe it does everything that
has been specified so far, except for the St/Sb compression
short-cuts, and except for local names (Z prefix).
It is written in Python, so you need a Python installation to run
it. It currently work in command-line mode, where the mangled symbol
is passed as an argument, eg.
punica loewis 92 ( ~/work/cxxabi ) > ./demangle.py _Z5firstI3DuoEvT1_
void first<Duo>(/*T1=*/Duo)
You'll notice that it does not process all examples correctly; in
these cases, I either consider the example incorrect, or think that
the mangling mechanism is wrong as specified in the first place. Of
course, there also may be bugs left, please let me know.
While writing this demangler, I *think* I made sure that demangling is
unambiguous in all cases, so the only problem left for proof would be
to show that there is exactly one mangling for every possible
declaration. Eg. I would not catch the case that
foo(void (*)(void))
could be either mangled as _Z3fooPFvvE or _Z3fooPFvE with the current
spec, which does not say whether the empty argument list is mangled as
(void) or not.
Anyway, comments are appreciated.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demangle.py
Type: application/octet-stream
Size: 10028 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20000310/ddb4cb8d/attachment.obj>
More information about the cxx-abi-dev
mailing list