ajk said:
How many real .NET compilers exist part from the standard ones from
Microsoft?
There are quite a few. MS is close to releasing F#. Fujitsu has a Cobol
compiler for .NET. There are also Eiffel compilers, Delphi compilers, etc.
Not sure the full extent. Not sure if their last step is the assembler or
not.
I got the impression from reading an ILAsm book that most
existing .NET compilers generate ILAsm instead of MSIL (judging from
the book's topic it may not be a complete surprise).
ILASM is the IL assembler and is a piece that creates the Portable
Executable from IL. The compilers create IL. This is a very high level
explanation. I would have to look at the book to see context of what the
author is saying about it, but now that you have clarified this makes sense.
The author may be differentiating the IL as a flat file from IL as a PE. Not
sure.
Is it because it
is so difficult to generate MSIL? or is because they want to be
independent of MSIL which also could change like a new version
of .NET?
IL is lower level than languages like C#, for sure. To actually package it
as an assembly is even more involved. I have not gotten into internals for
so long, I am not sure 100% how the MS compilers work and they may end up
using ILASM for the final step.
How long in your opinion would it take to create a compiler for say
JavaScript that generates MSIL code - roughly? Just to get a feel of
it.
Someone created Assembler.NET in a month or two. However, if someone knows
assembly that well, they are pretty advanced. If you want to tackle
JavaScript.NET, I would look for a book on compilers for .NET. I seem to
remember seeing one. Not sure if it was mainstream. There are also documents
in the .NET Framework install folders under the tools section that might
help. Dan Appleman's book on Obfuscation also has some great info, as does
Jeffrey Richter's book.
The amount of time it would take would depend on experience level and
determination (and time, of course). What would be your goal for doing this?
It seems to me that it would be best to generate ILAsm in order to get
the control and functionality without also having to lock oneself into
a particular .NET version?
If you mean to produce IL and then use the assembler for the PE, that may be
the only way. It would certainly make sense.
Lutz Roeder's reflector might be something to look at, if you can reverse
engineer it. Understanding how someone breaks apart a PE is a wonderful
learning experience. There may be some open source implementations out
there. Also the Mono project, which contains its own compilers would be a
good thing to look at. Mono is completely open source.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#
or just read it:
http://feeds.feedburner.com/GregoryBeamer
********************************************
| Think outside the box! |
********************************************