[Mono-devel-list] Add /addmodule: support to mcs

Paolo Molaro lupus at ximian.com
Thu Dec 18 06:55:45 EST 2003


On 12/18/03 Peter Ross wrote:
> > 
> > > I was wondering if anyone can give me any pointers on what would need to
> > > be done to add /addmodule support to mcs?
[...]
> My plan is to look at monodis, factor out some of the code into a
> library, build a .NET assembly above the library using PInvoke and then
> integrate the library into mcs.

The library already exists, the code is in metadata/.

> Why am I doing this?  I would like to get Mercury [1] building under
> Mono, and for that I need a C# compiler that accepts /addmodule and a
> minimal implementation of al.exe.

Didn't the mercury compiler generate IL code? Or does it generate both
IL and C# code?

I think the way to go is to implement the Assembly::LoadModule()
method. It may be that the MS runtime already supports the kind of use
we need to implement /addmodule.
Anyway, the implementation of the method should work in the context of
an AssemblyBuilder: when mcs creates the Assemblybuilder, it just
uses abuilder.LoadModule (...) for each /addmodule argument.
The loaded module gets added to the modules for the assembly builder
and things should mostly work ok, but no doubt some changes will be
needed, both when doing type lookups and when writing the pe file...
al.exe, I think, could be implemented with the same trick.
Alternatively, al.exe could be probably written using PEAPI.dll
instead of Reflection.Emit.
Another related (but minor) issue is getting mcs to create modules:
we can probably overload the assembly builder flags to add a Module
item, so Reflection.Emit will emit a module instead of a full assembly
in that case.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list