public CompilerResults Compile() { var exitval = DafnyDriver.ProcessCommandLineArguments(CompilationArgs, out var dafnyFiles, out var otherFiles); if (!PerformPreliminaryChecks(exitval, out var errorneousCompileResults)) { return(errorneousCompileResults); } TextWriter tw = new StringWriter(); Type.ResetScopes(); int oldErrorCount = Dp.reporter.Count(ErrorLevel.Error); DafnyDriver.CompileDafnyProgram(Dp, Path, otherFiles.AsReadOnly(), true, tw); int newErrorCount = Dp.reporter.Count(ErrorLevel.Error); if (oldErrorCount != newErrorCount) { return(ExtractError(oldErrorCount)); } bool hasMain = new Microsoft.Dafny.CsharpCompiler(Dp.reporter).HasMain(Dp, out _); return(new CompilerResults { Error = false, Executable = hasMain, Message = tw.ToString().TrimEnd('\r', '\n') }); }
public Program getProgram(string filename) { Program dafnyProgram = null; List <DafnyFile> dafnyFiles; List <string> otherFiles; string[] args = new string[] { filename }; DafnyDriver.ProcessCommandLineArguments(args, out dafnyFiles, out otherFiles); ErrorReporter reporter = new ConsoleErrorReporter(); string s = Microsoft.Dafny.Main.ParseCheck(dafnyFiles, "", reporter, out dafnyProgram); return(dafnyProgram); }