[Mono-list] Help in customization of MCS

Guilherme g_labega at yahoo.com.br
Sun Sep 4 07:35:48 EDT 2005


Hi, 

I’m working in some king of customization of MCS (Mono
C# compiler). What I’m doing in add some elements to
C# language to support something from AOP.

So let me show a basic example:

namespace XXXX
{

public aspect Class2
{
	pointcut MyPointCut1 void *.T*(XXXX.MainCls i);

	after MyPointCut1(XXXX.MainCls i)
	{
	Console.WriteLine("MyPointCut1: i: " + i);
		Console.WriteLine("Object Instance is: " +
instance.ToString());
	}
}

}

The code inside “after MyPointCut1” is called after
the execution of which method that the name starts
with “T” (in any class and any namespace).

namespace XXXX
{

public class MainCls
{
	public void Toto(MainCls i)
	{
		Console.WriteLine(i);
	}
}

}

So to find which method should be intercepted I use
some criteria’s: return type, the name (that stuff
with “*”), and parameters. I’m having troubles with
parameters. 

In my code I created a class named "aspect” that is
derived from “Class”. So when the method “public
override bool DefineMembers(TypeContainer parent)” is
called by MCS I start to look up for methods to
intercept. The parameters comparison (to check is
method parameter and aspect parameters are from same
type) is made in the following way:

return (p1.TypeName.ToString() ==
p2.TypeName.ToString());
Where p1 and p2 are instances of Parameter. 

The problem occurs in the code that I showed above. In
the method the type of parameters is write “MainCls”
and in the aspect “XXXX.MainCls”. So the compression
returns false, and that aspect in not binded for
“Toto” method. 

There is another way to check parameters type? :D 

I’m know that is a little complex question. If someone
want to talk about this project with me, please feel
free. Sorry about my terrible english and the long
e-mail. :D

Thanks in advanced, 

Guilherme. 

Mail: glabega at gmail.com
MSN : g_labega at hotmail.com


__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger 
http://br.download.yahoo.com/messenger/ 


More information about the Mono-list mailing list