public override void Visit(ITypeOf typeOf)
 {
     if (Process(typeOf))
     {
         visitor.Visit(typeOf);
     }
     base.Visit(typeOf);
 }
示例#2
0
 private static string GetExceptionId(IPrecondition precondition)
 {
     Contract.Requires(precondition != null);
     if (precondition.ExceptionToThrow != null)
     {
         ITypeOf        asTypeOf = precondition.ExceptionToThrow as ITypeOf;
         ITypeReference unspecializedExceptionType;
         if (asTypeOf != null)
         {
             unspecializedExceptionType = MethodHelper.Unspecialize(asTypeOf.TypeToGet);
         }
         else//Legacy contracts package exceptions differently then regular contracts.
         {
             unspecializedExceptionType = MethodHelper.Unspecialize(precondition.ExceptionToThrow.Type);
         }
         return(TypeHelper.GetTypeName(unspecializedExceptionType, NameFormattingOptions.DocumentationId));
     }
     return(null);
 }
示例#3
0
 public void Visit(ITypeOf typeOf)
 {
     throw new NotImplementedException();
 }
示例#4
0
 /// <summary>
 /// Generates IL for the specified type of.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 public override void TraverseChildren(ITypeOf typeOf)
 {
     this.generator.Emit(OperationCode.Ldtoken, typeOf.TypeToGet);
       this.generator.Emit(OperationCode.Call, this.GetTypeFromHandle);
       this.StackSize++;
 }
示例#5
0
 /// <summary>
 /// Traverses the children of the typeof() expression.
 /// </summary>
 public virtual void TraverseChildren(ITypeOf typeOf)
 {
     Contract.Requires(typeOf != null);
       this.TraverseChildren((IExpression)typeOf);
       if (this.StopTraversal) return;
       this.Traverse(typeOf.TypeToGet);
 }
示例#6
0
 /// <summary>
 /// Performs some computation with the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public virtual void Visit(ITypeOf typeOf)
 {
     this.Visit((IExpression)typeOf);
 }
        public override void TraverseChildren(ITypeOf typeOf)
{ MethodEnter(typeOf);
            base.TraverseChildren(typeOf);
     MethodExit();   }
示例#8
0
 /// <summary>
 /// Performs some computation with the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public virtual void Visit(ITypeOf typeOf)
 {
 }
示例#9
0
 /// <summary>
 /// Returns a shallow copy of the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public TypeOf Copy(ITypeOf typeOf)
 {
     return new TypeOf(typeOf);
 }
 public override void TraverseChildren(ITypeOf typeOf) {
   var e = this.sink.FindOrCreateTypeReferenceInCodeContext(typeOf.TypeToGet);
   TranslatedExpressions.Push(e);
 }
 public override void Visit(ITypeOf typeOf)
 {
     if(Process(typeOf)){visitor.Visit(typeOf);}
     base.Visit(typeOf);
 }
 public virtual void onASTElement(ITypeOf typeOf) { }
示例#13
0
 private HLLocation ProcessTypeOfExpression(ITypeOf pExpression)
 {
     return(HLTypeOfLocation.Create(HLDomain.GetOrCreateType(pExpression.TypeToGet)));
 }
示例#14
0
 private HLLocation ProcessTypeOfExpression(ITypeOf pExpression)
 {
     return HLTypeOfLocation.Create(HLDomain.GetOrCreateType(pExpression.TypeToGet));
 }
示例#15
0
 public void Visit(ITypeOf typeOf)
 {
     this.result = this.rewriter.Rewrite(typeOf);
 }
示例#16
0
 /// <summary>
 /// Rewrites the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public virtual IExpression Rewrite(ITypeOf typeOf)
 {
     var mutableTypeOf = typeOf as TypeOf;
       if (mutableTypeOf == null) return typeOf;
       this.RewriteChildren(mutableTypeOf);
       return mutableTypeOf;
 }
示例#17
0
 /// <summary>
 /// Visits the specified type of.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 public override void Visit(ITypeOf typeOf)
 {
     TypeOf mutableTypeOf = typeOf as TypeOf;
     if (alwaysMakeACopy || mutableTypeOf == null) mutableTypeOf = new TypeOf(typeOf);
     this.resultExpression = this.myCodeMutator.Visit(mutableTypeOf);
 }
