Пример #1
0
    static void Initialize() {
      if (Dafny.DafnyOptions.O == null) {
        var options = new Dafny.DafnyOptions();
        options.ProverKillTime = 10;
        options.ErrorTrace = 0;
        options.VcsCores = Math.Max(1, System.Environment.ProcessorCount - 1);
        options.ModelViewFile = "-";
        Dafny.DafnyOptions.Install(options);

        // Read additional options from DafnyOptions.txt
        string codebase = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
        string optionsFilePath = Path.Combine(codebase, "DafnyOptions.txt");
        if (File.Exists(optionsFilePath)) {
          var optionsReader = new StreamReader(new FileStream(optionsFilePath, FileMode.Open, FileAccess.Read));
          List<string> args = new List<string>();
          while (true) {
            string line = optionsReader.ReadLine();
            if (line == null) break;
            line = line.Trim();
            if (line.Length == 0 || line.StartsWith("//")) continue;
            args.Add(line);
          }
          optionsReader.Close();
          CommandLineOptions.Clo.Parse(args.ToArray());
        } else {
          options.ApplyDefaultOptions();
        }

        ExecutionEngine.printer = new DummyPrinter();
        ExecutionEngine.errorInformationFactory = new DafnyErrorInformationFactory();
        ChangeIncrementalVerification(2);
      }
    }
Пример #2
0
        public static int ThreadMain(string[] args)
        {
            Contract.Requires(cce.NonNullElements(args));

            ErrorReporter reporter = new ConsoleErrorReporter();

            ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors

            DafnyOptions.Install(new DafnyOptions(reporter));

            CommandLineArgumentsResult cliArgumentsResult = ProcessCommandLineArguments(args, out var dafnyFiles, out var otherFiles);
            ExitValue exitValue;

            switch (cliArgumentsResult)
            {
            case CommandLineArgumentsResult.OK:
                exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter);
                break;

            case CommandLineArgumentsResult.PREPROCESSING_ERROR:
                exitValue = ExitValue.PREPROCESSING_ERROR;
                break;

            case CommandLineArgumentsResult.OK_EXIT_EARLY:
                exitValue = ExitValue.SUCCESS;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (CommandLineOptions.Clo.XmlSink != null)
            {
                CommandLineOptions.Clo.XmlSink.Close();
                if (DafnyOptions.O.VerificationLoggerConfig != null)
                {
                    BoogieXmlConvertor.RaiseTestLoggerEvents(DafnyOptions.O.BoogieXmlFilename, DafnyOptions.O.VerificationLoggerConfig);
                }
            }
            if (CommandLineOptions.Clo.Wait)
            {
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
            }
            if (!DafnyOptions.O.CountVerificationErrors)
            {
                return(0);
            }
            //Console.ReadKey();
            return((int)exitValue);
        }
Пример #3
0
        static void Initialize()
        {
            if (Dafny.DafnyOptions.O == null)
            {
                var options = new Dafny.DafnyOptions();
                options.ProverKillTime = 10;
                options.AutoTriggers   = true;
                options.ErrorTrace     = 0;
                options.VcsCores       = Math.Max(1, System.Environment.ProcessorCount - 1);
                options.ModelViewFile  = "-";
                options.UnicodeOutput  = true;
                Dafny.DafnyOptions.Install(options);

                // Read additional options from DafnyOptions.txt
                string codebase        = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                string optionsFilePath = Path.Combine(codebase, "DafnyOptions.txt");
                if (File.Exists(optionsFilePath))
                {
                    var           optionsReader = new StreamReader(new FileStream(optionsFilePath, FileMode.Open, FileAccess.Read));
                    List <string> args          = new List <string>();
                    while (true)
                    {
                        string line = optionsReader.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        line = line.Trim();
                        if (line.Length == 0 || line.StartsWith("//"))
                        {
                            continue;
                        }
                        args.Add(line);
                    }
                    optionsReader.Close();
                    CommandLineOptions.Clo.Parse(args.ToArray());
                }
                else
                {
                    options.ApplyDefaultOptions();
                }

                ExecutionEngine.printer = new DummyPrinter();
                ExecutionEngine.errorInformationFactory = new DafnyErrorInformationFactory();
                ChangeIncrementalVerification(2);
            }
        }
Пример #4
0
        public static int ThreadMain(string[] args)
        {
            Contract.Requires(cce.NonNullElements(args));

            ErrorReporter reporter = new ConsoleErrorReporter();

            ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors

            DafnyOptions.Install(new DafnyOptions(reporter));

            List <DafnyFile> dafnyFiles;
            List <string>    otherFiles;

            ExitValue exitValue = ProcessCommandLineArguments(args, out dafnyFiles, out otherFiles);

            if (exitValue == ExitValue.VERIFIED)
            {
                exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter);
            }

            if (CommandLineOptions.Clo.XmlSink != null)
            {
                CommandLineOptions.Clo.XmlSink.Close();
            }
            if (CommandLineOptions.Clo.Wait)
            {
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
            }
            if (!DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR)
            {
                return(0);
            }
            //Console.ReadKey();
            return((int)exitValue);
        }
