static int Main(string[] args) { int errorReturnValue = -1; #region Parse options and check for errors var options = new Options(); options.Parse(args); if (options.HelpRequested) { options.PrintOptions(""); return(errorReturnValue); } if (options.HasErrors) { options.PrintErrorsAndExit(Console.Out); } if (!String.IsNullOrWhiteSpace(options.exemptionFile)) { string fileName = options.exemptionFile; var c = fileName[fileName.Length - 1]; if (c == '+' || c == '-') { fileName = options.exemptionFile.Remove(fileName.Length - 1); } if (!File.Exists(fileName)) { Console.WriteLine("Specified exemption file '{0}' not found.", fileName); } } if (options.stub != null) { Console.WriteLine("/s is no longer used to specify stub assemblies"); return(errorReturnValue); } if (options.modelExceptions == 1 && !options.wholeProgram) { Console.WriteLine("can specify a precise modeling of exceptions only when doing whole program analysis"); return(errorReturnValue); } if (options.breakIntoDebugger) { System.Diagnostics.Debugger.Launch(); } #endregion var assemblyNames = options.assemblies; if (assemblyNames == null || assemblyNames.Count == 0) { assemblyNames = new List <string>(); foreach (var g in options.GeneralArguments) { assemblyNames.Add(g); } } #region If an exclusion file has been specified, read in each line as a regular expression List <Regex> exemptionList = null; bool whiteList = false; if (!String.IsNullOrWhiteSpace(options.exemptionFile)) { int i = 0; exemptionList = new List <Regex>(); string fileName = options.exemptionFile; var c = fileName[fileName.Length - 1]; whiteList = true; if (c == '+' || c == '-') { fileName = options.exemptionFile.Remove(fileName.Length - 1); if (c == '-') { whiteList = false; } } try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader(fileName)) { String line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { exemptionList.Add(new Regex(line)); i++; } //Console.WriteLine("Read {0} lines from the exclusion file '{1}'.", // i, options.exemptionFile); } } catch (Exception e) { Console.WriteLine("Something went wrong reading the exclusion file '{0}'; read in {1} lines, continuing processing.", fileName, i); Console.WriteLine(e.Message); } } #endregion try { HeapFactory heap; switch (options.heapRepresentation) { case Options.HeapRepresentation.splitFields: heap = new SplitFieldsHeap(); break; case Options.HeapRepresentation.general: heap = new GeneralHeap(); break; default: Console.WriteLine("Unknown setting for /heap"); return(1); } var pgm = TranslateAssembly(assemblyNames, heap, options, exemptionList, whiteList); var fileName = assemblyNames[0]; fileName = Path.GetFileNameWithoutExtension(fileName); string outputFileName = fileName + ".bpl"; // Microsoft.Boogie.TokenTextWriter writer = new Microsoft.Boogie.TokenTextWriter("_" + outputFileName); Microsoft.Boogie.TokenTextWriter writer = new Microsoft.Boogie.TokenTextWriter(outputFileName); Prelude.Emit(writer); pgm.Emit(writer); writer.Close(); return(0); // return Inline(outputFileName); } catch (Exception e) { // swallow everything and just return an error code Console.WriteLine("The byte-code translator failed: {0}", e.Message); Console.WriteLine("Stack trace: {0}", e.StackTrace); return(-1); } }
static int Main(string[] args) { int errorReturnValue = -1; #region Parse options and check for errors var options = new Options(); options.Parse(args); if (options.HelpRequested) { options.PrintOptions(""); return errorReturnValue; } if (options.HasErrors) { options.PrintErrorsAndExit(Console.Out); } if (!String.IsNullOrWhiteSpace(options.exemptionFile)) { string fileName = options.exemptionFile; var c = fileName[fileName.Length - 1]; if (c == '+' || c == '-') fileName = options.exemptionFile.Remove(fileName.Length - 1); if (!File.Exists(fileName)) { Console.WriteLine("Specified exemption file '{0}' not found.", fileName); } } if (options.stub != null) { Console.WriteLine("/s is no longer used to specify stub assemblies"); return errorReturnValue; } if (options.modelExceptions == 1 && !options.wholeProgram) { Console.WriteLine("can specify a precise modeling of exceptions only when doing whole program analysis"); return errorReturnValue; } if (options.breakIntoDebugger) { System.Diagnostics.Debugger.Launch(); } #endregion var assemblyNames = options.assemblies; if (assemblyNames == null || assemblyNames.Count == 0) { assemblyNames = new List<string>(); foreach (var g in options.GeneralArguments) { assemblyNames.Add(g); } } #region If an exclusion file has been specified, read in each line as a regular expression List<Regex> exemptionList = null; bool whiteList = false; if (!String.IsNullOrWhiteSpace(options.exemptionFile)) { int i = 0; exemptionList = new List<Regex>(); string fileName = options.exemptionFile; var c = fileName[fileName.Length - 1]; whiteList = true; if (c == '+' || c == '-') { fileName = options.exemptionFile.Remove(fileName.Length - 1); if (c == '-') whiteList = false; } try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader(fileName)) { String line; // Read and display lines from the file until the end of // the file is reached. while ((line = sr.ReadLine()) != null) { exemptionList.Add(new Regex(line)); i++; } //Console.WriteLine("Read {0} lines from the exclusion file '{1}'.", // i, options.exemptionFile); } } catch (Exception e) { Console.WriteLine("Something went wrong reading the exclusion file '{0}'; read in {1} lines, continuing processing.", fileName, i); Console.WriteLine(e.Message); } } #endregion try { HeapFactory heap; switch (options.heapRepresentation) { case Options.HeapRepresentation.splitFields: heap = new SplitFieldsHeap(); break; case Options.HeapRepresentation.general: heap = new GeneralHeap(); break; default: Console.WriteLine("Unknown setting for /heap"); return 1; } if ((options.phoneFeedbackCode || options.phoneNavigationCode) && (options.phoneControls == null || options.phoneControls == "")) { Console.WriteLine("Options /phoneNavigationCode and /phoneFeedbackCode need /phoneControls option set."); return 1; } var pgm = TranslateAssembly(assemblyNames, heap, options, exemptionList, whiteList); var fileName = assemblyNames[0]; fileName = Path.GetFileNameWithoutExtension(fileName); string outputFileName = fileName + ".bpl"; // Microsoft.Boogie.TokenTextWriter writer = new Microsoft.Boogie.TokenTextWriter("_" + outputFileName); Microsoft.Boogie.TokenTextWriter writer = new Microsoft.Boogie.TokenTextWriter(outputFileName); Prelude.Emit(writer); pgm.Emit(writer); writer.Close(); return 0; // return Inline(outputFileName); } catch (Exception e) { // swallow everything and just return an error code Console.WriteLine("The byte-code translator failed: {0}", e.Message); // Console.WriteLine("Stack trace: {0}", e.StackTrace); return -1; } }