public DisInterval BoundsFor(Expression v) { var result = FirstDisjunct.BoundsFor(v); for (int i = 1; i < this.disjuncts.Length; i++) { result = (DisInterval)result.Join(this.disjuncts[i].BoundsFor(v)); } return(result); }
public override INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> Assume(APC pc, string tag, Variable condition, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> data) { bool StateValueIsKnown = false; Variable varForThisDotState = ThisDotState(pc); BoxedExpression boxedThisDotState = BoxedExpression.For(this.context.ExpressionContext.Refine(pc, varForThisDotState), this.decoderForExpressions.Outdecoder); BoxedExpression boxedCondition = BoxedExpression.For(this.context.ExpressionContext.Refine(pc, condition), this.decoderForExpressions.Outdecoder); var interval = data.BoundsFor(boxedThisDotState); AbstractDomains.Numerical.Rational rat; if (interval.TryGetSingletonValue(out rat)) { long lv; if (rat.TryInt64(out lv)) { int state = (int)lv; StateValueIsKnown = true; } } if (tag == "false") { data.TestFalse(boxedCondition); } else if (tag == "true") { data.TestTrue(boxedCondition); } // This assume statement is the beginning of a state slice only if the state value is not known // prior to the statement. if (!StateValueIsKnown) { interval = data.BoundsFor(boxedThisDotState); if (interval.TryGetSingletonValue(out rat)) { long lv; if (rat.TryInt64(out lv)) { int state = (int)lv; if (this.stateSliceEntries.ContainsKey(state)) { this.stateSliceEntries[state].Add(pc); } else { this.stateSliceEntries[state] = new Set <APC>(pc); } } } } return(base.Assume(pc, tag, condition, data)); }
/// <summary> /// WB(dest) == size /// </summary> public override INumericalAbstractDomain<BoxedVariable<Variable>, BoxedExpression> Localloc(APC pc, Variable dest, Variable size, INumericalAbstractDomain<BoxedVariable<Variable>, BoxedExpression> data) { Variable WB_dest; if (this.Context.ValueContext.TryGetWritableBytes(this.Context.MethodContext.CFG.Post(pc), dest, out WB_dest)) { var sizeExp = ToBoxedExpression(pc, size); var tryConst = data.BoundsFor(sizeExp); if (tryConst.IsSingleton) { data.AssumeInDisInterval(new BoxedVariable<Variable>(WB_dest), tryConst); } data = data.TestTrueGeqZero(sizeExp); data = data.TestTrueEqual(ToBoxedExpression(pc, WB_dest), sizeExp); } return data; }
public override INumericalAbstractDomain <BoxedExpression> Assume(APC pc, string tag, Variable condition, INumericalAbstractDomain <BoxedExpression> data) { BoxedExpression boxedCondition = BoxedExpression.For(this.context.Refine(pc, condition), this.decoderForExpressions.Outdecoder); if (tag == "false") { data.TestFalse(boxedCondition); } else if (tag == "true") { data.TestTrue(boxedCondition); } Variable varForThisDotState = ThisDotState(pc); BoxedExpression boxedThisDotState = BoxedExpression.For(this.context.Refine(pc, varForThisDotState), this.decoderForExpressions.Outdecoder); AbstractDomains.Numerical.Interval interval = data.BoundsFor(boxedThisDotState); AbstractDomains.Numerical.Rational rat; if (interval.TryGetSingletonValue(out rat)) { long lv; if (rat.TryInt64(out lv)) { int state = (int)lv; if (this.stateInfo.ContainsKey(state)) { this.stateInfo[state].Add(pc); } else { this.stateInfo[state] = new Set <APC>(pc); } } } return(base.Assume(pc, tag, condition, data)); }