June 29, 2011
Hi all,

Before I go any futher: even if you are interested in this it's pretty much useless in its current state. I hope to have it kind-of workable by the end of the week, no promises though.

So. As part of my continued work on Serenity ( https://github.com/mrmonday/serenity ), a little pre-alpha web framework I've been working on, I've begun work on a D to JavaScript source translator.

Rather than poisoning the world with more C++, I wrote some basic bindings to the dmd frontend in D, which means the whole thing can almost be entirely written in D.

Current state:
 * Can translate:
    - basic flow control
    - functions and their parameters
    - strings and integral types
 * Cannot translate:
    - Loops
    - Variables
    - Classes
    - Pretty much anything
 * No way to inject javascript
 * No support for javascript builtins
   + No validation for either of the above
 * No checking for name conflicts with js keywords
 * No windows support - there are some hacks to interface with more C++
   than D allows out of the box, they're GCC specific, meaning linux/osx
   /bsd only. Could work in mingw, with gdc, I haven't tried.
 * No optimizer - this will eventually depend on having the closure
   compiler installed
 * One-to-one translation, not semantically equivalent to D
   + Making it semantically equivalent would slow resulting code
     significantly
   + This will probably be resolved with a version() statement later on
   + This said, I will try and match as best I can without a slowdown
 * Missing pre-defined version identifiers
 * Some semantic error checking is done when creating object files
   in dmd, this checking is not done
 * A lot of it's rather hacky and needs cleaning up
 * I have no idea how it's licensed, I'll need to discuss this with
   Walter
 * Outputs to stdout currently, doesn't handle multiple files

You can find the source code at:

https://github.com/mrmonday/dmd

In the js branch. Again, it's not worth looking at yet, unless you're curious about the C++ bindings. Note that they don't bind the entirety of the dmd frontend, just what I've needed so far and a bit more.

There was something else I was going to mention, I forget what though.

-- 
Robert
http://octarineparrot.com/
June 29, 2011
On 29/06/2011 21:57, Robert Clipsham wrote:
> There was something else I was going to mention, I forget what though.

I remembered. The D source requires dmd pull request #131 to be merged if you want to compile it (which you don't).

-- 
Robert
http://octarineparrot.com/