Esempio n. 1
0
        /// <summary>
        /// Translates Dafny program to Boogie program
        /// </summary>
        /// <returns>Exit value</returns>
        public static void Translate(Dafny.Program dafnyProgram, string uniqueIdPrefix, out Bpl.Program boogieProgram) {

            Translator translator = new Translator(dafnyProgram.reporter);
            translator.InsertChecksums = true;
            translator.UniqueIdPrefix = uniqueIdPrefix;
            boogieProgram = translator.Translate(dafnyProgram);
        }
Esempio n. 2
0
        public PipelineOutcome VerifyProgram(Dafny.Program program, IList<string> fileNames, string programId, out PipelineStatistics stats, out List<ErrorInformation> errorList, out ErrorInformation errorInfo) {
            Microsoft.Boogie.Program boogieProgram;
            Translate(program, Thread.CurrentThread.Name, out boogieProgram);
            var po = BoogiePipeline(boogieProgram, fileNames, programId, out stats, out errorList);
            errorInfo = errorList.FirstOrDefault();

            return po;
        }
Esempio n. 3
0
        public static void PrintBoogieProgram(Dafny.Program program)
        {
          
            Bpl.Program boogieProgram;
            Translate(program, Thread.CurrentThread.Name, out boogieProgram);
            ExecutionEngine.PrintBplFile($"{program.Name}.bpl", boogieProgram, true, true, true);
            var prog = ExecutionEngine.ParseBoogieProgram(new List<string>() { $"{program.Name}.bpl" }, false);
            var p = new Pipeline();
            p.StartBoogie($"{program.Name}.bpl");
            PipelineStatistics t;
            List<ErrorInformation> err;
            p.BoogiePipeline(boogieProgram, new List<string>() { $"{program.Name}.bpl" }, "name", out t, out err);

        }
Esempio n. 4
0
 public static void Compile(Dafny.Program dafnyProgram, TextWriter outputWriter)
 {
     Microsoft.Dafny.DafnyOptions.O.SpillTargetCode = true;
       // Currently there are no provisions for specifying other files to compile with from the
       // VS interface, so just send an empty list.
       ReadOnlyCollection<string> otherFileNames = new List<string>().AsReadOnly();
       Microsoft.Dafny.DafnyDriver.CompileDafnyProgram(dafnyProgram, dafnyProgram.FullName, otherFileNames, outputWriter);
 }
Esempio n. 5
0
        public static bool Verify(Dafny.Program dafnyProgram, ResolverTagger resolver, string uniqueIdPrefix, string requestId, ErrorReporterDelegate er)
        {
            Dafny.Translator translator = new Dafny.Translator(dafnyProgram.reporter);
              var translatorFlags = new Dafny.Translator.TranslatorFlags() { InsertChecksums = true, UniqueIdPrefix = uniqueIdPrefix };

              var boogiePrograms = Dafny.Translator.Translate(dafnyProgram, dafnyProgram.reporter, translatorFlags);

              var impls = boogiePrograms.SelectMany(p => p.Item2.Implementations);
              resolver.ReInitializeVerificationErrors(requestId, impls);

              bool success = false;

              foreach (var kv in boogiePrograms) {
            var boogieProgram = kv.Item2;

            // TODO(wuestholz): Maybe we should use a fixed program ID to limit the memory overhead due to the program cache in Boogie.
            PipelineOutcome oc = BoogiePipeline(boogieProgram, 1 < Dafny.DafnyOptions.Clo.VerifySnapshots ? uniqueIdPrefix : null, requestId, er);
            switch (oc) {
              case PipelineOutcome.Done:
              case PipelineOutcome.VerificationCompleted:
            // TODO:  This would be the place to proceed to compile the program, if desired
            success = true;
            break;
              case PipelineOutcome.FatalError:
              default:
            return false;
            }
              }
              return success;
        }
Esempio n. 6
0
    public static bool Verify(Dafny.Program dafnyProgram, ResolverTagger resolver, string uniqueIdPrefix, string requestId, ErrorReporterDelegate er) {
      Dafny.Translator translator = new Dafny.Translator();
      translator.InsertChecksums = true;
      translator.UniqueIdPrefix = uniqueIdPrefix;
      Bpl.Program boogieProgram = translator.Translate(dafnyProgram);

      resolver.ReInitializeVerificationErrors(requestId, boogieProgram.Implementations);

      // TODO(wuestholz): Maybe we should use a fixed program ID to limit the memory overhead due to the program cache in Boogie.
      PipelineOutcome oc = BoogiePipeline(boogieProgram, 1 < Dafny.DafnyOptions.Clo.VerifySnapshots ? uniqueIdPrefix : null, requestId, er);
      switch (oc) {
        case PipelineOutcome.Done:
        case PipelineOutcome.VerificationCompleted:
          // TODO:  This would be the place to proceed to compile the program, if desired
          return true;
        case PipelineOutcome.FatalError:
        default:
          return false;
      }
    }
Esempio n. 7
0
 public static void Compile(Dafny.Program dafnyProgram, TextWriter outputWriter)
 {
   Microsoft.Dafny.DafnyOptions.O.SpillTargetCode = true;
   Microsoft.Dafny.DafnyDriver.CompileDafnyProgram(dafnyProgram, dafnyProgram.FullName, outputWriter);
 }
Esempio n. 8
0
      public VSResolver(Dafny.Program program, DafnyDriver dd)
        : base(program) {
        this.dd = dd;

        AdditionalInformationReporter =
          (addinfo)
            =>
            {
              if (!_additionalInformation.ContainsKey(addinfo.Token)) {
                _additionalInformation.Add(addinfo.Token, new HashSet<AdditionalInformation>());
              }
              _additionalInformation[addinfo.Token].Add(addinfo);
            };
      }