/// <summary> /// Creates a new package for an IPostcondition contract. /// </summary> public XPostcondition(IMetadataHost host, IPostcondition postcondition, string inheritedFrom, string inheritedFromTypeName, DocTracker docTracker) : base(host, inheritedFrom, inheritedFromTypeName, docTracker) { Contract.Requires(postcondition != null); Contract.Requires(docTracker != null); this.postcondition = postcondition; }
/// <summary> /// Traverses the postCondition. /// </summary> public void Traverse(IPostcondition postCondition) { Contract.Requires(postCondition != null); preorderVisitor.Visit(postCondition); if (StopTraversal) { return; } TraverseChildren(postCondition); }
public void Visit(IPostcondition postCondition) { this.result = this.copier.Copy(postCondition); }
/// <summary> /// Makes a shallow copy of the given postCondition. /// </summary> public virtual Postcondition Copy(IPostcondition postCondition) { return new Postcondition(postCondition); }
/// <summary> /// Visits the specified post condition. /// </summary> /// <param name="postCondition">The post condition.</param> public virtual IPostcondition Visit(IPostcondition postCondition) { Postcondition mutablePostCondition = postCondition as Postcondition; if (!this.copyOnlyIfNotAlreadyMutable || mutablePostCondition == null) mutablePostCondition = new Postcondition(postCondition); return this.Visit(mutablePostCondition); }
/// <summary> /// Visits the given postCondition. /// </summary> public virtual void Visit(IPostcondition postCondition) { this.Visit((IContractElement)postCondition); }
/// <summary> /// Traverses the children of the postCondition. /// </summary> public virtual void TraverseChildren(IPostcondition postCondition) { Contract.Requires(postCondition != null); this.TraverseChildren((IContractElement)postCondition); }
/// <summary> /// Visits the given postCondition. /// </summary> public virtual void Visit(IPostcondition postCondition) { }
/// <summary> /// Makes a shallow copy of the given postCondition. /// </summary> public virtual Postcondition Copy(IPostcondition postCondition) { Contract.Requires(postCondition != null); Contract.Ensures(Contract.Result<Postcondition>() != null); return new Postcondition(postCondition); }
/// <summary> /// Traverses the children of the postCondition. /// </summary> public virtual void TraverseChildren(IPostcondition postCondition) { Contract.Requires(postCondition != null); TraverseChildren((IContractElement)postCondition); }
public void Visit(IPostcondition postCondition) { traverser.Traverse(postCondition); }
/// <summary> /// Creates a postcondition that shares all of the information in <paramref name="postcondition"/> /// </summary> /// <param name="postcondition"></param> public Postcondition(IPostcondition postcondition) : base(postcondition) { }
private static List<IPostcondition> FilterUserMessage(IContractAwareHost host, IEnumerable<IPostcondition> postconditions, ITypeDefinition typeDefinition) { int n = (int)IteratorHelper.EnumerableCount(postconditions); var filteredPostconditions = new IPostcondition[n]; var i = 0; foreach (var p in postconditions) { if (CanAccess(p.Description, typeDefinition)) { filteredPostconditions[i] = p; } else { var newP = new Postcondition(p); newP.Description = null; filteredPostconditions[i] = newP; } i++; } return new List<IPostcondition>(filteredPostconditions); }
/// <summary> /// Rewrites the given postCondition. /// </summary> public virtual IPostcondition Rewrite(IPostcondition postCondition) { var mutablePostcondition = postCondition as Postcondition; if (mutablePostcondition == null) return postCondition; this.RewriteChildren(mutablePostcondition); return mutablePostcondition; }
public void Visit(IPostcondition postCondition) { Contract.Assert(postCondition != null); Visit((IContractElement)postCondition); }
/// <summary> /// Makes a deep copy of the given postCondition. /// </summary> public Postcondition Copy(IPostcondition postCondition) { Contract.Requires(postCondition != null); Contract.Ensures(Contract.Result<Postcondition>() != null); var mutableCopy = this.shallowCopier.Copy(postCondition); this.Copy((ContractElement)mutableCopy); return mutableCopy; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given postCondition. /// </summary> public virtual void Visit(IPostcondition postCondition) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(postCondition); this.Visit(postCondition.Condition); if (postCondition.Description != null) this.Visit(postCondition.Description); //^ 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(); }
/// <summary> /// Traverses the postCondition. /// </summary> public void Traverse(IPostcondition postCondition) { Contract.Requires(postCondition != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(postCondition); if (this.StopTraversal) return; this.TraverseChildren(postCondition); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(postCondition); }
/// <summary> /// Get the mutable copy of a postcondition. /// </summary> /// <param name="postcondition"></param> /// <returns></returns> public virtual Postcondition GetMutableCopy(IPostcondition postcondition) { object cachedValue; if (this.cache.TryGetValue(postcondition, out cachedValue)) return (Postcondition)cachedValue; var result = new Postcondition(postcondition); // Probably not necessary, no two postconditions are shared. this.cache.Add(postcondition, result); this.cache.Add(result, result); return result; }
public void Visit(IPostcondition postCondition) { this.traverser.Traverse(postCondition); }
/// <summary> /// Returns a deep copy of the <param name="postcondition"/>. /// </summary> public virtual IPostcondition Substitute(IPostcondition postcondition) { this.coneAlreadyFixed = true; return this.DeepCopy(new Postcondition(postcondition)); }
public void Visit(IPostcondition postCondition) { Contract.Requires(postCondition != null); throw new NotImplementedException(); }
/// <summary> /// Makes a deep copy of the given postCondition. /// </summary> public Postcondition Copy(IPostcondition postCondition) { var mutableCopy = this.shallowCopier.Copy(postCondition); this.Copy((ContractElement)mutableCopy); return mutableCopy; }
/// <summary> /// Visits the specified post condition. /// </summary> /// <param name="postCondition">The post condition.</param> public virtual IPostcondition Visit(IPostcondition postCondition) { if (this.stopTraversal) return postCondition; Postcondition mutablePostCondition = postCondition as Postcondition; if (mutablePostCondition == null) return postCondition; mutablePostCondition.Condition = this.Visit(mutablePostCondition.Condition); if (mutablePostCondition.Description != null) mutablePostCondition.Description = this.Visit(mutablePostCondition.Description); return mutablePostCondition; }