Create a generator


My personal goal is to use this to target microprocessors (like the SX chip, or more generally Pics). In any case it would be nice to attach some sort of generator to this - maybe there is an IL writer out there somewhere that needs a friend : ).


AdamStevenson wrote Mar 20, 2008 at 5:09 AM

I would be interested in working with someone on this. :)

nesteruk wrote Aug 13, 2008 at 11:57 AM

Well, there is a source code generator (see the ToSource() method prevalent in most structures). Compiling to IL is easy if you've just generated C# with ToSource(). But if you need to compile from another language, or if you want to compile directly to IL, I'm afraid you might have to overload ToSource() in every single element in order to get the result you're after.

derchoff wrote Aug 14, 2008 at 1:50 PM


I do not think the ToSource is the best way. A point of start could be the graph visitor ( very similar to the SharpDevelop graph visitor ) i added some time ago.
But, until a resolver is fully functionnal it will never work fine because it can remains a lot of ambigous node.

dougday wrote Dec 18, 2008 at 5:17 PM

A better way would be to eliminate the ToSource() method on each object, and create a serialization structure. For example, you'd have a CSharpSerializer that serializes a graph structure into C# source code. Generally, a serialization factory model works well for this. Then, in the cases of IL, or VB (which I'm sure people would like to see), there could be similar serialization classes.


debreuil wrote Dec 19, 2008 at 7:45 AM

I agree you want to go from a graph (or some form of intermediate representation) for this kind of thing, but generally I add a 'ToSource' just because it is specific to the language being parsed. I use it for debugging a lot in the initial stages, and it is just handier to have right on the class at that time. IL could be a special case here too I guess, in the sense that (in my view) .Net languages are just a high level view of IL -- then again C# can be used for things that have nothing to do with IL, so I probably wouldn't go that route. Ideally any generator would run from IL though, it is a perfect IR for C#, it is somewhat neutral, and a lot easier to generate from. Esp for reason number three ; ).

Hopefully this recession eventually allows us some of our time back...

wrote Feb 14, 2013 at 6:33 PM