Beispiel #1
0
 /// <summary>
 ///     Traverses the loop contract.
 /// </summary>
 public void Traverse(ILoopContract loopContract)
 {
     Contract.Requires(loopContract != null);
     preorderVisitor.Visit(loopContract);
     if (StopTraversal)
     {
         return;
     }
     TraverseChildren(loopContract);
 }
Beispiel #2
0
 /// <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);
 }
Beispiel #3
0
 /// <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);
 }
Beispiel #4
0
 /// <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);
 }
Beispiel #5
0
 //^ 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();
 }
Beispiel #6
0
 public void Visit(ILoopContract loopContract)
 {
     Contract.Assume(false);
 }
Beispiel #7
0
 /// <summary>
 /// Makes a shallow copy of the given loop contract.
 /// </summary>
 public virtual LoopContract Copy(ILoopContract loopContract)
 {
     return new LoopContract(loopContract);
 }
Beispiel #8
0
 /// <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;
 }
Beispiel #9
0
 /// <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);
 }
Beispiel #10
0
 /// <summary>
 /// Visits the given loop contract.
 /// </summary>
 public virtual void Visit(ILoopContract loopContract)
 {
 }
Beispiel #11
0
    /// <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;
    }
Beispiel #12
0
    /// <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);
    }
Beispiel #13
0
 /// <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;
     }
 }
Beispiel #14
0
 /// <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;
 }
Beispiel #15
0
 /// <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);
 }
Beispiel #16
0
 /// <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);
 }
Beispiel #17
0
 public void Visit(ILoopContract loopContract)
 {
     Contract.Assume(false);
 }
Beispiel #18
0
 /// <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;
   }
 }
Beispiel #19
0
 public void Visit(ILoopContract loopContract)
 {
     Contract.Requires(loopContract != null);
       throw new NotImplementedException();
 }
Beispiel #20
0
 /// <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;
 }