/// <summary> /// Creates a new package for an ITypeInvariant contract. /// </summary> public XInvariant(IMetadataHost host, ITypeInvariant invariant, DocTracker docTracker) : base(host, null, null, docTracker) { Contract.Requires(invariant != null); Contract.Requires(docTracker != null); this.invariant = invariant; }
/// <summary> /// Traverses the type invariant. /// </summary> public void Traverse(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); preorderVisitor.Visit(typeInvariant); if (StopTraversal) { return; } TraverseChildren(typeInvariant); }
public void Visit(ITypeInvariant typeInvariant) { this.result = this.copier.Copy(typeInvariant); }
/// <summary> /// Makes a shallow copy of the given type invariant. /// </summary> public virtual TypeInvariant Copy(ITypeInvariant typeInvariant) { return new TypeInvariant(typeInvariant); }
/// <summary> /// Visits the specified type invariant. /// </summary> /// <param name="typeInvariant">The type invariant.</param> public virtual ITypeInvariant Visit(ITypeInvariant typeInvariant) { TypeInvariant mutableTypeInvariant = typeInvariant as TypeInvariant; if (!this.copyOnlyIfNotAlreadyMutable || mutableTypeInvariant == null) mutableTypeInvariant = new TypeInvariant(typeInvariant); return this.Visit(mutableTypeInvariant); }
/// <summary> /// Visits the given type invariant. /// </summary> public virtual void Visit(ITypeInvariant typeInvariant) { this.Visit((IContractElement)typeInvariant); }
/// <summary> /// Traverses the children of the type invariant. /// </summary> public virtual void TraverseChildren(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); this.TraverseChildren((IContractElement)typeInvariant); }
/// <summary> /// Visits the given type invariant. /// </summary> public virtual void Visit(ITypeInvariant typeInvariant) { }
/// <summary> /// Makes a shallow copy of the given type invariant. /// </summary> public virtual TypeInvariant Copy(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); Contract.Ensures(Contract.Result<TypeInvariant>() != null); return new TypeInvariant(typeInvariant); }
/// <summary> /// Traverses the children of the type invariant. /// </summary> public virtual void TraverseChildren(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); TraverseChildren((IContractElement)typeInvariant); }
public void Visit(ITypeInvariant typeInvariant) { traverser.Traverse(typeInvariant); }
/// <summary> /// Creates a type invariant that shares all of the information in <paramref name="typeInvariant"/>. /// </summary> /// <param name="typeInvariant"></param> public TypeInvariant(ITypeInvariant typeInvariant) : base(typeInvariant) { this.isAxiom = typeInvariant.IsAxiom; this.name = typeInvariant.Name; }
/// <summary> /// Rewrites the given type invariant. /// </summary> public virtual ITypeInvariant Rewrite(ITypeInvariant typeInvariant) { var mutableTypeInvariant = typeInvariant as TypeInvariant; if (mutableTypeInvariant == null) return typeInvariant; this.RewriteChildren(mutableTypeInvariant); return mutableTypeInvariant; }
public void Visit(ITypeInvariant typeInvariant) { Contract.Assert(typeInvariant != null); Visit((IContractElement)typeInvariant); }
/// <summary> /// Makes a deep copy of the given type invariant. /// </summary> public TypeInvariant Copy(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); Contract.Ensures(Contract.Result<TypeInvariant>() != null); var mutableCopy = this.shallowCopier.Copy(typeInvariant); this.Copy((ContractElement)mutableCopy); return mutableCopy; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given type invariant. /// </summary> public virtual void Visit(ITypeInvariant typeInvariant) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(typeInvariant); this.Visit(typeInvariant.Condition); if (typeInvariant.Description != null) this.Visit(typeInvariant.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 type invariant. /// </summary> public void Traverse(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(typeInvariant); if (this.StopTraversal) return; this.TraverseChildren(typeInvariant); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(typeInvariant); }
/// <summary> /// Get the mutable copy of a type invariant. /// </summary> /// <param name="typeInvariant"></param> /// <returns></returns> public virtual TypeInvariant GetMutableCopy(ITypeInvariant typeInvariant) { object cachedValue; if (this.cache.TryGetValue(typeInvariant, out cachedValue)) return (TypeInvariant)cachedValue; var result = new TypeInvariant(typeInvariant); // Probably not necessary, no two thrown exceptions are shared. this.cache.Add(typeInvariant, result); this.cache.Add(result, result); return result; }
public void Visit(ITypeInvariant typeInvariant) { this.traverser.Traverse(typeInvariant); }
/// <summary> /// Returns a deep copy of the <param name="typeInvariant"/>. /// </summary> public virtual ITypeInvariant Substitute(ITypeInvariant typeInvariant) { this.coneAlreadyFixed = true; return this.DeepCopy(new TypeInvariant(typeInvariant)); }
public void Visit(ITypeInvariant typeInvariant) { Contract.Requires(typeInvariant != null); throw new NotImplementedException(); }
/// <summary> /// Makes a deep copy of the given type invariant. /// </summary> public TypeInvariant Copy(ITypeInvariant typeInvariant) { var mutableCopy = this.shallowCopier.Copy(typeInvariant); this.Copy((ContractElement)mutableCopy); return mutableCopy; }
/// <summary> /// Visits the specified type invariant. /// </summary> /// <param name="typeInvariant">The type invariant.</param> public virtual ITypeInvariant Visit(ITypeInvariant typeInvariant) { if (this.stopTraversal) return typeInvariant; TypeInvariant mutableTypeInvariant = typeInvariant as TypeInvariant; if (mutableTypeInvariant == null) return typeInvariant; mutableTypeInvariant.Condition = this.Visit(mutableTypeInvariant.Condition); if (mutableTypeInvariant.Description != null) mutableTypeInvariant.Description = this.Visit(mutableTypeInvariant.Description); return mutableTypeInvariant; }