Esempio n. 1
0
 public static void Main(string[] args)
 {
     try
     {
         Util.DebugWriteLine("hello");
         DafnySpec_Options options = new DafnySpec_Options();
         DafnyOptions.Install(options);
         Bpl.CommandLineOptions.Clo.RunningBoogieFromCommandLine = true;
         if (!Bpl.CommandLineOptions.Clo.Parse(args))
         {
             throw new Exception("argument parse error");
         }
         IList <string> files = Bpl.CommandLineOptions.Clo.Files;
         if (files.Count == 0)
         {
             throw new Exception("*** Error: No input files were specified.");
         }
         new DafnySpec().CompileSpec(options, files);
     }
     catch (Exception e)
     {
         Console.OpenStandardOutput().Flush();
         Console.WriteLine(e);
         Console.Error.WriteLine(e);
         Environment.Exit(-1);
     }
 }
Esempio n. 2
0
    public Dictionary <string, string> CompileSpecStart(DafnySpec_Options options, IList <string> files)
    {
        minVerify     = options.minVerify;
        outDir        = options.outDir;
        outListWriter = new StreamWriter(Path.Combine(outDir, "dafny_modules.txt"));

        trustedWriter  = new StreamWriter(Path.Combine(outDir, "Trusted" + ImpBasmExtn));
        trustedIWriter = new StreamWriter(Path.Combine(outDir, "Trusted" + IfcBasmExtn));
        WriteInterfaceImports(trustedIWriter, GatherAllImports(new List <string>()));
        trustedIWriter.WriteLine("module interface Trusted");
        trustedIWriter.WriteLine("{");
        trustedIWriter.WriteLine(baseDecls);
        WriteImplementationHeader(trustedWriter, "Trusted", new List <string>());

        Dictionary <string, string> allModules = new Dictionary <string, string>(StringComparer.CurrentCultureIgnoreCase);

        foreach (string file in files)
        {
            string filename   = new FileInfo(file).FullName;
            string moduleName = ModuleNameFromFilename(filename);
            if (!allModules.ContainsKey(moduleName))
            {
                AddImports(allModules, filename);
                allModules.Add(moduleName, filename);
            }
        }
        return(allModules);
    }
Esempio n. 3
0
    public void CompileSpec(DafnySpec_Options options, IList <string> files)
    {
        Dictionary <string, string> allModules = CompileSpecStart(options, files);

        Program program;
        string  errors = Microsoft.Dafny.Main.ParseCheck(
            allModules.Values.ToList(),
            "DAFNYCC_PROGRAM",
            out program);

        if (errors != null)
        {
            throw new Exception(errors);
        }
        Util.DebugWriteLine(program);
        DeclareProgram(program);
        CompileProgram(program);
        CompileDatatypesGhost();
        CompileSequenceSpecs();
        files.ToList().ForEach(f => ChooseOutDirWriter(f)); //- make sure even empty modules get written

        CompileSpecEnd();
    }
Esempio n. 4
0
    public void CompileSpec(DafnySpec_Options options, IList<string> files)
    {
        Dictionary<string,string> allModules = CompileSpecStart(options, files);

        Program program;
        string errors = Microsoft.Dafny.Main.ParseCheck(
            allModules.Values.ToList(),
            "DAFNYCC_PROGRAM",
            out program);
        if (errors != null)
        {
            throw new Exception(errors);
        }
        Util.DebugWriteLine(program);
        DeclareProgram(program);
        CompileProgram(program);
        CompileDatatypesGhost();
        CompileSequenceSpecs();
        files.ToList().ForEach(f => ChooseOutDirWriter(f)); //- make sure even empty modules get written

        CompileSpecEnd();
    }
Esempio n. 5
0
 public static void Main(string[] args)
 {
     try
     {
         Util.DebugWriteLine("hello");
         DafnySpec_Options options = new DafnySpec_Options();
         DafnyOptions.Install(options);
         Bpl.CommandLineOptions.Clo.RunningBoogieFromCommandLine = true;
         if (!Bpl.CommandLineOptions.Clo.Parse(args))
         {
             throw new Exception("argument parse error");
         }
         IList<string> files = Bpl.CommandLineOptions.Clo.Files;
         if (files.Count == 0)
         {
             throw new Exception("*** Error: No input files were specified.");
         }
         new DafnySpec().CompileSpec(options, files);
     }
     catch (Exception e)
     {
         Console.OpenStandardOutput().Flush();
         Console.WriteLine(e);
         Console.Error.WriteLine(e);
         Environment.Exit(-1);
     }
 }
Esempio n. 6
0
    public Dictionary<string,string> CompileSpecStart(DafnySpec_Options options, IList<string> files)
    {
        minVerify = options.minVerify;
        outDir = options.outDir;
        outListWriter = new StreamWriter(Path.Combine(outDir, "dafny_modules.txt"));

        trustedWriter = new StreamWriter(Path.Combine(outDir, "Trusted"+ImpBasmExtn));
        trustedIWriter = new StreamWriter(Path.Combine(outDir, "Trusted"+IfcBasmExtn));
        WriteInterfaceImports(trustedIWriter, GatherAllImports(new List<string>()));
        trustedIWriter.WriteLine("module interface Trusted");
        trustedIWriter.WriteLine("{");
        trustedIWriter.WriteLine(baseDecls);
        WriteImplementationHeader(trustedWriter, "Trusted", new List<string>());

        Dictionary<string, string> allModules = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
        foreach (string file in files)
        {
            string filename = new FileInfo(file).FullName;
            string moduleName = ModuleNameFromFilename(filename);
            if (!allModules.ContainsKey(moduleName))
            {
                AddImports(allModules, filename);
                allModules.Add(moduleName, filename);
            }
        }
        return allModules;
    }