public static new void Main(string[] args) { try { Util.DebugWriteLine("hello"); DafnyCC_Options options = new DafnyCC_Options(); DafnyOptions.Install(options); DafnyOptions.O.AllowGlobals = true; DafnyOptions.O.Dafnycc = true; 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."); } if (options.useFramePointer && options.x64) { throw new Exception("64-bit frame pointer not yet implemented"); } new DafnyCC().CompileCode(options, files); } catch (Exception e) { Console.OpenStandardOutput().Flush(); Console.WriteLine(e); Console.Error.WriteLine(e); Environment.Exit(-1); } }
public void CompileCodeEnd(DafnyCC_Options options) { checkedIWriter.WriteLine("}"); checkedWriter.WriteLine("}"); checkedIWriter.Close(); checkedWriter.Close(); heapIWriter.WriteLine("}"); heapWriter.WriteLine("}"); seqIWriter.WriteLine("}"); seqWriter.WriteLine("}"); seqIWriter.Close(); seqWriter.Close(); if (outDir == null) { mainWriter.WriteLine("}"); } heapWriter.Close(); heapIWriter.Close(); CompileSpecEnd(); }
public void CompileCode(DafnyCC_Options options, IList<string> files) { Dictionary<string,string> allModules = CompileCodeStart(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); CompileDatatypes(); CompileCodeEnd(options); }
public Dictionary<string,string> CompileCodeStart(DafnyCC_Options options, IList<string> files) { IEnumerable<string> axioms = new string[] { "Base_axioms", "Word_axioms", "Memory_axioms", "Assembly_axioms", "Io_axioms" }; Dictionary<string,string> allModules = CompileSpecStart(options, files); relational = options.relational; x64 = options.x64; IPSize = x64 ? 8 : 4; useFramePointer = options.useFramePointer; framePointerCount = useFramePointer ? 1 : 0; heapWriter = new StreamWriter(Path.Combine(outDir, "Heap"+ImpBasmExtn)); heapIWriter = new StreamWriter(Path.Combine(outDir, "Heap"+IfcBasmExtn)); checkedWriter = new StreamWriter(Path.Combine(outDir, "Checked"+ImpBasmExtn)); checkedIWriter = new StreamWriter(Path.Combine(outDir, "Checked"+IfcBasmExtn)); List<string> checkedImports = new List<string> { "Trusted" }; checkedIWriter.WriteLine("module interface Checked"); WriteInterfaceImports(checkedIWriter, GatherAllImports(checkedImports)); checkedIWriter.WriteLine("{"); checkedIWriter.WriteLine("type ArrayOfInt = ArrayOfInt(arrCount:int, arrAbs:int);"); WriteImplementationHeader(checkedWriter, "Checked", new List<string>() { "Trusted" }); List<string> heapImports = new List<string> { "Trusted", "Checked" }; heapIWriter.WriteLine("module interface Heap"); WriteInterfaceImports(heapIWriter, GatherAllImports(heapImports)); addAxioms(heapWriter, axioms); heapIWriter.WriteLine("{"); WriteImplementationHeader(heapWriter, "Heap", heapImports); List<string> seqImports = new List<string> { "Trusted", "Checked", "Heap" }; seqWriter = new StreamWriter(Path.Combine(outDir, "Seq"+ImpBasmExtn)); seqIWriter = new StreamWriter(Path.Combine(outDir, "Seq"+IfcBasmExtn)); seqIWriter.WriteLine("module interface Seq"); WriteInterfaceImports(seqIWriter, GatherAllImports(seqImports)); seqIWriter.WriteLine("{"); addAxioms(seqWriter, axioms); WriteImplementationHeader(seqWriter, "Seq", seqImports); return allModules; }