Add types to intermediate code representation.
First working version.