private Microsoft.Boogie.Type CreateTypeSynonym(Microsoft.Boogie.Type type, string name) { var typeDecl = new TypeSynonymDecl(Token.NoToken, name, null, type); var ts = new TypeSynonymAnnotation(Token.NoToken, typeDecl, new List <Microsoft.Boogie.Type>()); return(ts); }
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; }
///////////////////////////////////////////////////////////////////////////////////// private static void TypeToStringHelper(Type t, StringBuilder sb) { Contract.Requires(t != null); TypeSynonymAnnotation syn = t as TypeSynonymAnnotation; if (syn != null) { TypeToStringHelper(syn.ExpandedType, sb); } else { if (t.IsMap && CommandLineOptions.Clo.UseArrayTheory) { MapType m = t.AsMap; // Contract.Assert(m.MapArity == 1); sb.Append("(Array "); foreach (Type tp in m.Arguments) { sb.Append(TypeToString(tp)).Append(" "); } sb.Append(TypeToString(m.Result)).Append(")"); } else if (t.IsMap) { MapType m = t.AsMap; sb.Append('['); for (int i = 0; i < m.MapArity; ++i) { if (i != 0) { sb.Append(','); } TypeToStringHelper(m.Arguments[i], sb); } sb.Append(']'); TypeToStringHelper(m.Result, sb); } else if (t.IsBool || t.IsInt || t.IsReal || t.IsFloat || t.IsBv || t.IsRMode || t.IsString) { sb.Append(TypeToString(t)); } else { System.IO.StringWriter buffer = new System.IO.StringWriter(); using (TokenTextWriter stream = new TokenTextWriter("<buffer>", buffer, /*setTokens=*/ false, /*pretty=*/ false) ) { t.Emit(stream); } sb.Append(buffer.ToString()); } } }
public virtual Type VisitTypeSynonymAnnotation(TypeSynonymAnnotation node) { Contract.Requires(node != null); Contract.Ensures(Contract.Result <Type>() != null); node.ExpandedType = cce.NonNull((Type /*!*/)this.Visit(node.ExpandedType)); lock (node.Arguments) { for (int i = 0; i < node.Arguments.Count; ++i) { node.Arguments[i] = cce.NonNull((Type /*!*/)this.Visit(node.Arguments[i])); } } return(node); }
private static void TypeToStringHelper(Type t, StringBuilder sb) { Contract.Requires(t != null); TypeSynonymAnnotation syn = t as TypeSynonymAnnotation; if (syn != null) { TypeToStringHelper(syn.ExpandedType, sb); } else { if (t.IsMap) { MapType m = t.AsMap; sb.Append('['); for (int i = 0; i < m.MapArity; ++i) { if (i != 0) { sb.Append(','); } TypeToStringHelper(m.Arguments[i], sb); } sb.Append(']'); TypeToStringHelper(m.Result, sb); } else if (t.IsBool || t.IsInt || t.IsBv) { sb.Append(TypeToString(t)); } else { System.IO.StringWriter buffer = new System.IO.StringWriter(); using (TokenTextWriter stream = new TokenTextWriter("<buffer>", buffer, /*setTokens=*/ false, /*pretty=*/ false)) { t.Emit(stream); } sb.Append(buffer.ToString()); } } }
public virtual Type VisitTypeSynonymAnnotation(TypeSynonymAnnotation node) { Contract.Requires(node != null); Contract.Ensures(Contract.Result<Type>() != null); node.ExpandedType = cce.NonNull((Type/*!*/)this.Visit(node.ExpandedType)); lock (node.Arguments) { for (int i = 0; i < node.Arguments.Count; ++i) node.Arguments[i] = cce.NonNull((Type/*!*/)this.Visit(node.Arguments[i])); } return node; }
public override Type VisitTypeSynonymAnnotation(TypeSynonymAnnotation node) { Contract.Ensures(Contract.Result<Type>() == node); node.ExpandedType = cce.NonNull((Type/*!*/)this.Visit(node.ExpandedType)); for (int i = 0; i < node.Arguments.Count; ++i) this.Visit(node.Arguments[i]); return node; }
public override Type VisitTypeSynonymAnnotation(TypeSynonymAnnotation node) { ReturnResult(Translate(node.ExpandedType)); //ignoring arguments return(node); }