added module context support

this implements a function which builds a context for modules which can
be used for type checking