A type inference approach to program analysis