[Mono-list] Javascript and Mono

Miguel de Icaza miguel@ximian.com
06 Jan 2003 17:51:24 -0500


Hello,

> Do mcs and mbas use the CodeProvider classes in the same way as ASP.NET 
> (or could that be used the same way?)
> I mean, is that the way to work with the CodeProvider classes?

The short answer is: you can safely ignore CodeProvider.

The CodeProvider code is just a set of classes used to *generate* source
code in a language.  Conceptually the provider classes do something
like:

	Provider p = GetProviderFor ("C#");

	Class c = p.CreateClass ("MyClass");
	Method m = c.CreateMethod ("Main");
	m.Call ("Console.WriteLine", "Hello");

	p.GenerateSource ("prog.cs");

The above basically generates:

	class MyClass {
		static void Main ()
		{
			Console.WriteLine ("Hello");
		}
	}	

The above example is not real, because I do not remember how the API
works exactly.  The point is that these classes are just used to
generate textual source code, and nothing else.

The compiler work has no relation to this.

> If we have CodeProvider classes, can we use these for the compiler? (in 
> other words, the compiler would just be a 'commandline wrapper' around 
> the CodeProvider class).

This is a common mistake (I fell for this too when doing mcs).  

The CodeProvider is only used to generate *source code*, not to generate
or compile code.  You have to write a Reflection.Emit backend.

> Yes, but I think it would be good if all compilers follow the same 
> 'guideline' (I don't mind which one),
> so I think the best for now if to name it mjsc?

That sounds fine to me.

Miguel.