public override CBAProgram runCBAPass(CBAProgram p) { // Eliminate dead variables UnusedVarEliminator.Eliminate(p as Program); // Add the inlining bound addInlineAttribute(p); // Inline doInlining(p); // Remove the inlined procedures & implementations removeInlinedProcs(p); // Remove annotations that won't parse because of dropped variables RemoveVarsFromAttributes.Prune(p); return(p); }
// deletes calls to all entrypoints except mainproc, returns CorralMain since that this is the entrypoint // clears out all commands from the blocks with deleted calls private static string sliceMainForProc(Program program, string mainproc, HashSet <string> otherEPs) { Procedure entrypoint_proc = program.TopLevelDeclarations.OfType <Procedure>().Where(proc => BoogieUtil.checkAttrExists("entrypoint", proc.Attributes)).FirstOrDefault(); Debug.Assert(entrypoint_proc != null); Implementation entrypoint_impl = program.TopLevelDeclarations.OfType <Implementation>().Where(impl => impl.Name.Equals(entrypoint_proc.Name)).FirstOrDefault(); foreach (Block b in entrypoint_impl.Blocks) { if (b.Cmds.OfType <CallCmd>().Any(cc => cc.callee != mainproc && otherEPs.Contains(cc.callee))) { b.Cmds.Clear(); } } UnusedVarEliminator.Eliminate(program); return(entrypoint_proc.Name); }