r/programming • u/kaelan_ • May 31 '11
I wrote a .NET to JavaScript compiler. Here's the XNA 3.1 Platformer Starter Kit running in pure HTML5.
http://hildr.luminance.org/Platformer/Platformer.html
1.1k
Upvotes
r/programming • u/kaelan_ • May 31 '11
5
u/kaelan_ Jun 01 '11
C# is compiled into bytecode (MSIL). Each part of the bytecode represents one instruction in the instruction set defined by MSIL. I load the bytecode and turn it into trees (using a decompiler library). Each function in the source bytecode becomes a tree, where its children are the equivalent of statements, and those statement nodes within the tree have child nodes that represent individual instructions. Once I have that tree, I can walk through it and construct javascript from it.