Published on
March 26, 2007 in
Pictures.
Heute werde ich endlich meine Steuererklärung beim Finanzamt Freiburg-Stadt einreichen. Für Nicht-Ortskundige gibt es auf der Website einen schönen Lageplan. Doch irgendwie konnten es sich die Beamten nicht nehmen lassen, neben dem Finanzamt auch “in einem Atemzug” die Position des Gefängnisses zu erwähnen. Möglicherweise eine präventive Maßnahme gegen Steuersünder?

Today I’d like to give you a HowTo for tapping the Mono C# compiler (mcs):
- Install Cygwin and don’t forget to configure the packages
make and gcc-g++.
- Download the Mono sources and extract the entire archive.
- Compile the parser generator
jay by typing make in the directory MONO-SRC\mcs\jay.
- Go to the directory
MONO-SRC\mcs\mcs and run the parser generator
../jay/jay.exe -ctv < ../jay/skeleton.cs cs-parser.jay > cs-parser.cs.
- Compile the Visual Studio solution “compiler.sln”.
After that Visual-Studio creates the obligatory mcs.exe in the current version. Now you are able to tap all the information during the compile process. In my case I’m only interested in the Abstract Syntax Tree (AST).
Unfortunately the Mono C# compiler retrives no fancy visitor like SUN’s Java compiler. All aspects are captured in an ugly and recursive class mixture. The entry point is the class RootContext.ToplevelTypes. So I recommend to add this class into the Visual Studio watch list to determine where you can find specific details.
The following snippet delivers the class, all methods and all arguments. Just put this code into driver.cs at line 1660, recompile it and look what the output shows.
foreach (Class c in RootContext.ToplevelTypes.Types)
{
Console.WriteLine("Class: " + c.Name);
foreach ( Method m in c.Methods )
{
Console.WriteLine("Method: " + m.Name);
foreach (Parameter p in m.ParameterInfo.FixedParameters)
{
Console.WriteLine("Parameter: " + p.Name + "(" + p.TypeName + ")");
}
}
}
Der Uni-Spielplatz in Saarbrigge. Zum Austoben für zwischendurch – also zwischen Vorlesung und Seminar eigentlich eine ganz tolle Idee
