Exemple #1
0
        public static void ProcessPFile(CommandLineArguments options, FSharpExpGen fsExpGen)
        {
            //Desugar the P Program
            var prog = fsExpGen.genFSExpression(options.pFile);

            if (options.desugar)
            {
                printPFile(options.deSugarFile, prog);
            }
            if (options.serialize)
            {
                Save(prog, "serialized_" + options.deSugarFile);
            }

            //Type check the program.
            Console.WriteLine("Type checking...");
            ProgramTyping.typecheckProgram(prog);

            //Remove named tuples in the P Program
            prog = RemoveNamedTuples.removeNamedTuplesProgram(prog);
            if (options.removeNT)
            {
                printPFile(options.removeNTFile, prog);
            }
            if (options.serialize)
            {
                Save(prog, "serialized_" + options.removeNTFile);
            }

            //Remove side effects in the P Program
            prog = RemoveSideEffects.removeSideEffectsProgram(prog);
            if (options.removeSE)
            {
                printPFile(options.removeSEFile, prog);
            }

            if (options.serialize)
            {
                Save(prog, "serialized_" + options.removeSEFile);
            }

            //Print the Boogie file.
            if (options.genBoogie)
            {
                using (var sw = new StreamWriter(options.boogieFile))
                    using (var tr = new IndentedTextWriter(sw, "    "))
                    {
                        Translator.translateProg(prog, tr);
                    }
            }
        }
        public void runTests()
        {
            int    numTests = 0;
            int    passed   = 0;
            int    failed   = 0;
            string file;

            using (var fileList = new StreamReader(listFile))
            {
                while ((file = fileList.ReadLine()) != null)
                {
                    try
                    {
                        var prog = fsExpGen.genFSExpression(file);
                        if (testDesugar)
                        {
                            bool b = CheckP(prog);
                            if (b)
                            {
                                ++passed;
                            }
                            else
                            {
                                ++failed;
                            }
                            ++numTests;
                        }

                        ProgramTyping.typecheckProgram(prog);

                        prog = RemoveNamedTuples.removeNamedTuplesProgram(prog);
                        if (testRemoveNT)
                        {
                            bool b = CheckP(prog);
                            if (b)
                            {
                                ++passed;
                            }
                            else
                            {
                                ++failed;
                            }
                            ++numTests;
                        }

                        prog = RemoveSideEffects.removeSideEffectsProgram(prog);
                        if (testRemoveSE)
                        {
                            bool b = CheckP(prog);
                            if (b)
                            {
                                ++passed;
                            }
                            else
                            {
                                ++failed;
                            }
                            ++numTests;
                        }
                        if (testBoogie)
                        {
                            bool b = CheckBoogie(file, prog);
                            if (b)
                            {
                                ++passed;
                            }
                            else
                            {
                                ++failed;
                            }
                            ++numTests;
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        ++failed;
                    }
                }
            }
        }