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

Ney, Richard richard.ney at aspect.com
Mon Mar 8 20:30:19 PST 2004


Mike,

I've included a sample tree grammar that generates the body of my simple
expression evaluators. The classes you are looking for are in the
System.Reflection.Emit namespace. They allow you to generate classes in
memory using MSIL. Now one thing I will point out is that when you
generate in memory MSIL you still get all the abilities of .NET so you
can include a broiler plate superclass that has common methods that can
use in you MSIL. If you are looking at MSIL I assume you have discovered
ILDASM.exe which will allow you to view code you have written in C# as
MSIL. Also there is an option you can set during debugging on the Emit
object that will save the class to a file so you can examine it with
MSIL. I hope this helps get you started.

-Richard

-----Original Message-----
From: Mike Bresnahan [mailto:mbresnah at visi.com] 
Sent: Monday, March 08, 2004 5:55 PM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] Re: C# vs MSIL Output

> I have an application that converts data fetched from a database with
> one schema into the data model for a logical schema. I use the ANTLR
> with C# and I have an SQL Parser that generates a bunch of ASTs that
> represent each column in the logical query and which physical columns
> are used to make render it. The tree parser is excellent for doing
> ILGenerator.Emit calls to create MSIL in memory to make the
> transformation and the performance is very good.

Does your emitted IL perform selections, cartesian products,
projections,
unions, intersections, etc?

Is your source code freely available?

> Also from a security point of view dropping C# files onto the disk and
> compiling so you can load them into your application domain. This
opens
> the door to rouge code insertion since there is a small lag between
the
> time you generate the file, compile it and load it. I admit this is a
> small window and if random file names are used hard to do but it is
> possible.

Good point.  The option
System.CodeDom.Compiler.CompilerParameters.GenerateInMemory states that
the
resultant assembly is generated in memory, not on disk.  However I do
not
know if the compiler uses intermediate temporary files.

Mike Bresnahan



 
Yahoo! Groups Links



 



 
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/
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExpressionTreeParser.g
Type: application/octet-stream
Size: 24096 bytes
Desc: ExpressionTreeParser.g
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20040308/9efb9279/ExpressionTreeParser.obj


More information about the antlr-interest mailing list