public static void SetContextEdge(this ContextEdge @this, BijectiveMap <Subroutine, int> subroutineLocalIds, STuple <CFGBlock, CFGBlock, string> edge) { @this.Block1SubroutineLocalId = subroutineLocalIds[edge.One.Subroutine]; @this.Block1Index = edge.One.Index; @this.Block2SubroutineLocalId = subroutineLocalIds[edge.Two.Subroutine]; @this.Block2Index = edge.Two.Index; @this.Tag = edge.Three; }
public MethodHasher( AnalysisDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, SymbolicValue, ILogOptions, IMethodResult <SymbolicValue> > driver, IMethodDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, SymbolicValue, ILogOptions> mDriver, bool trace, Func <Subroutine, int> subroutineIdentifier = null, Func <Type, int> typeIdentifier = null ) { this.driver = driver; this.mDriver = mDriver; this.tw = new HashWriter(trace); this.ilHasher = new ILHasher(this.mDriver.StackLayer, this.tw, this.ReferenceType, this.InlinedSubroutine); if (subroutineIdentifier != null) { this.subroutineIdentifier = subroutineIdentifier; } else { // unique ID for a subroutine (used to put warnings into contexts) var subroutineLocalIds = new BijectiveMap <Subroutine, int>(); this.subroutineIdentifier = sub => { int res; if (!subroutineLocalIds.TryGetValue(sub, out res)) { subroutineLocalIds.Add(sub, res = subroutineLocalIds.Count); } return(res); }; } if (typeIdentifier != null) { this.typeIdentifier = typeIdentifier; } else { // unique ID for types (used for general serialization of boxed expressions) var referencedTypesLocalIds = new BijectiveMap <Type, int>(); this.typeIdentifier = typ => { int res; if (!referencedTypesLocalIds.TryGetValue(typ, out res)) { referencedTypesLocalIds.Add(typ, res = referencedTypesLocalIds.Count); } return(res); }; } }
public static Witness GetWitness(this Outcome @this, BijectiveMap <Subroutine, int> subroutineLocalIds) { Contract.Ensures(Contract.Result <Witness>() != null); return(new Witness( null, // F: The proof obligation ID is lost in the serialization/deserialization @this.WarningType, @this.ProofOutcome, @this.GetAPC(subroutineLocalIds), new Set <WarningContext>(@this.OutcomeContexts.Select(c => c.WarningContext)))); }
public static APC GetAPC(this OutcomeOrSuggestion @this, BijectiveMap <Subroutine, int> subroutineLocalIds) { return(new APC( subroutineLocalIds.KeyForValue(@this.SubroutineLocalId).Blocks.First(b => b.Index == @this.BlockIndex), @this.ApcIndex, @this.ContextEdges .OrderBy(edge => edge.Rank) .Select(edge => edge.GetContextEdge(subroutineLocalIds)) .Aggregate((FList <STuple <CFGBlock, CFGBlock, string> >)null, (accu, edge) => accu.Cons(edge)) .Reverse())); }
/// <summary> /// Must be called only once ! /// </summary> public static void SetWitness(this IClousotCache @this, Outcome outcome, Witness witness, BijectiveMap <Subroutine, int> subroutineLocalIds) { if (@outcome.OutcomeContexts.Any()) { throw new InvalidOperationException(); } @outcome.ProofOutcome = witness.Outcome; @outcome.WarningType = witness.Warning; @this.SetAPC(outcome, witness.PC, subroutineLocalIds); foreach (var c in witness.Context) { @this.AddNewOutcomeContext(outcome, c); } }
/// <summary> /// Must be called only once ! /// </summary> public static void SetAPC(this IClousotCache @this, OutcomeOrSuggestion that, APC apc, BijectiveMap <Subroutine, int> subroutineLocalIds) { if (@that.ContextEdges.Any()) { throw new InvalidOperationException(); } @that.SubroutineLocalId = subroutineLocalIds[apc.Block.Subroutine]; @that.BlockIndex = apc.Block.Index; @that.ApcIndex = apc.Index; int rank = 0; foreach (var edge in apc.SubroutineContext.GetEnumerable()) { var added = @this.AddNewContextEdge(that, rank); added.SetContextEdge(subroutineLocalIds, edge); rank++; } }
public static STuple <CFGBlock, CFGBlock, string> GetContextEdge(this ContextEdge @this, BijectiveMap <Subroutine, int> subroutineLocalIds) { return(new STuple <CFGBlock, CFGBlock, string>( subroutineLocalIds.KeyForValue(@this.Block1SubroutineLocalId).Blocks.First(b => b.Index == @this.Block1Index), subroutineLocalIds.KeyForValue(@this.Block2SubroutineLocalId).Blocks.First(b => b.Index == @this.Block2Index), @this.Tag)); }