Пример #1
0
        public string ResolveProgram()
        {
            string err = null;

            if (tacnyProgram.Tactics.Count > 0)
            {
                foreach (var member in tacnyProgram.Members)
                {
                    err = ScanMemberBody(member.Value);
                    solution_list.Fin();

                    if (err != null)
                    {
                        return(err);
                    }
                }

                if (solution_list != null)
                {
                    VerifySolutionList();
                    return(null);
                }
            }
            tacnyProgram.ResolveProgram();
            tacnyProgram.VerifyProgram();
            return(err);
        }
Пример #2
0
        /// <summary>
        /// Processes the file
        /// </summary>
        /// <param name="fileNames"></param>
        /// <param name="programId"></param>
        /// <returns></returns>
        static ExitValue ProcessFiles(IList <string /*!*/> /*!*/ fileNames, string programId = null)
        {
            //Contract.Requires(Tacny.tcce.NonNullElements(fileNames));

            if (programId == null)
            {
                programId = fileNames[0];
            }

            var exitValue = ExitValue.Verified;

            if (CommandLineOptions.Clo.VerifySeparately && 1 < fileNames.Count)
            {
                foreach (string f in fileNames)
                {
                    Console.WriteLine();
                    Console.WriteLine($"-------------------- {f} --------------------");
                    var ev = ProcessFiles(new List <string> {
                        f
                    }, f);
                    if (exitValue != ev && ev != ExitValue.Verified)
                    {
                        exitValue = ev;
                    }
                }
                return(exitValue);
            }

            using (new XmlFileScope(CommandLineOptions.Clo.XmlSink, fileNames[fileNames.Count - 1])) {
                Program tacnyProgram;
                string  programName = fileNames.Count == 1 ? fileNames[0] : "the program";
                // install Util.Printer
                try {
                    Debug.WriteLine("Initializing Tacny Program");
                    tacnyProgram = new Program(fileNames, programId);
                    // Initialize the printer
                    Printer.Install(fileNames[0]);
                    tacnyProgram.MaybePrintProgram(tacnyProgram.DafnyProgram, programName + "_src");
                } catch (ArgumentException ex) {
                    exitValue = ExitValue.DafnyError;
                    _printer.ErrorWriteLine(Console.Out, ex.Message);
                    return(exitValue);
                }


                var program = tacnyProgram.ParseProgram();
                int qq      = tacnyProgram.ResolveProgram(program);
                var md      = Interpreter.FindAndApplyTactic(tacnyProgram.ParseProgram(), ((ClassDecl)program.DefaultModuleDef.TopLevelDecls[0]).Members[0], null);
                Printer.P.GetConsolePrinter().PrintMethod(md as Method, 0, false);


                if (!CommandLineOptions.Clo.NoResolve && !CommandLineOptions.Clo.NoTypecheck && DafnyOptions.O.DafnyVerify)
                {
                    Debug.WriteLine("Starting lazy tactic evaluation");
                    LazyTacny.Interpreter r = new LazyTacny.Interpreter(tacnyProgram);
                    var prog = r.ResolveProgram();
                    tacnyProgram.PrintProgram(prog);
                    Debug.WriteLine("Fnished lazy tactic evaluation");
                }
                tacnyProgram.PrintAllDebugData(TacnyOptions.O.PrintCsv);
            }
            return(exitValue);
        }