Add support for member functions on user-types.

On the way, made various improvements. In particular, moved Context to its
own file and used it directly as the interface for StaticChecker and
IrGenerator.

Closures would make a lot of this much simpler.