.NET/C#'s CodeDOM and Flare

From: Ben Houston (ben@exocortex.org)
Date: Sat Jun 15 2002 - 01:27:56 MDT


Hello,

I'm sure by now most people on this list are familiar with my love of
modern object oriented languages such as C#. Today I'm going to explain
a little about C#'s and .NET's CodeDOM. The term 'CodeDOM' is an
acronym for Code Document Object Model. Basically it is a way to
represent piece of code in C# or a similar language as a tree or graph
of objects. The root object in a standard CodeDOM is
System.CodeDom.CodeCompileUnit. This root object contains a list of
System.CodeDom.CodeNamespaces. Each CodeNamespace can then contain a
list of CodeTypeDeclarations -- the common root for reference types,
value types and enumerations. I won't bore all you with the details but
there are objects that can represent variables, functions, if
statements, binary expressions, etc...

For all the details check it out on MSDN:
 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfsystemcodedom.asp

It is very easy to convert from CodeDOM into C# code. Just pass the
root, CodeCompileUnit, to the CodeDOM.CodeGenerator and out comes
formatted C# or pass it to CodeDOM.CodeCompiler to get compiled
binaries. I should add that a code CodeDOM theoretically can be
converted into any language that supports the various elements used.
 
Interestly, you can now generate from C# code its corresponding CodeDOM
using a new tool by Ivan Zderadicka. This means that you can load in a
piece of source code and manipulate it in a semi-compiled and highly
information representation. Imagine the possibilities.... ;-)
  http://www.c-sharpcorner.com/Code/2002/June/CsCodeParser.asp

The three representations of code in this model:
  1. [C# text] The human readable C# text
  2. [CodeDOM] Computer malleable CodeDOM graphs
  3. [Compiled] Computer executable compiled assemblies.

The transitions between the representations already discussed:
  [C# text] --> [CodeDOM]
  [CodeDOM] --> [C# text]
  [CodeDOM] --> [Compiled]

The only missing transition is the [Compiled] --> [CodeDOM]. Hopefully
it will not take too long for someone to develop a decent decompiler.
:-)

I've tried writing some code that manipulates CodeDOMs as well as code
that manipulates human readable C# code for the purposes of execution
time code generation. So far I have found it to be fairly challenging.
I almost feel as if there is some useful tool that is still not build
yet. Maybe I just need some more abstract programming concepts such as
ADTs or functional blocks in a parallel structure to the current
CodeDOM? What do you all think?

I would suggest that CodeDOM really does bridge the gap between Flare
and traditional non-XML based languages.

Cheers,
Ben Houston
http://www.exocortex.org/dsp
http://www.exocortex.org/3dengine



This archive was generated by hypermail 2.1.5 : Wed Jul 17 2013 - 04:00:39 MDT