[antlr-interest] RE: C# vs MSIL Output

Daniel Gackle gackle at shaw.ca
Mon Mar 8 22:03:59 PST 2004


> As far as I can tell, the ICompiler object created by
> CSharpCodeProvider.CreateCompiler converts the CodeDom
> to C# and invokes csc.exe.

That's right. Even if you ask the CodeDom for an in-memory assembly, it
still generates C# source code and parses it all over again before turning
it into IL. It's not possible to use the CodeDom to generate IL directly.
That's what Reflection.Emit does. However, we did some performance tests and
found that, once you get past the compilation of the C#, code generated via
the CodeDom doesn't run significantly slower than code generated via
Reflection.Emit. As a result, we opted for the convenience of the
higher-level CodeDom API.

Daniel

________________________________________________________________________

Message: 6
   Date: Sun, 7 Mar 2004 18:28:08 -0600
   From: "Mike Bresnahan" <mbresnah at visi.com>
Subject: RE: C# vs MSIL Output

> Actually you can generate IL once you have a CodeDom tree - there are
> classes in the Microsoft.CSharp namespace:
>
> CSharpCodeProvider.CreateCompiler
> CSharpCodeProvider.CreateGenerator
> CSharpCodeProvider.CreateParser

As far as I can tell, the ICompiler object created by
CSharpCodeProvider.CreateCompiler converts the CodeDom to C# and invokes
csc.exe.  I'm guessing CodeDom is not transformed directly to MSIL because
csc.exe uses a different data structure for storing the parsed source code.
Until this internal data structure and CodeDom are the same or someone
writes a new compiler, we will be stuck transforming CodeDom to source code
as an intermediate step.

What's interesting is that there is an option to create the compiled
assembly in-memory instead of in a temporary file.  I'm guessing this means
that csc.exe outputs the assembly to stdout or through some other IPC
mechanism, however "csc.exe -help" does not list such and option.

Mike Bresnahan



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list