finish compile (just a copy from untyped compile) and the squelette of type checker