Intoduction:
Most of the .NET compatible languages (like C# or VB.NET) while creating managed
code, translate your source code into Microsoft intermediate language (MSIL),
which is a CPU-independent set of instructions that can be efficiently
converted to native code. MSIL (or simply IL) includes instructions for
loading, storing, initializing, and calling methods on objects, as well as
instructions for arithmetic and logical operations, control flow, direct memory
access, exception handling, and other operations. So, it is not wrong to say
that IL is the base language for all .NET languages.
DotNet framework provides the following tools for working with IL code:
-
MSIL Assembler
(ILAsm.exe) The MSIL Assembler generates a portable executable (PE) file from
IL files.
-
MSIL Disassembler (ILDAsm.exe) The MSIL Disassembler is a companion tool
to the MSIL Assembler. Ildasm.exe takes a portable executable (PE) file that
contains Microsoft intermediate language (MSIL) code and creates a text file
suitable as input to Ilasm.exe.
This presents a very interesting and powerful option of doing round-trip
engineering. MSIL round-trip technology gives you the ability to convert an
assembly into IL (using MSIL Disassembler - Ildasm.exe), making modifications
to the IL file and then reassembling the IL (using MSIL Assembler -ilasm.exe)
to produce the modified assembly.
Think also of the ability to do all this programmatically.
A very powerful example of this possibility is to create an Aspect
compiler for doing Aspect Oriented Programming in DotNet. This compiler could
convert any assembly into IL, inject aspect code into it, and reassemble it to
created the aspected assembly!!
Objective:
The objective of this project is to create a managed parser for MSIL (Microsoft
Intermediate Language). This parser can be used to create an IL 'CodeDOM graph'
or 'CodeDOM tree'. With this the user should be able to navigate through the IL
code and be able to programmatically add/remove IL code.
As a first step towards this, I have created an IL lexical analyzer and an IL
grammar analyzer. I used a tool called
GOLD parser builder which is similar to lex and yacc.
Please send your queries to
Developer Mailing List
|