dmd json file output

Rainer Schuetze r.sagitario at gmx.de
Tue Jan 22 00:02:20 PST 2013



On 21.01.2013 08:27, Walter Bright wrote:
> The current version is pretty verbose. For:
>
>      int ***x;
>
> it will emit as the type:
>
> "type" : {
>          "kind" : "pointer",
>          "pretty" : "int***",
>          "targetType" : {
>                  "kind" : "pointer",
>                  "pretty" : "int**",
>                  "targetType" : {
>                          "kind" : "pointer",
>                          "pretty" : "int*",
>                          "targetType" : {
>                                  "kind" : "int",
>                                  "pretty" : "int"
>                          }
>                  }
>          }
> }
>
> I find this to be excessive, and it helps to produce truly gigantic
> .json files. I think it's better to just put out the deco for the type:
>
> "type" : "PPPi"
>
> But, you might say, that is not user friendly! Nope, it isn't. But the
> .json output is for a machine to read, not humans, and the deco types
> are very space efficient, and are trivial to convert to whatever data
> structure the reader needs. Much easier than the verbose thing.
>
> What do you think?

I agree the verbose output is overkill.

Considering that the demangling in druntime still has a number of open 
issues (e.g. http://d.puremagic.com/issues/show_bug.cgi?id=3034, 
http://d.puremagic.com/issues/show_bug.cgi?id=6045) and that there are 
ambiguities in the name mangling (e.g. 
http://d.puremagic.com/issues/show_bug.cgi?id=5957, 
http://d.puremagic.com/issues/show_bug.cgi?id=4268), my first reaction 
was that it might be better to provide a function to parse the pretty 
type. It is not too difficult and would be a nice start for the 
lexer/parser topic, but might be burdened with new bugs.

Considering function types, the deco does not contain any function 
argument identifiers anymore, but these are very useful for tooltips in 
an IDE like Visual D.

As a compromise, the type chould just contain the mangled and the pretty 
name:

 > "type" : {
 >          "mangled" : "PPPi",
 >          "pretty" : "int***",
 > }




More information about the Digitalmars-d mailing list