/// <summary> /// Traverses the loop contract. /// </summary> public void Traverse(ILoopContract loopContract) { Contract.Requires(loopContract != null); preorderVisitor.Visit(loopContract); if (StopTraversal) { return; } TraverseChildren(loopContract); }
/// <summary> /// /// </summary> /// <param name="loopContract"></param> public LoopContract(ILoopContract loopContract) { this.invariants = new List <ILoopInvariant>(loopContract.Invariants); this.locations = new List <ILocation>(loopContract.Locations); if (loopContract.Writes != null) { this.writes = new List <IExpression>(loopContract.Writes); } this.variants = new List <IExpression>(loopContract.Variants); }
/// <summary> /// Traverses the children of the loop contract. /// </summary> public virtual void TraverseChildren(ILoopContract loopContract) { Contract.Requires(loopContract != null); Traverse(loopContract.Invariants); if (StopTraversal) { return; } Traverse(loopContract.Variants); if (StopTraversal) { return; } Traverse(loopContract.Writes); }
/// <summary> /// Traverses the loop contract. /// </summary> public void Traverse(ILoopContract loopContract) { Contract.Requires(loopContract != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(loopContract); if (this.StopTraversal) return; this.TraverseChildren(loopContract); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(loopContract); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given loop contract. /// </summary> public virtual void Visit(ILoopContract loopContract) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(loopContract); this.Visit(loopContract.Invariants); this.Visit(loopContract.Variants); this.Visit(loopContract.Writes); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
public void Visit(ILoopContract loopContract) { Contract.Assume(false); }
/// <summary> /// Makes a shallow copy of the given loop contract. /// </summary> public virtual LoopContract Copy(ILoopContract loopContract) { return new LoopContract(loopContract); }
/// <summary> /// Makes a deep copy of the given loop contract. /// </summary> public LoopContract Copy(ILoopContract loopContract) { var mutableCopy = this.shallowCopier.Copy(loopContract); mutableCopy.Invariants = this.Copy(mutableCopy.Invariants); mutableCopy.Variants = this.Copy(mutableCopy.Variants); mutableCopy.Writes = this.Copy(mutableCopy.Writes); return mutableCopy; }
/// <summary> /// Visits the specified loop contract. /// </summary> /// <param name="loopContract">The loop contract.</param> /// <returns></returns> public virtual ILoopContract Visit(ILoopContract loopContract) { LoopContract mutableLoopContract = loopContract as LoopContract; if (!this.copyOnlyIfNotAlreadyMutable || mutableLoopContract == null) mutableLoopContract = new LoopContract(loopContract); return this.Visit(mutableLoopContract); }
/// <summary> /// Visits the given loop contract. /// </summary> public virtual void Visit(ILoopContract loopContract) { }
/// <summary> /// Makes a deep copy of the given loop contract. /// </summary> public LoopContract Copy(ILoopContract loopContract) { Contract.Requires(loopContract != null); Contract.Ensures(Contract.Result<LoopContract>() != null); var mutableCopy = this.shallowCopier.Copy(loopContract); mutableCopy.Invariants = this.Copy(mutableCopy.Invariants); mutableCopy.Variants = this.Copy(mutableCopy.Variants); mutableCopy.Writes = this.Copy(mutableCopy.Writes); return mutableCopy; }
/// <summary> /// Makes a shallow copy of the given loop contract. /// </summary> public virtual LoopContract Copy(ILoopContract loopContract) { Contract.Requires(loopContract != null); Contract.Ensures(Contract.Result<LoopContract>() != null); return new LoopContract(loopContract); }
/// <summary> /// Associates the given object with the given loop contract. /// If the object is already associated with a loop contract, that association will be lost as a result of this call. /// </summary> /// <param name="contract">The contract to associate with loop.</param> /// <param name="loop">An object to associate with the loop contract. This can be any kind of object.</param> public void AssociateLoopWithContract(object loop, ILoopContract contract) { lock (this.methodContractFor) { this.loopContractFor[loop] = contract; } }
/// <summary> /// Rewrites the given loop contract. /// </summary> public virtual ILoopContract Rewrite(ILoopContract loopContract) { var mutableLoopContract = loopContract as LoopContract; if (mutableLoopContract == null) return loopContract; this.RewriteChildren(mutableLoopContract); return mutableLoopContract; }
/// <summary> /// Traverses the children of the loop contract. /// </summary> public virtual void TraverseChildren(ILoopContract loopContract) { Contract.Requires(loopContract != null); this.Traverse(loopContract.Invariants); if (this.StopTraversal) return; this.Traverse(loopContract.Variants); if (this.StopTraversal) return; this.Traverse(loopContract.Writes); }
/// <summary> /// /// </summary> /// <param name="loopContract"></param> public LoopContract(ILoopContract loopContract) { this.invariants = new List<ILoopInvariant>(loopContract.Invariants); this.locations = new List<ILocation>(loopContract.Locations); if (loopContract.Writes != null) this.writes = new List<IExpression>(loopContract.Writes); this.variants = new List<IExpression>(loopContract.Variants); }
public void Visit(ILoopContract loopContract) { Contract.Requires(loopContract != null); throw new NotImplementedException(); }
/// <summary> /// Visits the specified loop contract. /// </summary> /// <param name="loopContract">The loop contract.</param> /// <returns></returns> public virtual ILoopContract Visit(ILoopContract loopContract) { if (this.stopTraversal) return loopContract; LoopContract mutableLoopContract = loopContract as LoopContract; if (mutableLoopContract == null) return loopContract; mutableLoopContract.Invariants = this.Visit(mutableLoopContract.Invariants); mutableLoopContract.Writes = this.Visit(mutableLoopContract.Writes); return mutableLoopContract; }