private SetBigIntegerEvent(CtorType ctorType, int position, Int64 val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetIntegerEvent(CtorType ctorType, int position, int val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetCharacterEvent(CtorType ctorType, int position, char val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetBinaryEvent(CtorType ctorType, int position, byte[] val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetShortEvent(CtorType ctorType, int position, short val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetBooleanEvent(CtorType ctorType, int position, bool val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetDecimalEvent(CtorType ctorType, int position, decimal val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetBooleanEvent(CtorType ctorType, int position, bool val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
public override CtorType VisitCtorType(CtorType node) { var argTypes = node.Arguments.Select(t => Translate(t)).ToList(); ReturnResult(IsaBoogieType.TConType(node.Decl.Name, argTypes, usedClosedConstructors)); return(node); }
private SetEnumEvent(CtorType ctorType, int position, Enum val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetSingleEvent(CtorType ctorType, int position, float val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetShortEvent(CtorType ctorType, int position, short val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetDecimalEvent(CtorType ctorType, int position, decimal val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetDoubleEvent(CtorType ctorType, int position, double val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private Dictionary<string, Type> GetPermissionTypes() { var permissionTypes = new Dictionary<string, Type>(); foreach (var decl in program.TopLevelDeclarations.Where(decl => decl is TypeCtorDecl || decl is TypeSynonymDecl)) { foreach (var domainName in FindDomainNames(decl.Attributes)) { if (permissionTypes.ContainsKey(domainName)) { Error(decl, $"Duplicate permission type for domain {domainName}"); } else if (decl is TypeCtorDecl typeCtorDecl) { if (typeCtorDecl.Arity > 0) { Error(decl, "Permission type must be fully instantiated"); } else { permissionTypes[domainName] = new CtorType(Token.NoToken, typeCtorDecl, new List<Type>()); } } else { permissionTypes[domainName] = new TypeSynonymAnnotation(Token.NoToken, (TypeSynonymDecl) decl, new List<Type>()); } } } return permissionTypes; }
public void Arguments() { var tcDecl = new TypeCtorDecl(Token.NoToken, "fox", 1); var tc = new CtorType(Token.NoToken, tcDecl, new List <Microsoft.Boogie.Type>() { Microsoft.Boogie.Type.Bool }); var tcTypeIdent = new TypedIdent(Token.NoToken, "fox", tc); var gv = new GlobalVariable(Token.NoToken, tcTypeIdent); // FIXME: The Symbolic constructor shouldn't really need the program location gv.SetMetadata <ProgramLocation>((int)AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(gv)); var sym = new SymbolicVariable("y", gv); var builder = new SimpleExprBuilder(/*immutable=*/ true); var eq = builder.Eq(sym.Expr, sym.Expr); Assert.IsNotInstanceOf <LiteralExpr>(eq); // Check that it wasn't constant folded using (var writer = new StringWriter()) { var printer = GetPrinter(writer); printer.AddDeclarations(eq); printer.PrintSortDeclarations(); Assert.AreEqual("(declare-sort @fox)\n", writer.ToString()); } }
private SetTimeEvent(CtorType ctorType, int position, DateTime val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
public override CtorType VisitCtorType(CtorType node) { insideContructedType++; base.VisitCtorType(node); insideContructedType--; return(node); }
private SetBinaryEvent(CtorType ctorType, int position, byte[] val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetEnumEvent(CtorType ctorType, int position, Enum val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetSingleEvent(CtorType ctorType, int position, float val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetTimestampEvent(CtorType ctorType, int position, DateTime val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
public override CtorType VisitCtorType(CtorType node) { //Contract.Requires(node != null); Contract.Ensures(Contract.Result <CtorType>() != null); // do /not/ clone the type recursively return((CtorType)node.Clone()); }
private SetDoubleEvent(CtorType ctorType, int position, double val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetCharacterEvent(CtorType ctorType, int position, char val, String name) { this.ctorType = ctorType; this.position = position; this.val = val; this.name = name; }
private SetParameterListEvent(CtorType ctorType, String name, ICollection valsColl, Object[] valsArr, IType type) { this.ctorType = ctorType; this.name = name; this.valsColl = valsColl; this.valsArr = valsArr; this.type = type; }
private SetParameterEvent(CtorType ctorType, int position, String name, object val, IType type) { this.ctorType = ctorType; this.position = position; this.val = val; this.type = type; this.name = name; }
private SetParameterEvent(CtorType ctorType, int position, String name, object val, IType type) { this.ctorType = ctorType; this.position = position; this.val = val; this.type = type; this.name = name; }
private SetParameterListEvent(CtorType ctorType, String name, ICollection valsColl, Object[] valsArr, IType type) { this.ctorType = ctorType; this.name = name; this.valsColl = valsColl; this.valsArr = valsArr; this.type = type; }
private void RegisterType(Type type) { Contract.Requires(type != null); if (KnownTypes.Contains(type)) { return; } if (type.IsMap && CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic) { KnownTypes.Add(type); MapType mapType = type.AsMap; Contract.Assert(mapType != null); foreach (Type t in mapType.Arguments) { Contract.Assert(t != null); RegisterType(t); } RegisterType(mapType.Result); if (!CommandLineOptions.Clo.UseArrayTheory) { AddDeclaration("(declare-sort " + TypeToString(type) + " 0)"); } return; } if (type.IsBool || type.IsInt || type.IsReal || type.IsBv || type.IsFloat || type.IsRMode || type.IsString || type.IsRegEx) { return; } CtorType ctorType = type as CtorType; if (ctorType != null) { // Check if this is a built-in type. If so, no declaration is needed. string decl = ctorType.GetBuiltin(); if (decl != null) { KnownTypes.Add(type); return; } if (ctorType.IsDatatype()) { return; } } if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic) { AddDeclaration("(declare-sort " + TypeToString(type) + " 0)"); KnownTypes.Add(type); return; } }
public Sort BuildCtorType(CtorType ctorType) { Context z3 = ((Z3apiProverContext)container).z3; if (ctorType.Arguments.Count > 0) { throw new Exception("Type constructor of non-zero arity are not handled"); } return(z3.MkSort(ctorType.Decl.Name)); }
// the instantiations of inserted type variables, the order corresponds to the order in which "AbstractionVariable(int)" delivers variables private Type /*!*/ ThinOutType(Type rawType, List <TypeVariable> boundTypeParams, List <Type> instantiations) { if (rawType.FreeVariables.All(var => !boundTypeParams.Contains(var))) { // Bingo! // if the type does not contain any bound variables, we can simply // replace it with a type variable TypeVariable /*!*/ abstractionVar = AbstractionVariable(instantiations.Count); instantiations.Add(rawType); return(abstractionVar); } if (rawType.IsVariable) { // // then the variable has to be bound, we cannot do anything TypeVariable /*!*/ rawVar = rawType.AsVariable; return(rawVar); // } else if (rawType.IsMap) { // // recursively abstract this map type and continue abstracting CtorType /*!*/ abstraction = AbstractMapType(rawType.AsMap); return(ThinOutType(abstraction, boundTypeParams, instantiations)); // } else if (rawType.IsCtor) { // // traverse the subtypes CtorType /*!*/ rawCtorType = rawType.AsCtor; List <Type> /*!*/ newArguments = new List <Type>(); foreach (Type /*!*/ subtype in rawCtorType.Arguments.ToList()) { newArguments.Add(ThinOutType(subtype, boundTypeParams, instantiations)); } return(new CtorType(Token.NoToken, rawCtorType.Decl, newArguments)); // } else { System.Diagnostics.Debug.Fail("Don't know how to handle this type: " + rawType); return(rawType); // compiler appeasement policy } }
public virtual CtorType VisitCtorType(CtorType node) { Contract.Requires(node != null); Contract.Ensures(Contract.Result <CtorType>() != null); lock (node) { for (int i = 0; i < node.Arguments.Count; ++i) { node.Arguments[i] = cce.NonNull((Type /*!*/)this.Visit(node.Arguments[i])); } } return(node); }
private Sort GetCtorType(CtorType ctorType) { if (!ctorTypes.ContainsKey(ctorType)) { Sort typeAst = BuildCtorType(ctorType); ctorTypes.Add(ctorType, typeAst); } Sort result; bool containsKey = ctorTypes.TryGetValue(ctorType, out result); Debug.Assert(containsKey); return(result); }
/// <summary> /// input type should be a map type or a constructor type that was generated for a map /// </summary> private MapType TranslateToMapType(Type type) { if (type.IsMap) { return(type.AsMap); } if (type.IsCtor) { CtorType ctorType = type.AsCtor; return(_mapAbstractionBuilder.RawType(ctorType.Decl)); } throw new cce.UnreachableException(); }
private void RegisterType(Type type) { Contract.Requires(type != null); if (KnownTypes.Contains(type)) { return; } if (type.IsMap && CommandLineOptions.Clo.MonomorphicArrays) { KnownTypes.Add(type); MapType mapType = type.AsMap; Contract.Assert(mapType != null); foreach (Type t in mapType.Arguments) { Contract.Assert(t != null); RegisterType(t); } RegisterType(mapType.Result); if (!CommandLineOptions.Clo.UseArrayTheory) { AddDeclaration("(declare-sort " + TypeToString(type) + " 0)"); } return; } if (type.IsBool || type.IsInt || type.IsReal || type.IsBv || type.IsFloat) { return; } CtorType ctorType = type as CtorType; if (ctorType != null && ctorType.IsDatatype()) { return; } if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic) { AddDeclaration("(declare-sort " + TypeToString(type) + " 0)"); KnownTypes.Add(type); return; } }
private Function SelectFun(MapType m, TypeCtorDecl ctorDecl) { var ctorTypeParams = m.FreeVariables.Select(tv => (Type)tv).ToList(); var ctorType = new CtorType(Token.NoToken, ctorDecl, ctorTypeParams); var valueTypes = new List <Type> { ctorType }; valueTypes.AddRange(m.Arguments); valueTypes.Add(m.Result); List <TypeVariable> typeParams = new List <TypeVariable> (m.TypeParameters); typeParams.AddRange(m.FreeVariables); return(HelperFuns.BoogieFunction("select_" + ctorDecl.Name, typeParams, valueTypes.ToArray())); }
public override CtorType VisitCtorType(CtorType node) { //TODO: checking for T by name does not work in general, fix this by parametrizing the class by the actual object if (node.Decl.Name.Equals("T") && !node.Arguments.Any()) { ReturnResult(typeTy); } else { //we don't support VC optimizations that monomorphize the VC if there are no polymorphic types for now //hence values of a type generated via a constructor are always represented by u ReturnResult(valueTy); } return(node); }
MapTypeClassRepresentation GetRepresentation(MapType rawType, out CtorType ctorType) { if (!rawToAbstractType.TryGetValue(rawType, out Tuple <MapType, CtorType> res)) { MapType abstraction = rawType; List <Type> instantiation = new List <Type>(); if (!useUniqueType(rawType)) { abstraction = ThinOutMapType(rawType, out instantiation); } var repr = GetClassRepresentation(abstraction, rawType); ctorType = new CtorType(Token.NoToken, repr.RepresentingType, instantiation); rawToAbstractType.Add(rawType, Tuple.Create(abstraction, ctorType)); return(repr); } ctorType = res.Item2; return(GetClassRepresentation(res.Item1, rawType)); }
public void MapWithTypeConstructorTypesNoArguments() { var tcDecl = new TypeCtorDecl(Token.NoToken, "fox", 0); var tc = new CtorType(Token.NoToken, tcDecl, new List <Microsoft.Boogie.Type>()); var tcDecl2 = new TypeCtorDecl(Token.NoToken, "fox_two", 0); var tc2 = new CtorType(Token.NoToken, tcDecl2, new List <Microsoft.Boogie.Type>()); var tcDecl3 = new TypeCtorDecl(Token.NoToken, "fox_three", 0); var tc3 = new CtorType(Token.NoToken, tcDecl3, new List <Microsoft.Boogie.Type>()); var mapType = new MapType( Token.NoToken, new List <Microsoft.Boogie.TypeVariable>(), new List <Microsoft.Boogie.Type>() { tc, tc2 }, tc3); var mapTypeTypeIdent = new TypedIdent(Token.NoToken, "mapx", mapType); var gv = new GlobalVariable(Token.NoToken, mapTypeTypeIdent); // FIXME: The Symbolic constructor shouldn't really need the program location gv.SetMetadata <ProgramLocation>((int)AnnotationIndex.PROGRAM_LOCATION, new ProgramLocation(gv)); var sym = new SymbolicVariable("y", gv); var builder = new SimpleExprBuilder(/*immutable=*/ true); var eq = builder.Eq(sym.Expr, sym.Expr); Assert.IsNotInstanceOf <LiteralExpr>(eq); // Check that it wasn't constant folded using (var writer = new StringWriter()) { var printer = GetPrinter(writer); printer.AddDeclarations(eq); printer.PrintSortDeclarations(); var str = writer.ToString().Trim(); // Check we can see all the sort declarations we expect but don't depend on their order Assert.IsTrue(str.Contains("(declare-sort @fox)")); Assert.IsTrue(str.Contains("(declare-sort @fox_two)")); Assert.IsTrue(str.Contains("(declare-sort @fox_three)")); } }
protected void GenTypeAxiomParams(MapType/*!*/ abstractedType, TypeCtorDecl/*!*/ synonymDecl, out Type/*!*/ mapTypeSynonym, out List<TypeVariable/*!*/>/*!*/ typeParams, out List<Type/*!*/>/*!*/ originalIndexTypes) { Contract.Requires(abstractedType != null); Contract.Requires(synonymDecl != null); Contract.Ensures(Contract.ValueAtReturn(out mapTypeSynonym) != null); Contract.Ensures(cce.NonNullElements(Contract.ValueAtReturn(out typeParams))); Contract.Ensures(cce.NonNullElements(Contract.ValueAtReturn(out originalIndexTypes))); typeParams = new List<TypeVariable/*!*/>(); typeParams.AddRange(abstractedType.TypeParameters); typeParams.AddRange(abstractedType.FreeVariables); originalIndexTypes = new List<Type/*!*/>(abstractedType.Arguments.Count + 1); List<Type>/*!*/ mapTypeParams = new List<Type>(); foreach (TypeVariable/*!*/ var in abstractedType.FreeVariables) { Contract.Assert(var != null); mapTypeParams.Add(var); } if (CommandLineOptions.Clo.MonomorphicArrays) mapTypeSynonym = abstractedType; else mapTypeSynonym = new CtorType(Token.NoToken, synonymDecl, mapTypeParams); originalIndexTypes.Add(mapTypeSynonym); originalIndexTypes.AddRange(abstractedType.Arguments.ToList()); }
public override CtorType VisitCtorType(CtorType node) { add(node); return(base.VisitCtorType(node)); }
public override CtorType VisitCtorType(CtorType node) { //Contract.Requires(node != null); Contract.Ensures(Contract.Result<CtorType>() != null); // do /not/ clone the type recursively return (CtorType)node.Clone(); }
public virtual CtorType VisitCtorType(CtorType node) { Contract.Requires(node != null); Contract.Ensures(Contract.Result<CtorType>() != null); lock (node) { for (int i = 0; i < node.Arguments.Count; ++i) node.Arguments[i] = cce.NonNull((Type/*!*/)this.Visit(node.Arguments[i])); } return node; }
public override CtorType VisitCtorType(CtorType node) { Contract.Ensures(Contract.Result<CtorType>() == node); for (int i = 0; i < node.Arguments.Count; ++i) this.Visit(node.Arguments[i]); return node; }
public override CtorType VisitCtorType(CtorType node) { //instantiate T@U with the Boogie values means we do not need to transform the value ReturnResult(v => v); return(node); }