[Mono-bugs] [Bug 74951][Wis] New - Proposal: code manipulation stack
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sat May 14 17:07:28 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by dsilva at ccs.neu.edu.
http://bugzilla.ximian.com/show_bug.cgi?id=74951
--- shadow/74951 2005-05-14 17:07:28.000000000 -0400
+++ shadow/74951.tmp.25050 2005-05-14 17:07:28.000000000 -0400
@@ -0,0 +1,96 @@
+Bug#: 74951
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: Mono.Cecil
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: dsilva at ccs.neu.edu
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Proposal: code manipulation stack
+
+There are currently various ways to read, write, and otherwise manipulate
+C# trees and MSIL bytecode. This report proposes a code manipulation stack
+to unify many of these efforts.
+
+BACKGROUND
+
+These are the libraries of which I am currently aware:
+
+- Mono.CodeGeneration, by Lluis Sanchez Gual. Provides an imperative
+interface to generating MSIL through C#-like constructs.
+http://primates.ximian.com/~lluis/blog/pivot/entry.php?id=34
+
+- The Mono C# compiler internal AST and backend. The Mono C# compiler is
+itself a .Net program.
+
+- Microsoft .Net Reflection. The System.Reflection.Emit namespace provides
+a low-level interface to build MSIL instructions and assemblies.
+http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemReflectionEmit.asp
+
+- AbsIL (AbstractIL), by Don Syme at Microsoft Research. An OCaml and F#
+library for manipulating MSIL. Also provides ILX (the library), which
+generates ILX (the language), an MSIL extension that efficiently encodes
+discriminated unions, first-class function values and generics as MSIL.
+http://research.microsoft.com/projects/ilx/absil.aspx
+
+- Mono.Cecil. Provides a bytecode parser and will provide the reverse
+direction in the future.
+http://www.mono-project.com/Cecil
+
+- RAIL, the Runtime Assembly Instrumentation Library, by the Dependable
+Systems Group at the University of Coimbra. Similar to Cecil.
+http://rail.dei.uc.pt/
+
+- AspectDNG, by Thomas Gil and Jean-Baptiste Evain at DotNetGuru. Builds
+atop RAIL to provide a .Net aspect weaver. Also provides ILML, an MSIL
+meta-language library.
+http://aspectdng.sourceforge.net/
+
+- PERWAPI, the PE File Reader/Writer API, by the PL and Systems group at
+the Queensland University of Technology. Similar to RAIL and Cecil.
+http://www.plas.fit.qut.edu.au/perwapi/Default.aspx
+
+
+MOTIVATION
+
+As the Mono C# compiler is a .Net program, it makes sense to expose its
+interfaces for generating abstract syntax trees (representing C# code),
+intermediate representation trees (common across other .Net compilers like
+mbas?), and code streams.
+
+Mono.CodeGeneration goes straight from C#-like constructs to a live .Net
+type through Reflection.Emit, but it would also be a great interface to
+create MCS AST objects. Those can then be transformed into Cecil objects.
+ Cecil provides a codegen interface very similar to Reflection.Emit, but
+can serve as a potentially improved library for code-manipulation
+developers, since only Microsoft can change the Emit interface.
+
+Providing a comprehensive path from bytecode to code trees and back makes
+it easier to write code loading, generation, analysis, manipulation, and
+optimization tools. More tools, of course, makes Mono and the .Net
+platform more interesting.
+
+CODE MANIPULATION INTERFACE
+
+A good set of functions for code generation would be:
+
+ParseCSharpModule : String -> Mono.MCS.AST.Module
+ParseCSharp|Expression, Type, Method| : String -> Mono.MCS.AST.*
+Transform : Mono.CodeGeneration.* -> Mono.MCS.AST.*
+Analyze : Mono.MCS.AST.* -> Mono.MCS.IR.*
+Compile : Mono.MCS.IR.* -> Mono.Cecil.*
+Optimize : Mono.MCS.Cecil.* -> Mono.MCS.Cecil.*
+Assemble : Mono.Cecil.* -> System.Reflection.Emit.*
+
+And a set of functions for code parsing:
+
+Disassemble : ByteStream -> Mono.Cecil.IAssemblyDefinition
+Decompile : Mono.Cecil.* -> Mono.MCS.IR.*
More information about the mono-bugs
mailing list