private static IDictionary <Block, IList <VCExprVar> > ConvertVariableToVCExpr( IDictionary <Block, ISet <Variable> > dict, IVCVarFunTranslator translator) { if (dict == null) { return(null); } var blockToNewVCVar = new Dictionary <Block, IList <VCExprVar> >(); foreach (var blockAndVars in dict) { IList <VCExprVar> newVCExprs = new List <VCExprVar>(); foreach (var v in blockAndVars.Value) { if (!translator.TranslateBoogieVar(v, out var result)) { throw new ProofGenUnexpectedStateException(typeof(VCToIsaInterface), "Could not map Boogie variable to VC variable"); } newVCExprs.Add(result); } blockToNewVCVar.Add(blockAndVars.Key, newVCExprs); } return(blockToNewVCVar); }
private static Dictionary <T, IList <NamedDeclaration> > SortActiveDecls <T>( IDictionary <T, ISet <NamedDeclaration> > activeDeclsPerBlock, IEnumerable <Function> functions, IVCVarFunTranslator translator, out IDictionary <T, IList <VCExprVar> > activeVarsPerBlock) { activeVarsPerBlock = new Dictionary <T, IList <VCExprVar> >(); var activeDeclsPerBlockSorted = new Dictionary <T, IList <NamedDeclaration> >(); foreach (var kv in activeDeclsPerBlock) { var activeVars = kv.Value.Where(decl => decl is Variable); var activeVCVars = activeVars.Select(decl => { if (translator.TranslateBoogieVar((Variable)decl, out var result)) { return(result); } Contract.Assert(false); return(null); }).ToList(); activeVarsPerBlock.Add(kv.Key, activeVCVars); var sortedDecls = new List <NamedDeclaration>(); foreach (var f in functions) { if (kv.Value.Contains(f)) { sortedDecls.Add(f); } } sortedDecls.AddRange(activeVars); if (sortedDecls.Count() != kv.Value.Count) { throw new ProofGenUnexpectedStateException(typeof(VCToIsaInterface), "did not capture all active declarations"); } activeDeclsPerBlockSorted.Add(kv.Key, sortedDecls); } return(activeDeclsPerBlockSorted); }