Thread overview
What kind of mangling has the LDC2 -X JsonFile "deco" field?
Sep 17, 2020
realhet
Sep 17, 2020
Adam D. Ruppe
Sep 17, 2020
Adam D. Ruppe
Sep 17, 2020
realhet
September 17, 2020
Hello,

I'm trying to get information from the JsonFile produced by LDC2, but having no clue how to decode this:

For example:
header: KeywordCat kwCatOf(int k)
  "deco" : "FAyaZE3het8keywords10KeywordCat",

The "deco" field contains the full name of the return type het.keywords.KeywordCat, but in front of that I don't know how to decode that "FAyaZE".

Also this is how a string return type is encoded: "FiZAya"

I tried std.demangle and and online GCC demangler, but no luck.

Anyone can help me telling how to decode these please?

Thank you in advance!
September 17, 2020
On Thursday, 17 September 2020 at 03:06:45 UTC, realhet wrote:
> I'm trying to get information from the JsonFile produced by LDC2, but having no clue how to decode this:
>
> For example:
> header: KeywordCat kwCatOf(int k)
>   "deco" : "FAyaZE3het8keywords10KeywordCat",

That's a D mangle but just of one individual variable, without an attached name. std.demangle looks for the _D prefix and the name so it prolly can't read it.

https://dlang.org/spec/abi.html#name_mangling

But from eyeball it is a extern(D) function taking a string argument and returning a KeywordCat enum..

The "F" means extern(D). After this are the argument list. "Aya" you'll get to recognize as "string", but formally it means "Array (A) of immutable (y) chars (a)". Then "Z" means non-variadic function and this ends the argument list, so the next thing is the return type. "E" means enum, then the name comes with a count of chars in this name piece, then the chars.

September 17, 2020
On Thursday, 17 September 2020 at 03:06:45 UTC, realhet wrote:
> Anyone can help me telling how to decode these please?

so here's a cool trick to get hte other demanglers to help.

Just prepend

_D4name

to the string. so like:


$ ./ddemangle
_D4nameFAyaZE3het8keywords10KeywordCat
het.keywords.KeywordCat name(immutable(char)[])


so then the demangler will recognize it and use your placeholder name while spitting out the rest.

of course you can change that 4name to whatever you want.
September 17, 2020
On Thursday, 17 September 2020 at 04:01:11 UTC, Adam D. Ruppe wrote:
> On Thursday, 17 September 2020 at 03:06:45 UTC, realhet wrote:
>> Anyone can help me telling how to decode these please?
> Just prepend
>
> _D4name

Thank you very much!