示例#1
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Constructor.  Initialize a checker with the program and log file.
        /// Optionally, use prover context provided by parameter "ctx".
        /// </summary>
        public Checker(VC.ConditionGeneration vcgen, Program prog, string /*?*/ logFilePath, bool appendLogFile, int timeout, ProverContext ctx = null)
        {
            Contract.Requires(vcgen != null);
            Contract.Requires(prog != null);
            this.timeout = timeout;
            this.Program = prog;

            ProverOptions options = cce.NonNull(CommandLineOptions.Clo.TheProverFactory).BlankProverOptions();

            if (logFilePath != null)
            {
                options.LogFilename = logFilePath;
                if (appendLogFile)
                {
                    options.AppendLogFile = appendLogFile;
                }
            }

            if (timeout > 0)
            {
                options.TimeLimit = timeout * 1000;
            }

            options.Parse(CommandLineOptions.Clo.ProverOptions);

            ContextCacheKey key = new ContextCacheKey(prog);
            ProverInterface prover;

            if (vcgen.CheckerCommonState == null)
            {
                vcgen.CheckerCommonState = new Dictionary <ContextCacheKey, ProverContext>();
            }
            IDictionary <ContextCacheKey, ProverContext> /*!>!*/ cachedContexts = (IDictionary <ContextCacheKey, ProverContext /*!*/>)vcgen.CheckerCommonState;

            if (ctx == null && cachedContexts.TryGetValue(key, out ctx))
            {
                ctx    = (ProverContext)cce.NonNull(ctx).Clone();
                prover = (ProverInterface)
                         CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
            }
            else
            {
                if (ctx == null)
                {
                    ctx = (ProverContext)CommandLineOptions.Clo.TheProverFactory.NewProverContext(options);
                }

                Setup(prog, ctx);

                // we first generate the prover and then store a clone of the
                // context in the cache, so that the prover can setup stuff in
                // the context to be cached
                prover = (ProverInterface)
                         CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
                cachedContexts.Add(key, cce.NonNull((ProverContext)ctx.Clone()));
            }

            this.thmProver = prover;
            this.gen       = prover.VCExprGen;
        }
示例#2
0
 public override bool Equals(object that) {
   if (that is ContextCacheKey) {
     ContextCacheKey thatKey = (ContextCacheKey)that;
     return this.program.Equals(thatKey.program);
   }
   return false;
 }
示例#3
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Constructor.  Initialize a checker with the program and log file.
        /// Optionally, use prover context provided by parameter "ctx". 
        /// </summary>
        public Checker(VC.ConditionGeneration vcgen, Program prog, string/*?*/ logFilePath, bool appendLogFile, int timeout, ProverContext ctx = null)
        {
            Contract.Requires(vcgen != null);
              Contract.Requires(prog != null);
              this.timeout = timeout;
              this.Program = prog;

              ProverOptions options = cce.NonNull(CommandLineOptions.Clo.TheProverFactory).BlankProverOptions();

              if (logFilePath != null) {
            options.LogFilename = logFilePath;
            if (appendLogFile)
              options.AppendLogFile = appendLogFile;
              }

              if (timeout > 0) {
            options.TimeLimit = timeout * 1000;
              }

              options.Parse(CommandLineOptions.Clo.ProverOptions);

              ContextCacheKey key = new ContextCacheKey(prog);
              ProverInterface prover;

              if (vcgen.CheckerCommonState == null) {
            vcgen.CheckerCommonState = new Dictionary<ContextCacheKey, ProverContext>();
              }
              IDictionary<ContextCacheKey, ProverContext>/*!>!*/ cachedContexts = (IDictionary<ContextCacheKey, ProverContext/*!*/>)vcgen.CheckerCommonState;

              if (ctx == null && cachedContexts.TryGetValue(key, out ctx))
              {
            ctx = (ProverContext)cce.NonNull(ctx).Clone();
            prover = (ProverInterface)
              CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
              } else {
            if (ctx == null) ctx = (ProverContext)CommandLineOptions.Clo.TheProverFactory.NewProverContext(options);

            Setup(prog, ctx);

            // we first generate the prover and then store a clone of the
            // context in the cache, so that the prover can setup stuff in
            // the context to be cached
            prover = (ProverInterface)
              CommandLineOptions.Clo.TheProverFactory.SpawnProver(options, ctx);
            cachedContexts.Add(key, cce.NonNull((ProverContext)ctx.Clone()));
              }

              this.thmProver = prover;
              this.gen = prover.VCExprGen;
        }