Пример #1
0
        public RuleResult CheckMethod(MethodDefinition method)
        {
            if (method.Body == null)
            {
                return(RuleResult.DoesNotApply);
            }

            CFG cfg = new CFG(method);

            // requires -v -v
            if (Runner.VerbosityLevel > 0)
            {
                Trace.WriteLine(string.Empty);
                Trace.WriteLine("-------------------------------------");
                Trace.WriteLine(method.ToString());
                if (Runner.VerbosityLevel > 2)
                {
                    cfg.PrintDot();
                }
            }

            NonNullAttributeCollector nnaCollector = new NonNullAttributeCollector();
            NullDerefAnalysis         analysis     = new NullDerefAnalysis(method, nnaCollector, Runner);

            analysis.Verbose = Runner.VerbosityLevel > 1;

            Dataflow dataflow = new Dataflow(cfg, analysis);

            analysis.Verbose = Runner.VerbosityLevel > 1;
            dataflow.Compute();

            return(Runner.CurrentRuleResult);
        }
Пример #2
0
		public RuleResult CheckMethod (MethodDefinition method)
		{
			if (method.Body == null)
				return RuleResult.DoesNotApply;

			CFG cfg = new CFG (method);

			// requires -v -v
			if (Runner.VerbosityLevel > 0) {
				Trace.WriteLine(string.Empty);
				Trace.WriteLine("-------------------------------------");
				Trace.WriteLine(method.ToString());
				if (Runner.VerbosityLevel > 2)
					cfg.PrintDot ();
			}

			NonNullAttributeCollector nnaCollector = new NonNullAttributeCollector();
			NullDerefAnalysis analysis = new NullDerefAnalysis (method, nnaCollector, Runner);
			analysis.Verbose = Runner.VerbosityLevel > 1;

			Dataflow dataflow = new Dataflow (cfg, analysis);
			analysis.Verbose = Runner.VerbosityLevel > 1;
			dataflow.Compute ();

			return Runner.CurrentRuleResult;
		}
Пример #3
0
		public NullDerefAnalysis([NonNull] MethodDefinition method,
				[NonNull] NonNullAttributeCollector nnaCollector,
				[NonNull] IRunner runner)
		{
			this.stackDepth = method.Body.MaxStack;
			this.locals = method.Body.Variables.Count;
			if(method.HasThis)
				this.args = method.Parameters.Count + 1;
			else
				this.args = method.Parameters.Count;
			this.method = method;
			this.nnaCollector = nnaCollector;
			this.runner = runner;
		}
Пример #4
0
 public NullDerefAnalysis([NonNull] MethodDefinition method,
                          [NonNull] NonNullAttributeCollector nnaCollector,
                          [NonNull] IRunner runner)
 {
     this.stackDepth = method.Body.MaxStack;
     this.locals     = method.Body.Variables.Count;
     if (method.HasThis)
     {
         this.args = method.Parameters.Count + 1;
     }
     else
     {
         this.args = method.Parameters.Count;
     }
     this.method       = method;
     this.nnaCollector = nnaCollector;
     this.runner       = runner;
 }