コード例 #1
0
ファイル: Analyzer.cs プロジェクト: Plankankul/SpecSharp
        protected override void LanguageSpecificAnalysis(Method method)
        {
            if (!this.CodeIsWellFormed)
            {
                return;
            }
            if (Cci.Analyzer.Debug)
            {
                ControlFlowGraph cfg = GetCFG(method);
                if (cfg != null)
                {
                    cfg.Display(Console.Out);
                }
            }
            if (method.Name.Name.StartsWith("Microsoft.Contracts"))
            {
                return;
            }
            // Weak Purity and Effects Analysis
            if (this.WeakPurityAnalysis && this.WeakPurityAnalyzer != null)
            {
                this.WeakPurityAnalyzer.VisitMethod(method); // computes points-to and effects
                // processes results from VisitMethod: issues errors and potentially prints out detailed info.
                this.WeakPurityAnalyzer.ProcessResultsMethod(method);

                // Admissibility Check
                PointsToAndWriteEffects ptwe = this.WeakPurityAnalyzer.GetPurityAnalysisWithDefault(method);
                if (method.IsConfined || method.IsStateIndependent)
                {
                    Microsoft.SpecSharp.ReadEffectAdmissibilityChecker reac = new Microsoft.SpecSharp.ReadEffectAdmissibilityChecker(method, typeSystem.ErrorHandler);
                    reac.CheckReadEffectAdmissibility(ptwe.ComputeEffects(ptwe.ReadEffects));
                }
            }

            if (ReentrancyAnalysis)
            {
                if (this.ReentrancyAnalyzer != null)
                {
                    this.ReentrancyAnalyzer.VisitMethod(method);
                }
            }

            if (ObjectExposureAnalysis)
            {
                if (this.ObjectExposureAnalyzer != null)
                {
                    this.ObjectExposureAnalyzer.VisitMethod(method);
                }
            }
        }
コード例 #2
0
ファイル: Analyzer.cs プロジェクト: Plankankul/SpecSharp
        /// <summary>
        /// Put general analysis targeting to general IL properties.
        /// </summary>
        /// <param name="method"></param>
        protected void GeneralAnalysis(Method method)
        {
            nonNullInfo = null;

            if (!this.CodeIsWellFormed)
            {
                return;
            }

            if (debug)
            {
                ControlFlowGraph cfg = GetCFG(method);
                if (cfg != null)
                {
                    cfg.Display(Console.Out);
                }
            }

            if (!method.Name.Name.StartsWith("Microsoft.Contracts"))
            {
                // Definite assignment checking

                //System.Console.WriteLine("--------------- Analyzing Method: {0}", method.Name);


                if (this.DefiniteAssignmentChecking)
                {
                    // For every statement, three things are returned from this pre- stage analysis
                    // 1) which program vars (that represent NN arrays) are created but not committed
                    // 2) which program vars (that represent NN arrays) are created and committed between
                    //    the creation and commitment of current array.
                    // 3) if the statement is a commitment call for an NN array, whether it
                    //    is ok to lift the array to be non-delayed.
                    PreDAStatus preAnalysisResult = MethodReachingDefNNArrayChecker.Check(typeSystem, method, this);
                    if (preAnalysisResult != null)
                    {
                        delayInfo = MethodDefiniteAssignmentChecker.Check(typeSystem, method, this, preAnalysisResult);
                    }
                }
                if (Analyzer.Debug)
                {
                    if (delayInfo != null)
                    {
                        System.Console.WriteLine("----- delay info count: {0}", delayInfo.Count());
                    }
                }

                if (this.ExposureChecking)
                {
                    ExposureChecker.Check(typeSystem, method, this);
                }

                // NonNull checking
                if (this.NonNullChecking)
                {
                    nonNullInfo = NonNullChecker.Check(typeSystem, method, this);
                }

                //System.Console.WriteLine("---------------- Finished Analyzing Method:{0}", method.Name);
            }
        }