On Wed, Jul 10, 2013 at 10:30 AM, Adam D. Ruppe <span dir="ltr"><<a href="mailto:destructionator@gmail.com" target="_blank">destructionator@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Wednesday, 10 July 2013 at 16:30:25 UTC, Timothee Cour wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Do you have a pointer for that function in dmd ?<br>
</blockquote>
<br></div>
The compiler doesn't do it as one function, I mean it can parse as string and mangle it in the process of compiling code.<br>
<br>
To go from demangled string => mangled string, you'd first parse the demangled string as a declaration and turn it into a symbol, then mangle that symbol.<br>
<br>
<br>
But.... if you just want to do really simple cases, maybe this isn't too hard. I just quickly slapped this file together:<br>
<br>
<a href="http://arsdnet.net/dcode/mangle.d" target="_blank">http://arsdnet.net/dcode/<u></u>mangle.d</a><br>
<br>
<br>
It is very basic, but might work for a lot of cases - it handled some basic functions I tried. Perhaps not too hard to add support for more from here.<br>
<br>
As you can see by looking at the code, the way it works is:<br>
<br>
1) tokenize the input string (it does this in a stupid way, and doesn't know all of D's symbols and keywords, but it doesn't have to be too smart since demangle produces fairly predictable input, so I think it will be ok).<br>

<br>
2) runs a simple, stupid parser to get the components of the function - return type, name, and arguments. To add support for templates, extern(C), and so on, this would need to be expanded.<br>
<br>
3) put the pieces back together in a wholly mangled form, borrowing one helper array from core.demangle.<br>
<br>
<br>
<br>
There's a main function at the bottom of the file that does one of the few tests I tried with it.<br>
</blockquote></div><br><div><br></div><div>also, can you push it to your misc-stuff-including-D-programming-language-web-stuff git repo?</div><div><br></div>