D to Javascript converter (a hacked up dmd)

Daniel Murphy yebblies at nospamgmail.com
Fri Mar 2 16:56:46 PST 2012


"Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
news:omhitgvibquioulpcxxq at forum.dlang.org...
>
> If I add a way to instead put those var declarations in
> function scope, it is cleaner - no globals - and the same
> thing Javascript itself would do anyway!
>
>
> I'll have to redo the string buffering to make that though,
> so it will take some code to do it. Dumping it in the global
> was simple to implement with what was already there.
>

Btw, in VarDeclaration::toMicroD you're using microd_decl23 as the sink, 
which results in all var declarations getting doubled.  The problem with 
globals not getting default initialized is here too, it's only using 
explicit initializers.  Something like this should work:


// set sink to be one of the normal buffers, not a tee

sink(" = ");
if (init)
    init->toMicroD(sink);
else
    type->defaultInit(0)->toMicroD(sink);
sink(";\n"); 




More information about the Digitalmars-d-announce mailing list