public override Bpl.Variable CreateEventVariable(IEventDefinition e) { Bpl.Variable v; string fieldName = MemberHelper.GetMemberSignature(e, NameFormattingOptions.DocumentationId); // HACK fieldName = fieldName.Replace("E:", "F:"); fieldName = TranslationHelper.TurnStringIntoValidIdentifier(fieldName); Bpl.IToken tok = e.Token(); Bpl.Type t = this.sink.CciTypeToBoogie(e.Type.ResolvedType); if (e.Adder.ResolvedMethod.IsStatic) { Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldName, t); v = new Bpl.GlobalVariable(tok, tident); } else { Bpl.Type mt = new Bpl.MapType(tok, new List <Bpl.TypeVariable>(), new List <Bpl.Type>(new Bpl.Type[] { this.RefType }), t); Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldName, mt); v = new Bpl.GlobalVariable(tok, tident); } return(v); }
public IType makeTypeI(Type boogieType, Context context) { Debug.Assert(boogieType != null); IType result; var ts = boogieType as TypeSynonymAnnotation; TypeConstructorInstance originalType; if (ts == null) { originalType = null; } else { TypeConstructor originalConstructor = makeConstructor(ts.Decl.Name, ts.Decl.TypeParameters.Count); originalType = new TypeConstructorInstance(originalConstructor, makeTypes(ts.Arguments, context)); } // string originalName = (ts!=null)?ts.ToString():null; if (boogieType.IsBool) { result = BooleanType.booleanType; } else if (boogieType.IsInt) { result = IntegerType.integerType; } else if (boogieType.IsBv) { result = BitVectorType.makeBitVectorType((boogieType as BvType).BvBits); } else if (boogieType.IsCtor) { TypeConstructor constructor = makeConstructor(boogieType.AsCtor.Decl.Name, boogieType.AsCtor.Decl.Arity); result = new TypeConstructorInstance(constructor, makeTypes(boogieType.AsCtor.Arguments, context)); } else if (boogieType.IsMap) { Microsoft.Boogie.MapType bmt = boogieType.AsMap; pushTypeVariables(ref context, bmt.TypeParameters); result = new MapType( makeTypeVariables(context, bmt.TypeParameters), makeTypes(bmt.Arguments, context), makeTypeI(bmt.Result, context), originalType); context.pop(); } else if (boogieType.IsVariable) { result = new VariableType(context.lookupTypeVariable(boogieType.AsVariable.Name)); } else { throw new Exception("Unsupported Boogie type:" + boogieType); } result.check(context); return(result); }
/// <summary> /// Creates a fresh BPL variable to represent <paramref name="field"/>, deciding /// on its type based on the heap representation. /// </summary> public override Bpl.Variable CreateFieldVariable(IFieldReference field) { Bpl.Variable v; string fieldname = MemberHelper.GetMemberSignature(field, NameFormattingOptions.DocumentationId); fieldname = TranslationHelper.TurnStringIntoValidIdentifier(fieldname); Bpl.IToken tok = field.Token(); Bpl.Type t = this.sink.CciTypeToBoogie(field.Type.ResolvedType); if (field.ResolvedField.IsStatic) { Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldname, t); v = new Bpl.GlobalVariable(tok, tident); } else { Bpl.Type mt = new Bpl.MapType(tok, new List<Bpl.TypeVariable>(), new List<Bpl.Type>(new Bpl.Type[] {this.RefType}), t); Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldname, mt); v = new Bpl.GlobalVariable(tok, tident); } return v; }
/// <summary> /// Creates a fresh BPL variable to represent <paramref name="field"/>, deciding /// on its type based on the heap representation. /// </summary> public override Bpl.Variable CreateFieldVariable(IFieldReference field) { Bpl.Variable v; string fieldname = MemberHelper.GetMemberSignature(field, NameFormattingOptions.DocumentationId); fieldname = TranslationHelper.TurnStringIntoValidIdentifier(fieldname); Bpl.IToken tok = field.Token(); Bpl.Type t = this.sink.CciTypeToBoogie(field.Type.ResolvedType); if (field.ResolvedField.IsStatic) { Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldname, t); v = new Bpl.GlobalVariable(tok, tident); } else { Bpl.Type mt = new Bpl.MapType(tok, new List <Bpl.TypeVariable>(), new List <Bpl.Type>(new Bpl.Type[] { this.RefType }), t); Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldname, mt); v = new Bpl.GlobalVariable(tok, tident); } return(v); }
public override Bpl.Variable CreateEventVariable(IEventDefinition e) { Bpl.Variable v; string fieldName = MemberHelper.GetMemberSignature(e, NameFormattingOptions.DocumentationId); // HACK fieldName = fieldName.Replace("E:", "F:"); fieldName = TranslationHelper.TurnStringIntoValidIdentifier(fieldName); Bpl.IToken tok = e.Token(); Bpl.Type t = this.sink.CciTypeToBoogie(e.Type.ResolvedType); if (e.Adder.ResolvedMethod.IsStatic) { Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldName, t); v = new Bpl.GlobalVariable(tok, tident); } else { Bpl.Type mt = new Bpl.MapType(tok, new List<Bpl.TypeVariable>(), new List<Bpl.Type>(new Bpl.Type[] {this.RefType}), t); Bpl.TypedIdent tident = new Bpl.TypedIdent(tok, fieldName, mt); v = new Bpl.GlobalVariable(tok, tident); } return v; }