示例#1
0
 /// <summary>
 /// A copy constructor that allocates an instance that is the same as the given template, except for its containing block.
 /// </summary>
 /// <param name="containingBlock">The containing block of the copied type invariant. This should be different from the containing block of the template.</param>
 /// <param name="template">The statement to copy.</param>
 protected TypeInvariant(BlockStatement containingBlock, TypeInvariant template)
     : base(containingBlock, template)
 {
     if (template.Name != null)
     this.name = template.Name.MakeCopyFor(containingBlock.Compilation);
       this.isAxiom = template.isAxiom;
 }
示例#2
0
 /// <summary>
 /// Visits the specified type invariant.
 /// </summary>
 /// <param name="typeInvariant">The type invariant.</param>
 protected virtual ITypeInvariant DeepCopy(TypeInvariant typeInvariant)
 {
     typeInvariant.Condition = this.Substitute(typeInvariant.Condition);
       if (typeInvariant.Description != null)
     typeInvariant.Description = this.Substitute(typeInvariant.Description);
       return typeInvariant;
 }
示例#3
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;
 }
示例#4
0
 /// <summary>
 /// Rewrites the children of the given type invariant.
 /// </summary>
 public virtual void RewriteChildren(TypeInvariant typeInvariant)
 {
     this.RewriteChildren((ContractElement)typeInvariant);
 }
示例#5
0
 /// <summary>
 /// Visits the specified type invariant.
 /// </summary>
 /// <param name="typeInvariant">The type invariant.</param>
 public virtual ITypeInvariant Visit(TypeInvariant typeInvariant)
 {
     typeInvariant.Condition = this.Visit(typeInvariant.Condition);
       if (typeInvariant.Description != null)
     typeInvariant.Description = this.Visit(typeInvariant.Description);
       return typeInvariant;
 }
示例#6
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);
 }