private void attachEnsures(Implementation impl) { List <Variable> functionInterfaceVars = new List <Variable>(); foreach (Variable v in BoogieUtil.GetGlobalVariables(vcgen.program)) { functionInterfaceVars.Add(new Formal(Token.NoToken, new TypedIdent(Token.NoToken, "", v.TypedIdent.Type), true)); } foreach (Variable v in impl.InParams) { functionInterfaceVars.Add(new Formal(Token.NoToken, new TypedIdent(Token.NoToken, "", v.TypedIdent.Type), true)); } foreach (Variable v in impl.OutParams) { functionInterfaceVars.Add(new Formal(Token.NoToken, new TypedIdent(Token.NoToken, "", v.TypedIdent.Type), true)); } foreach (IdentifierExpr e in impl.Proc.Modifies) { if (e.Decl == null) { continue; } functionInterfaceVars.Add(new Formal(Token.NoToken, new TypedIdent(Token.NoToken, "", e.Decl.TypedIdent.Type), true)); } Formal returnVar = new Formal(Token.NoToken, new TypedIdent(Token.NoToken, "", Bpl.Type.Bool), false); var function = new Function(Token.NoToken, impl.Name + summaryPredSuffix, functionInterfaceVars, returnVar); prover.Context.DeclareFunction(function, ""); List <Expr> exprs = new List <Expr>(); foreach (Variable v in BoogieUtil.GetGlobalVariables(vcgen.program)) { Contract.Assert(v != null); exprs.Add(new OldExpr(Token.NoToken, new IdentifierExpr(Token.NoToken, v))); } foreach (Variable v in impl.Proc.InParams) { Contract.Assert(v != null); exprs.Add(new IdentifierExpr(Token.NoToken, v)); } foreach (Variable v in impl.Proc.OutParams) { Contract.Assert(v != null); exprs.Add(new IdentifierExpr(Token.NoToken, v)); } foreach (IdentifierExpr ie in impl.Proc.Modifies) { Contract.Assert(ie != null); if (ie.Decl == null) { continue; } exprs.Add(ie); } Expr postExpr = new NAryExpr(Token.NoToken, new FunctionCall(function), exprs); impl.Proc.Ensures.Add( new Ensures(Token.NoToken, false, postExpr, "")); }
private static void initialize(Program program, ErrorTrace trace, string filename) { // Initialization fileName = filename == null ? "null" : filename; nameImplMap = BoogieUtil.nameImplMapping(program); events = new List <Event>(); threadStacks = new Dictionary <int, List <WorkItem> >(); tidCounter = 0; varNamesChanged = false; varNameMap = new Dictionary <string, string>(); var globals = BoogieUtil.GetGlobalVariables(program); globals.Iter(g => varNameMap.Add(g.Name + "__0", g.Name)); }