示例#18
0
 /// <summary>
 /// Visits the specified type of.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 public override void Visit(ITypeOf typeOf)
 {
     TypeOf mutableTypeOf = typeOf as TypeOf;
     if (mutableTypeOf == null) {
       this.resultExpression = typeOf;
       return;
     }
     this.resultExpression = this.myCodeMutator.Visit(mutableTypeOf);
 }
示例#19
0
 public override void TraverseChildren(ITypeOf typeOf)
 {
     base.TraverseChildren(typeOf);
     ((TypeOf)typeOf).Type = this.platformType.SystemType;
 }
示例#20
0
 public void Visit(ITypeOf typeOf)
 {
     this.result = this.copier.Copy(typeOf);
 }
示例#21
0
 public override void Visit(ITypeOf typeOf)
 {
     allElements.Add(new InvokInfo(Traverser, "ITypeOf", typeOf));
 }
示例#22
0
 public virtual void onASTElement(ITypeOf typeOf)
 {
 }
 /// <summary>
 /// Rewrites the given typeof(); expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public virtual IExpression Rewrite(ITypeOf typeOf)
 {
     return typeOf;
 }
示例#24
0
 //^ ensures this.path.Count == old(this.path.Count);
 /// <summary>
 /// Traverses the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public virtual void Visit(ITypeOf typeOf)
 {
     if (this.stopTraversal) return;
       //^ int oldCount = this.path.Count;
       this.path.Push(typeOf);
       this.Visit(typeOf.TypeToGet);
       //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count.
       this.path.Pop();
 }
示例#25
0
 public override void TraverseChildren(ITypeOf typeOf) {
   base.TraverseChildren(typeOf);
   ((TypeOf)typeOf).Type = this.platformType.SystemType;
 }
示例#26
0
 /// <summary>
 /// Traverses the typeof() expression.
 /// </summary>
 public void Traverse(ITypeOf typeOf)
 {
     Contract.Requires(typeOf != null);
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(typeOf);
       if (this.StopTraversal) return;
       this.TraverseChildren(typeOf);
       if (this.StopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(typeOf);
 }
示例#27
0
    /// <summary>
    /// Returns a shallow copy of the given typeof() expression.
    /// </summary>
    /// <param name="typeOf"></param>
    public TypeOf Copy(ITypeOf typeOf) {
      Contract.Requires(typeOf != null);
      Contract.Ensures(Contract.Result<TypeOf>() != null);

      return new TypeOf(typeOf);
    }
示例#28
0
 public void Visit(ITypeOf typeOf)
 {
     this.traverser.Traverse(typeOf);
 }
示例#29
0
    /// <summary>
    /// Returns a deep copy of the given typeof() expression.
    /// </summary>
    /// <param name="typeOf"></param>
    public TypeOf Copy(ITypeOf typeOf) {
      Contract.Requires(typeOf != null);
      Contract.Ensures(Contract.Result<TypeOf>() != null);

      var mutableCopy = this.shallowCopier.Copy(typeOf);
      this.CopyChildren((Expression)mutableCopy);
      mutableCopy.TypeToGet = this.Copy(mutableCopy.TypeToGet);
      return mutableCopy;
    }
示例#30
0
 public void Visit(ITypeOf typeOf)
 {
     Contract.Requires(typeOf != null);
       throw new NotImplementedException();
 }
 /// <summary>
 /// Performs some computation with the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public virtual void Visit(ITypeOf typeOf)
 {
 }
示例#32
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="typeOf"></param>
 public TypeOf(ITypeOf typeOf)
     : base(typeOf)
 {
     this.typeToGet = typeOf.TypeToGet;
 }
示例#33
0
 /// <summary>
 /// Visits the specified type of.
 /// </summary>
 /// <param name="typeOf">The type of.</param>
 public override void Visit(ITypeOf typeOf)
 {
     TypeOf mutableTypeOf = new TypeOf(typeOf);
     this.resultExpression = this.myCodeCopier.DeepCopy(mutableTypeOf);
 }
 public override void TraverseChildren(ITypeOf typeOf) {
   this.sourceEmitterOutput.Write("typeof(");
   this.PrintTypeReference(typeOf.TypeToGet);
   this.sourceEmitterOutput.Write(")");
 }
示例#35
0
 /// <summary>
 /// Returns a deep copy of the given typeof() expression.
 /// </summary>
 /// <param name="typeOf"></param>
 public TypeOf Copy(ITypeOf typeOf)
 {
     var mutableCopy = this.shallowCopier.Copy(typeOf);
       this.CopyChildren((Expression)mutableCopy);
       mutableCopy.TypeToGet = this.Copy(mutableCopy.TypeToGet);
       return mutableCopy;
 }
示例#36
0
 public override void TraverseChildren(ITypeOf typeOf)
 {
     MethodEnter(typeOf);
     base.TraverseChildren(typeOf);
     MethodExit();
 }
示例#37
0
        /// <summary>
        /// Listen to all the IMethodDefinitions
        /// </summary>
        /// <param name="methodDefinition"></param>
        public override void Visit(IMethodDefinition methodDefinition)
        {
            if (methodDefinition == null)
            {
                return;
            }

            if (IsGetter(methodDefinition) || IsSetter(methodDefinition))
            {
                return;
            }

            string methodName = MemberHelper.GetMethodSignature(methodDefinition, NameFormattingOptions.DocID);

            Console.WriteLine(methodName);

            IMethodContract methodContract = this.contractProvider.GetMethodContractFor(methodDefinition);

            //IMethodContract inheritedContract = ContractHelper.InheritMethodContracts(this.host, this.contractProvider, methodDefinition);
            if (methodContract != null)
            {
                XElement member = GetMemberElement(membersElement, methodDefinition);

                //Add contract exceptions
                WriteExceptions(member, methodContract);

                //Add a new element for each contract
                if (options.toSummary == false)
                {
                    foreach (IPrecondition contractElement in methodContract.Preconditions)
                    {
                        Contract.Assume(contractElement != null, "lack of contracts for collections");
                        XAttribute exceptionAttribute = null;
                        if (contractElement.ExceptionToThrow != null)
                        {
                            ITypeOf asTypeOf = contractElement.ExceptionToThrow as ITypeOf;
                            if (asTypeOf != null)
                            {
                                exceptionAttribute = GetTypeAttribute("exception", asTypeOf.TypeToGet);
                            }
                        }
                        WriteContractElement(member, contractElement, "requires", GetDescriptionAttribute(contractElement), exceptionAttribute);
                    }
                    foreach (IPostcondition contractElement in methodContract.Postconditions)
                    {
                        Contract.Assume(contractElement != null, "lack of contracts for collections");
                        WriteContractElement(member, contractElement, "ensures", GetDescriptionAttribute(contractElement));
                    }
                    foreach (IThrownException thrownException in methodContract.ThrownExceptions)
                    {
                        Contract.Assume(thrownException != null, "lack of contracts for collections");
                        Contract.Assume(thrownException.Postcondition != null, "lack of CCI2 contracts");
                        WriteContractElement(member, thrownException.Postcondition, "ensuresOnThrow", GetDescriptionAttribute(thrownException.Postcondition), GetTypeAttribute("exception", thrownException.ExceptionType));
                    }
                }
                //Add contract information into the summary element
                else
                {
                    XElement summaryElement = GetSummaryElement(member);

                    summaryElement.Add(new XElement("para", "Requires: "));
                    foreach (IContractElement contractElement in methodContract.Preconditions)
                    {
                        Contract.Assume(contractElement != null, "lack of contracts for collections");
                        WriteContractElementToSummary(summaryElement, contractElement);
                    }

                    summaryElement.Add(new XElement("para", "Ensures: "));
                    foreach (IContractElement contractElement in methodContract.Postconditions)
                    {
                        Contract.Assume(contractElement != null, "lack of contracts for collections");
                        WriteContractElementToSummary(summaryElement, contractElement);
                    }

                    summaryElement.Add(new XElement("para", "EnsuresOnThrow: "));
                    foreach (ThrownException thrownException in methodContract.ThrownExceptions)
                    {
                        Contract.Assume(thrownException != null, "lack of contracts for collections");
                        Contract.Assume(thrownException.Postcondition != null, "lack of contracts for CCI2");
                        Contract.Assume(thrownException.ExceptionType != null, "lack of contracts for CCI2");
                        WriteContractElementToSummary(summaryElement, thrownException.Postcondition, thrownException.ExceptionType.ToString());
                    }

                    WriteContractElementsToReleventParameters(member, methodDefinition, methodContract);
                }
            }

            base.Visit(methodDefinition);
        }