Exemple #1
0
        public BasicMethodDriver(Method method, IBasicAnalysisDriver parent)
        {
            this.method = method;
            this.parent = parent;

            RawLayer = CodeLayerFactory.Create(
                this.parent.SubroutineFacade.GetControlFlowGraph(method).GetDecoder(parent.MetaDataProvider),
                parent.MetaDataProvider,
                parent.ContractProvider, dummy => "", dummy => "");

            if (DebugOptions.Debug)
            {
                Console.WriteLine("-----APC based CFG-----");
                RawLayer.ILDecoder.ContextProvider.MethodContext.CFG.Print(Console.Out, RawLayer.Printer, null, null);
            }

            StackLayer = CodeLayerFactory.Create(
                StackDepthFactory.Create(RawLayer.ILDecoder, RawLayer.MetaDataProvider),
                RawLayer.MetaDataProvider,
                RawLayer.ContractProvider, (i => "s" + i.ToString()), i => "s" + i.ToString()
                );

            if (DebugOptions.Debug)
            {
                Console.WriteLine("-----Stack based CFG-----");
                StackLayer.ILDecoder.ContextProvider.MethodContext.CFG.Print(Console.Out, StackLayer.Printer, null, null);
            }
        }
        private ICFG contractFreeCFG; // computed on demand

        protected BasicMethodDriver(
            Method method,
            IBasicAnalysisDriver <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, LogOptions> parent
            )
        {
            Contract.Requires(parent != null);

            this.method = method;
            this.parent = parent;
            var rawCFG = this.parent.MethodCache.GetCFG(method);

            // Here we build our stack of adapters.
            //
            //  StackDepth    (Temp decoder for APC)
            //  CFG           (Unit decoder for APC, including Assume)
            //  cciilprovider (Unit decoder for PC)
            //

            rawLayer = CodeLayerFactory.Create(
                rawCFG.GetDecoder(parent.MetaDataDecoder),
                parent.MetaDataDecoder,
                parent.ContractDecoder,
                (unit) => "",
                (unit) => "",
                (v1, v2) => false);

            if (PrintIL)
            {
                Console.WriteLine("-----------------APC based CFG---------------------");
                this.RawLayer.Decoder.AssumeNotNull().Context.MethodContext.CFG.Print(Console.Out, this.RawLayer.Printer, null, null, null);
            }

            stackLayer = CodeLayerFactory.Create(
                StackDepthFactory.Create(
                    this.RawLayer.Decoder,
                    this.RawLayer.MetaDataDecoder),
                this.RawLayer.MetaDataDecoder,
                this.RawLayer.ContractDecoder,
                delegate(int i) { return("s" + i.ToString()); },
                delegate(int i) { return("s" + i.ToString()); },
                (s1, s2) => false
                );

            if (PrintIL)
            {
                Console.WriteLine("-----------------Stack based CFG---------------------");
                this.StackLayer.Decoder.AssumeNotNull().Context.MethodContext.CFG.Print(Console.Out, StackLayer.Printer, null, null, null);
            }

            // set static wp tracing option
            WeakestPreconditionProver.Trace           = parent.Options.TraceWP;
            WeakestPreconditionProver.EmitSMT2Formula = parent.Options.EmitSMT2Formula;
        }