private Implementation processImplementation(Implementation node) { varsRead = new VarsUsed(); // Gather the set of vars used foreach (var b in node.Blocks) { base.VisitBlock(b); } globalsRead.UnionWith(varsRead.globalsUsed); // Get rid of declarations (before variable slice adds new variables) var newvars = new List <Variable>(); foreach (Variable v in node.LocVars) { if (varsRead.localsUsed.Contains(v.Name)) { newvars.Add(v); } } node.LocVars = newvars; // Do VariableSlicing VariableSlicing slice = new VariableSlicing(new VarSet(new HashSet <string>(varsRead.localsUsed), node.Name), ltinfo, node); for (int i = 0; i < node.Blocks.Count; i++) { node.Blocks[i] = slice.VisitBlock(node.Blocks[i]); } varsRead = null; return(node); }
public UnReadVarEliminator(bool onlyLocals) { this.onlyLocals = onlyLocals; varsRead = null; globalsRead = null; ltinfo = new ModifyTrans(); gtinfo = new ModifyTrans(); sliceGlobals = null; }
public Program run(Program node) { globalsRead = new HashSet <string>(); // Typecheck -- needed for variable abstraction if (node.Typecheck() != 0) { BoogieUtil.PrintProgram(node, "error.bpl"); throw new InternalError("Type errors"); } // Go through all procedures and implementations (slice locals) var TopLevelDeclarations = node.TopLevelDeclarations.ToList(); for (int i = 0; i < TopLevelDeclarations.Count; i++) { if (TopLevelDeclarations[i] is Implementation) { TopLevelDeclarations[i] = processImplementation(TopLevelDeclarations[i] as Implementation); } else if (TopLevelDeclarations[i] is Procedure) { processProcedure(TopLevelDeclarations[i] as Procedure); } } node.TopLevelDeclarations = TopLevelDeclarations; if (onlyLocals) { return(node); } sliceGlobals = new VariableSlicing(VarSet.ToVarSet(globalsRead, node), gtinfo); node = sliceGlobals.VisitProgram(node); BoogieUtil.DoModSetAnalysis(node); return(node); }
public VariableSlicePass(VarSet v) { tinfo = new ModifyTrans(); vslice = new VariableSlicing(v, tinfo); passName = "Variable Slicing"; }