/// <summary> /// Initialize the variables. /// </summary> /// <param name="program">The source Boogie program.</param> /// <param name="sourceLanguage">The source language of the input program.</param> /// <param name="disableInspection">Disables inspection of programmer inserted barriers.</param> /// <param name="disableGridBarriers">Disables grid-level barriers during instrumentation.</param> /// <param name="useAxioms">Use axioms for instrumentation instead of variable assignments.</param> public Instrumentor(Microsoft.Boogie.Program program, SourceLanguage sourceLanguage, bool disableInspection, bool disableGridBarriers, bool useAxioms) { this.program = program; this.sourceLanguage = sourceLanguage; this.disableInspection = disableInspection; this.disableGridBarriers = disableGridBarriers; this.useAxioms = useAxioms; analyzer = new GraphAnalyzer(program); foreach (Declaration declaration in program.TopLevelDeclarations) { if (declaration is Procedure) { Procedure procedure = declaration as Procedure; if (procedure.Name == "$bugle_barrier") { barrier_definition = procedure; } else if (procedure.Name == "$bugle_grid_barrier") { grid_barrier_definition = procedure; } } } _1bv1 = new LiteralExpr(Token.NoToken, BigNum.ONE, 1); Logger.Log($"Blocks;{program.Blocks().Count()}"); Logger.Log($"Commands;{program.Blocks().Sum(x => x.Cmds.Count)}"); }
public bool RunOn(Microsoft.Boogie.Program prog, PassInfo passInfo) { var blocks = prog.Blocks(); bool changed = false; foreach (var block in blocks) { var newCmds = new List <Cmd>(); foreach (var cmd in block.Cmds) { if (cmd is AssumeCmd) { var assumeCmd = cmd as AssumeCmd; if (ExprUtil.IsTrue(assumeCmd.Expr)) { // This is a trivial assume Console.WriteLine("Removing trivial assume true on line {0}", assumeCmd.tok.line); changed = true; continue; } } // Add the existing command to the list if we want to keep it newCmds.Add(cmd); } if (block.cmds.Count > newCmds.Count) { // Assign new list if necessary block.Cmds = newCmds; } } return(changed); }