Ejemplo n.º 1
0
 /// <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;
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Traverses the type invariant.
 /// </summary>
 public void Traverse(ITypeInvariant typeInvariant)
 {
     Contract.Requires(typeInvariant != null);
     preorderVisitor.Visit(typeInvariant);
     if (StopTraversal)
     {
         return;
     }
     TraverseChildren(typeInvariant);
 }
Ejemplo n.º 3
0
 public void Visit(ITypeInvariant typeInvariant)
 {
     this.result = this.copier.Copy(typeInvariant);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Makes a shallow copy of the given type invariant.
 /// </summary>
 public virtual TypeInvariant Copy(ITypeInvariant typeInvariant)
 {
     return new TypeInvariant(typeInvariant);
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Visits the given type invariant.
 /// </summary>
 public virtual void Visit(ITypeInvariant typeInvariant)
 {
     this.Visit((IContractElement)typeInvariant);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Traverses the children of the type invariant.
 /// </summary>
 public virtual void TraverseChildren(ITypeInvariant typeInvariant)
 {
     Contract.Requires(typeInvariant != null);
       this.TraverseChildren((IContractElement)typeInvariant);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Visits the given type invariant.
 /// </summary>
 public virtual void Visit(ITypeInvariant typeInvariant)
 {
 }
Ejemplo n.º 9
0
    /// <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);
    }
Ejemplo n.º 10
0
 /// <summary>
 ///     Traverses the children of the type invariant.
 /// </summary>
 public virtual void TraverseChildren(ITypeInvariant typeInvariant)
 {
     Contract.Requires(typeInvariant != null);
     TraverseChildren((IContractElement)typeInvariant);
 }
Ejemplo n.º 11
0
 public void Visit(ITypeInvariant typeInvariant)
 {
     traverser.Traverse(typeInvariant);
 }
Ejemplo n.º 12
0
 /// <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;
 }
Ejemplo n.º 13
0
 /// <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;
 }
Ejemplo n.º 14
0
 public void Visit(ITypeInvariant typeInvariant)
 {
     Contract.Assert(typeInvariant != null);
     Visit((IContractElement)typeInvariant);
 }
Ejemplo n.º 15
0
    /// <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;
    }
Ejemplo n.º 16
0
 //^ 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();
 }
Ejemplo n.º 17
0
 /// <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;
 }
Ejemplo n.º 18
0
 /// <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);
 }
Ejemplo n.º 19
0
 /// <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;
 }
Ejemplo n.º 20
0
 public void Visit(ITypeInvariant typeInvariant)
 {
     this.traverser.Traverse(typeInvariant);
 }
Ejemplo n.º 21
0
 /// <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));
 }
Ejemplo n.º 22
0
 public void Visit(ITypeInvariant typeInvariant)
 {
     Contract.Requires(typeInvariant != null);
       throw new NotImplementedException();
 }
Ejemplo n.º 23
0
 /// <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;
 }
Ejemplo n.º 24
0
 /// <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;
 }
Ejemplo n.º 25
0
 /// <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;
 }