[Mono-list] Implementing attribute-based code generation
Jambunathan K
Jambunathan K <kjambunathan.devel@gmail.com>
Thu, 13 Jan 2005 12:59:18 +0530
Stephen
I think looking at code paths for handling ConditionalAttribute in C#
compiler would be a good starting point.
In addition mcs/mbas (VB.NET compiler) code could also provide some
good starting points.
mbas generates "code on the run" for "late binding" and "conversions"
between the primitive types. It usually inserts a call to methods in
Microsoft.VisualBasic.CompilerServices namespace for providing these
services. So searching for "CompilerServices" in mcs/mbas tree should
give you an idea of how an invocation can be inserted in to the
emitted code and the point where it could be done. Btw, mbas was
forked off mcs. So you should be able to switch easily between the two
code bases.
Regards,
Jambunathan K.
On Wed, 12 Jan 2005 18:48:02 -0500, Stephen Touset <stephen@touset.org> wrote:
> I'm looking into the potential of writing code to allow mono to have
> extensions. As a first foray into the idea, I'm going to try writing a
> module that would look for specific attributes on methods and classes,
> and use those to generate code that would go into the marked methods and
> all methods of the marked classes, respectively.
>
> However, looking at the mono source code, it seems to be very complex.
> I'm looking for hints as to the best place to put the hooks for the
> extension, because of this. My first idea would be to put this after the
> parsing of the source tree, so that I can manipulate the methods as
> they're in memory. However, I can't seem to find simple ways to navigate
> through the memory representation of the source tree. Can anyone give me
> a brief pointer to where I should be looking?
>
> --
> Stephen Touset <stephen@touset.org>
>
>
>