//////////////////////////////////////////////////////////////////////////// protected override void GenSelectStoreFunctions(MapType abstractedType, TypeCtorDecl synonym, out Function/*!*/ select, out Function/*!*/ store) { //Contract.Requires(synonym != null); //Contract.Requires(abstractedType != null); Contract.Ensures(Contract.ValueAtReturn(out select) != null); Contract.Ensures(Contract.ValueAtReturn(out store) != null); Type/*!*/ mapTypeSynonym; List<TypeVariable/*!*/>/*!*/ typeParams; List<Type/*!*/>/*!*/ originalInTypes; GenTypeAxiomParams(abstractedType, synonym, out mapTypeSynonym, out typeParams, out originalInTypes); // select List<TypeVariable/*!*/>/*!*/ explicitSelectParams, implicitSelectParams; select = CreateAccessFun(typeParams, originalInTypes, abstractedType.Result, synonym.Name + "Select", out implicitSelectParams, out explicitSelectParams); // store, which gets one further argument: the assigned rhs originalInTypes.Add(abstractedType.Result); List<TypeVariable/*!*/>/*!*/ explicitStoreParams, implicitStoreParams; store = CreateAccessFun(typeParams, originalInTypes, mapTypeSynonym, synonym.Name + "Store", out implicitStoreParams, out explicitStoreParams); // the store function does not have any explicit type parameters Contract.Assert(explicitStoreParams.Count == 0); if (CommandLineOptions.Clo.UseArrayTheory) { select.AddAttribute("builtin", "select"); store.AddAttribute("builtin", "store"); } else { AxBuilder.AddTypeAxiom(GenMapAxiom0(select, store, abstractedType.Result, implicitSelectParams, explicitSelectParams, originalInTypes)); AxBuilder.AddTypeAxiom(GenMapAxiom1(select, store, abstractedType.Result, explicitSelectParams)); } }
//////////////////////////////////////////////////////////////////////////// protected override void GenSelectStoreFunctions(MapType abstractedType, TypeCtorDecl synonym, out Function/*!*/ select, out Function/*!*/ store) { //Contract.Requires(synonym != null); //Contract.Requires(abstractedType != null); Contract.Ensures(Contract.ValueAtReturn(out select) != null); Contract.Ensures(Contract.ValueAtReturn(out store) != null); Contract.Assert(synonym.Name != null); string/*!*/ baseName = synonym.Name; int typeParamNum = abstractedType.FreeVariables.Count + abstractedType.TypeParameters.Count; int arity = typeParamNum + abstractedType.Arguments.Count; Type/*!*/[]/*!*/ selectTypes = new Type/*!*/ [arity + 2]; Type/*!*/[]/*!*/ storeTypes = new Type/*!*/ [arity + 3]; int i = 0; // Fill in the free variables and type parameters for (; i < typeParamNum; i++) { selectTypes[i] = AxBuilder.T; storeTypes[i] = AxBuilder.T; } // Fill in the map type if (CommandLineOptions.Clo.MonomorphicArrays) { selectTypes[i] = abstractedType; storeTypes[i] = abstractedType; } else { selectTypes[i] = AxBuilder.U; storeTypes[i] = AxBuilder.U; } i++; // Fill in the index types foreach (Type/*!*/ type in abstractedType.Arguments) { Contract.Assert(type != null); if (CommandLineOptions.Clo.Monomorphize && AxBuilder.UnchangedType(type)) { selectTypes[i] = type; storeTypes[i] = type; } else { selectTypes[i] = AxBuilder.U; storeTypes[i] = AxBuilder.U; } i++; } // Fill in the output type for select function which also happens // to be the type of the last argument to the store function if (CommandLineOptions.Clo.Monomorphize && AxBuilder.UnchangedType(abstractedType.Result)) { selectTypes[i] = abstractedType.Result; storeTypes[i] = abstractedType.Result; } else { selectTypes[i] = AxBuilder.U; storeTypes[i] = AxBuilder.U; } i++; // Fill in the map type which is the output of the store function if (CommandLineOptions.Clo.MonomorphicArrays) storeTypes[i] = abstractedType; else storeTypes[i] = AxBuilder.U; Contract.Assert(cce.NonNullElements<Type>(selectTypes)); Contract.Assert(cce.NonNullElements<Type>(storeTypes)); select = HelperFuns.BoogieFunction(baseName + "Select", selectTypes); store = HelperFuns.BoogieFunction(baseName + "Store", storeTypes); if (CommandLineOptions.Clo.UseArrayTheory) { select.AddAttribute("builtin", "select"); store.AddAttribute("builtin", "store"); } else { AxBuilder.AddTypeAxiom(GenMapAxiom0(select, store, abstractedType.TypeParameters.Count, abstractedType.FreeVariables.Count)); AxBuilder.AddTypeAxiom(GenMapAxiom1(select, store, abstractedType.TypeParameters.Count, abstractedType.FreeVariables.Count)); } }