public ArrayState( ArraySegmentationEnvironment <NonRelationalValueAbstraction <BoxedVariable <Variable>, BoxedExpression>, BoxedVariable <Variable>, BoxedExpression> array, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> numerical, Analyzers.NonNull.TypeBindings <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable> .Domain?nonnull, IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression>[] otherStates, int[] mappings) { Contract.Requires(array != null); Contract.Requires(numerical != null); Contract.Requires(otherStates != null); Contract.Requires(mappings != null); Contract.Requires(Contract.ForAll(otherStates, x => x != null)); Contract.Ensures(this.arrayState == array); Contract.Ensures(this.numericalState == numerical); Contract.Ensures(this.nonnullState.Equals(nonnull)); Contract.Ensures(this.otherStates == otherStates); Contract.Ensures(this.mappings == mappings); this.arrayState = array; this.numericalState = numerical; this.nonnullState = nonnull; this.otherStates = otherStates; this.mappings = mappings; }
public ArrayState UpdateArray(ArraySegmentationEnvironment <NonRelationalValueAbstraction <BoxedVariable <Variable>, BoxedExpression>, BoxedVariable <Variable>, BoxedExpression> newArrayState) { Contract.Requires(newArrayState != null); Contract.Ensures(Contract.Result <ArrayState>() != null); return(new ArrayState(newArrayState, this.numericalState, this.nonnullState, this.otherStates, this.mappings)); }
public ArrayState( ArraySegmentationEnvironment <NonRelationalValueAbstraction <BoxedVariable <Variable>, BoxedExpression>, BoxedVariable <Variable>, BoxedExpression> array, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> numerical, Analyzers.NonNull.TypeBindings <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable> .Domain?nonnull = null ) : this(array, numerical, nonnull, new IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression> [0], new int[0]) { Contract.Requires(array != null); Contract.Requires(numerical != null); }
protected ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression> MaterializeEnumerable <Elements>( APC postPC, ArraySegmentationEnvironment <Elements, BoxedVariable <Variable>, BoxedExpression> preState, Variable enumerable, Elements initialValue) where Elements : class, IAbstractDomainForArraySegmentationAbstraction <Elements, BoxedVariable <Variable> > { Variable modelArray; if (this.Context.ValueContext.TryGetModelArray(postPC, enumerable, out modelArray)) { MaterializeArray(postPC, preState, (BoxedExpression be) => CheckOutcome.True, modelArray, initialValue, initialValue); } return(null); }
public ArrayState( ArraySegmentationEnvironment <NonRelationalValueAbstraction <BoxedVariable <Variable>, BoxedExpression>, BoxedVariable <Variable>, BoxedExpression> array, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> numerical, IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression>[] otherStates, int[] mappings ) : this(array, numerical, null, otherStates, mappings) { Contract.Requires(array != null); Contract.Requires(numerical != null); Contract.Requires(otherStates != null); Contract.Requires(mappings != null); Contract.Requires(Contract.ForAll(otherStates, x => x != null)); }
protected ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression> MaterializeArray <Elements>( APC postPC, ArraySegmentationEnvironment <Elements, BoxedVariable <Variable>, BoxedExpression> preState, Func <BoxedExpression, FlatAbstractDomain <bool> > CheckIfNonZero, Variable arrayValue, Elements initialValue, Elements bottom) where Elements : class, IAbstractDomainForArraySegmentationAbstraction <Elements, BoxedVariable <Variable> > { Contract.Requires(preState != null); Contract.Requires(initialValue != null); var boxSym = new BoxedVariable <Variable>(arrayValue); ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression> arraySegment; if (preState.TryGetValue(boxSym, out arraySegment)) { return(arraySegment); // already materialized } Variable array_Length; if (this.Context.ValueContext.TryGetArrayLength(postPC, arrayValue, out array_Length)) { var isNonEmpty = CheckIfNonZero(this.ToBoxedExpression(postPC, array_Length)).IsTrue(); var limits = new NonNullList <SegmentLimit <BoxedVariable <Variable> > >() { new SegmentLimit <BoxedVariable <Variable> >(NormalizedExpression <BoxedVariable <Variable> > .For(0), false), // { 0 } new SegmentLimit <BoxedVariable <Variable> >(NormalizedExpression <BoxedVariable <Variable> > .For(new BoxedVariable <Variable>(array_Length)), !isNonEmpty) // { symb.Length } }; var elements = new NonNullList <Elements>() { initialValue }; var newSegment = new ArraySegmentation <Elements, BoxedVariable <Variable>, BoxedExpression>( limits, elements, bottom, this.ExpressionManager); preState.AddElement(new BoxedVariable <Variable>(arrayValue), newSegment); return(newSegment); } return(null); }
ArrayCounterInitialization <AbstractDomain>(APC pc, Local local, Variable source, ArrayState resultState, ArraySegmentationEnvironment <AbstractDomain, BoxedVariable <Variable>, BoxedExpression> mySubState) where AbstractDomain : class, IAbstractDomainForArraySegmentationAbstraction <AbstractDomain, BoxedVariable <Variable> > { Contract.Ensures(Contract.Result <ArraySegmentationEnvironment <AbstractDomain, BoxedVariable <Variable>, BoxedExpression> >() != null); var sourceExp = ToBoxedExpression(pc, source); // we look for loop initializations i == var Variable localValue; if (sourceExp.IsVariable && this.Context.ValueContext.TryLocalValue(this.Context.MethodContext.CFG.Post(pc), local, out localValue)) { // If source >= 0, we check if source <= arr.Length, for some array 'arr' // If this is the case, then we can try to refine the segmentation including source and locValue if (resultState.Numerical.CheckIfGreaterEqualThanZero(sourceExp).IsTrue()) { var sourceNorm = ToNormalizedExpression(source); var toUpdate = new Dictionary <BoxedVariable <Variable>, ArraySegmentation <AbstractDomain, BoxedVariable <Variable>, BoxedExpression> >(); foreach (var pair in mySubState.Elements) { if (!pair.Value.IsEmptyArray && pair.Value.IsNormal && // We do the trick only for arrays {0} val {Len} as otherwise we should be more careful where we refine the segmentation, as for instance the update below may be too rough. However, I haven't find any interesting non-artificial example for it pair.Value.Elements.Count() == 1) { foreach (var limit in pair.Value.LastLimit) { if (resultState.Numerical.CheckIfLessEqualThan(sourceExp, limit.Convert(this.Encoder)).IsTrue()) { IAbstractDomain abstractValue; if (pair.Value.TryGetAbstractValue( NormalizedExpression <BoxedVariable <Variable> > .For(0), sourceNorm, resultState.Numerical, out abstractValue) && abstractValue is AbstractDomain) { ArraySegmentation <AbstractDomain, BoxedVariable <Variable>, BoxedExpression> newSegment; if (pair.Value.TrySetAbstractValue(sourceNorm, (AbstractDomain)abstractValue, resultState.Numerical, out newSegment)) { toUpdate.Add(pair.Key, newSegment); break; // We've already updated this segmentation } } } } } } foreach (var pair in toUpdate) { mySubState[pair.Key] = pair.Value; } } } return(mySubState); }
public ArrayState Widening(ArrayState a) { Contract.Requires(this.PluginsCount == a.PluginsCount); Contract.Ensures(Contract.Result <ArrayState>() != null); Contract.Ensures(Contract.Result <ArrayState>().PluginsCount == this.PluginsCount); ArrayState result; if (AbstractDomainsHelper.TryTrivialJoin(this, a, out result)) { return(result); } #if DEBUG // F: for debugging result = null; #endif ArraySegmentationEnvironment <NonRelationalValueAbstraction <BoxedVariable <Variable>, BoxedExpression>, BoxedVariable <Variable>, BoxedExpression> array = null; INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> numerical = null; #if PARALLELWIDENING var arrayTask = Task.Run(() => array = this.Array.Widening(a.Array)); var numericalTask = Task.Run(() => numerical = this.Numerical.Widening(a.Numerical) as INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression>); #else array = this.Array.Widening(a.Array); numerical = this.Numerical.Widening(a.Numerical) as INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression>; #endif var plugins = new IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression> [this.PluginsCount]; for (var i = 0; i < this.PluginsCount; i++) { plugins[i] = this.PluginAbstractStateAt(i).Widening(a.PluginAbstractStateAt(i)) as IAbstractDomainForEnvironments <BoxedVariable <Variable>, BoxedExpression>; } #if PARALLELWIDENING Task.WaitAll(arrayTask, numericalTask); #endif return(new ArrayState(array, numerical, plugins, this.mappings)); }
public IsArrayPure(ArraySegmentationEnvironment <TwoValuesLattice <BoxedVariable <Variable> >, BoxedVariable <Variable>, BoxedExpression> state) { Contract.Requires(state != null); this.state = state; }