Пример #5
0
 public static void Install(DafnyOptions options)
 {
     Contract.Requires(options != null);
     clo = options;
     Bpl.CommandLineOptions.Install(options);
 }
Пример #6
0
 public Printer(TextWriter wr, DafnyOptions.PrintModes printMode = DafnyOptions.PrintModes.Everything) {
   Contract.Requires(wr != null);
   this.wr = wr;
   this.printMode = printMode;
 }
Пример #7
0
 public static void Install(DafnyOptions options) {
   Contract.Requires(options != null);
   clo = options;
   Bpl.CommandLineOptions.Install(options);
 }
Пример #8
0
 public static void Install(DafnyOptions options)
 {
     Clo = options;
 }
Пример #9
0
        public static int ThreadMain(string[] args)
        {
            Contract.Requires(cce.NonNullElements(args));

            ErrorReporter reporter = new ConsoleErrorReporter();

            ExecutionEngine.printer = new DafnyConsolePrinter(); // For boogie errors

            DafnyOptions.Install(new DafnyOptions(reporter));

            ExitValue exitValue = ExitValue.VERIFIED;

            CommandLineOptions.Clo.RunningBoogieFromCommandLine = true;
            if (!CommandLineOptions.Clo.Parse(args))
            {
                exitValue = ExitValue.PREPROCESSING_ERROR;
                goto END;
            }
            //CommandLineOptions.Clo.Files = new List<string> { @"C:\dafny\Test\dafny0\Trait\TraitExtend.dfy" };

            if (CommandLineOptions.Clo.Files.Count == 0)
            {
                ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: No input files were specified.");
                exitValue = ExitValue.PREPROCESSING_ERROR;
                goto END;
            }
            if (CommandLineOptions.Clo.XmlSink != null)
            {
                string errMsg = CommandLineOptions.Clo.XmlSink.Open();
                if (errMsg != null)
                {
                    ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: " + errMsg);
                    exitValue = ExitValue.PREPROCESSING_ERROR;
                    goto END;
                }
            }
            if (!CommandLineOptions.Clo.DontShowLogo)
            {
                Console.WriteLine(CommandLineOptions.Clo.Version);
            }
            if (CommandLineOptions.Clo.ShowEnv == CommandLineOptions.ShowEnvironment.Always)
            {
                Console.WriteLine("---Command arguments");
                foreach (string arg in args)
                {
                    Contract.Assert(arg != null);
                    Console.WriteLine(arg);
                }
                Console.WriteLine("--------------------");
            }

            var dafnyFiles = new List <string>();
            var otherFiles = new List <string>();

            foreach (string file in CommandLineOptions.Clo.Files)
            {
                Contract.Assert(file != null);
                string extension = Path.GetExtension(file);
                if (extension != null)
                {
                    extension = extension.ToLower();
                }
                if (extension == ".dfy" || extension == ".tacny")
                {
                    dafnyFiles.Add(file);
                }
                else if ((extension == ".cs") || (extension == ".dll"))
                {
                    otherFiles.Add(file);
                }
                else
                {
                    ExecutionEngine.printer.ErrorWriteLine(Console.Out, "*** Error: '{0}': Filename extension '{1}' is not supported. Input files must be Dafny programs (.dfy) or C# files (.cs) or managed DLLS (.dll)", file,
                                                           extension == null ? "" : extension);
                    exitValue = ExitValue.PREPROCESSING_ERROR;
                    goto END;
                }
            }
            exitValue = ProcessFiles(dafnyFiles, otherFiles.AsReadOnly(), reporter);

END:
            if (CommandLineOptions.Clo.XmlSink != null)
            {
                CommandLineOptions.Clo.XmlSink.Close();
            }
            if (CommandLineOptions.Clo.Wait)
            {
                Console.WriteLine("Press Enter to exit.");
                Console.ReadLine();
            }
            if (!DafnyOptions.O.CountVerificationErrors && exitValue != ExitValue.PREPROCESSING_ERROR)
            {
                return(0);
            }
            //Console.ReadKey();
            return((int)exitValue);
        }
Пример #10
0
 public static void Install(DafnyOptions options)
 {
     Clo = options;
 }
Пример #11
0
 public static string ModuleDefinitionToString(ModuleDefinition m, DafnyOptions.PrintModes printMode = DafnyOptions.PrintModes.
     Everything)
 {
     Contract.Requires(m != null);
       using (var wr = new System.IO.StringWriter()) {
     var pr = new Printer(wr, printMode);
     pr.PrintModuleDefinition(m, m.VisibilityScope, 0, null);
     return ToStringWithoutNewline(wr);
       }
 }
Пример #12
0
 protected Printer(TextWriter tw, string filename, DafnyOptions.PrintModes printMode = DafnyOptions.PrintModes.Everything) : base(tw, printMode) {
     FileName = filename;
     wr = tw;
     this.printMode = printMode;
 }