public static List <Bpl.ErrorInformation> ResolveAndVerify(Program program, Bpl.ErrorReporterDelegate er) { Contract.Requires <ArgumentNullException>(program != null); var r = new Resolver(program); //var start = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds; r.ResolveProgram(program); //var end = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds var boogieProg = Translate(program, program.Name, er); Bpl.PipelineStatistics stats; List <Bpl.ErrorInformation> errorList; Bpl.PipelineOutcome tmp = BoogiePipeline(boogieProg, new List <string> { program.Name }, program.Name, er, out stats, out errorList, program); return(errorList); }
/// <summary> /// Pipeline the boogie program to Dafny where it is valid /// </summary> /// <returns>Exit value</returns> public static Bpl.PipelineOutcome BoogiePipeline(Bpl.Program program, IList <string> fileNames, string programId, Bpl.ErrorReporterDelegate er, out Bpl.PipelineStatistics stats, out List <Bpl.ErrorInformation> errorList, Program tmpDafnyProgram = null) { Contract.Requires(program != null); Contract.Ensures(0 <= Contract.ValueAtReturn(out stats).InconclusiveCount&& 0 <= Contract.ValueAtReturn(out stats).TimeoutCount); Bpl.LinearTypeChecker ltc; Bpl.CivlTypeChecker ctc; string baseName = cce.NonNull(Path.GetFileName(fileNames[fileNames.Count - 1])); baseName = cce.NonNull(Path.ChangeExtension(baseName, "bpl")); string bplFileName = Path.Combine(Path.GetTempPath(), baseName); errorList = new List <Bpl.ErrorInformation>(); stats = new Bpl.PipelineStatistics(); Bpl.PipelineOutcome oc = Bpl.ExecutionEngine.ResolveAndTypecheck(program, bplFileName, out ltc, out ctc); switch (oc) { case Bpl.PipelineOutcome.ResolvedAndTypeChecked: Bpl.ExecutionEngine.EliminateDeadVariables(program); Bpl.ExecutionEngine.CollectModSets(program); Bpl.ExecutionEngine.CoalesceBlocks(program); Bpl.ExecutionEngine.Inline(program); errorList = new List <Bpl.ErrorInformation>(); var tmp = new List <Bpl.ErrorInformation>(); oc = Bpl.ExecutionEngine.InferAndVerify(program, stats, programId, errorInfo => { tmp.Add(errorInfo); er?.Invoke(new CompoundErrorInformation(errorInfo.Tok, errorInfo.Msg, errorInfo, tmpDafnyProgram)); }); errorList.AddRange(tmp); return(oc); default: Contract.Assert(false); throw new cce.UnreachableException(); // unexpected outcome } }
public static Bpl.Program Translate(Program dafnyProgram, string uniqueIdPrefix, Bpl.ErrorReporterDelegate er) { Contract.Requires <ArgumentNullException>(dafnyProgram != null, "dafnyProgram"); Contract.Requires <ArgumentNullException>(uniqueIdPrefix != null, "uniqueIdPrefix"); Contract.Ensures(Contract.Result <Bpl.Program>() != null); var translator = new Translator(dafnyProgram.reporter, er) { InsertChecksums = true, UniqueIdPrefix = uniqueIdPrefix }; return(translator.Translate(dafnyProgram)); }