Learning Program Semantics for Vulnerability Detection via Type-specific Inter-procedural Slicing