[Mono-list] C++ to CIL compilers?

Tyson Dowd trd@cs.mu.oz.au
Mon, 21 Jan 2002 09:20:08 +1100

On 20-Jan-2002, Miguel de Icaza <miguel@ximian.com> wrote:
> > Are there any C++ to CIL compilers _except_ Visual C++? 
> Not at this point.  
> > The idea of making component programming and reuse language independent
> > is IMO the best thing about .NET/Mono. But I hardly found any compiler
> > apart from MS's development suites targeting the CIL. As only a C#
> > compiler is planed as part of the Mono Project and as the GCC Project
> > does apparently not plan to add a CIL backend, do I have to invest a
> > substantial sum of money (that I don't have) in a set MS compilers to
> > start using Mono (using a language other than C#)?
> The .NET Framework SDK (free download) contains a C++ compiler that you
> can use.  It is called `cl.exe'.
> As you know, we do lack the resources to build a C++ compiler (that is a
> major task to take on).  My suggestion for anyone who is interested in
> bringing a free C++ compiler to the .NET world is to take the gcc C++
> compiler as a start, keep the "front-end" of the compiler (parsing and
> semantic analysis) and write a CIL backend for it.  
> Significant work needs to happen in the front-end as well to enable dual
> managed/unmanaged compilation and recognize the .NET keywords (stuff
> like __gc). 
> I would start by splitting of the code to avoid making the job on
> yourself harder.  Once a proof of concept compiler can be built, then
> you can figure whether it is possible or worth to bring this back into
> the main gcc code base. 
> Other languages will appear at some point as writing front-ends for CIL
> is relatively trivial given that it cleanly "separates" the phases of
> the compiler.  So the work that you have to do is limited by the CIL
> level.  
> It took me only 8-months of part-time work on the compiler to write a C#
> compiler, so it is something within the scope of a one semester class to
> create other languages.

Sure, if these languages are designed to target CIL and are (therefore)
pretty much just an alternative syntax for C#.

If you want your language to do anything that CIL doesn't directly
support, or you need to interoperate with CIL but your language doesn't
have all the features of CIL (or at least the CLS) then you are going to
have a much tougher time writing a compiler.

C# is going to be the easiest case, as it is practically the same
feature set as CIL.  The more different your language is from C#, the
more work you are going to have to do.

I would certainly think modifying gcc to be like the Managed C++
compiler would be way way more work than 1 semester.

       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd@cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #