public override Method VisitMethod(Method method)
        {
            if (method == null) return null;

            if (visitedMethods.ContainsKey(method))
                return method;

            base.VisitMethod(method);

            method.SetDelayedContract((m, dummy) =>
            {
                // cleanup contracts for clousot
                this.CleanupRequires(method);
                this.CleanupEnsures(method);
                // this.CleanupBody(method.Body);
            });

            return method;
        }
示例#2
0
        public override Method VisitMethod(Method method)
        {
            if (method == null) return null;

            Contract.Assume(method.Template == null);
            Contract.Assume(TypeNode.IsCompleteTemplate(method.DeclaringType));

            if (this.contractNodes.IsObjectInvariantMethod(method))
            {
                ExtractInvariantsFromMethod(method);
                return method;
            }

            if (!this.IncludeModels && HelperMethods.HasAttribute(method.Attributes, ContractNodes.ModelAttributeName))
                return null;

            // skip iterator movenext methods
            if (HelperMethods.IsCompilerGenerated(method.DeclaringType) &&
                method.Name != null && method.Name.Name == "MoveNext")
            {
                // generated MoveNext method, skip it.
                return method;
            }

            // Keep track of visited methods

            if (visitedMethods.ContainsKey(method))
                return method;

            visitedMethods.Add(method, method);

            var scrubber = this.currentScrubber;
            if (scrubber != null)
            {
                method.SetDelayedContract((m, dummy) =>
                {
                    scrubber.VisitMethod(m);
                    ExtractContractsForMethod(m, dummy);
                });
            }
            else
            {
                method.SetDelayedContract(ExtractContractsForMethod);
            }

            return method;
        }