//private const string KernelFile = CosmosRoot + @"\Users\Emile\TestBed\TestBed\bin\Debug\TestBed.dll"; //private const string OutputFile = CosmosRoot + @"\Users\Emile\TestBed\TestBed\bin\Debug\TestBedBoot.asm"; private static void Main(string[] args) { //Console.SetOut(new StreamWriter("out", false)); var xSW = Stopwatch.StartNew(); try { CosmosPaths.DebugStubSrc = Path.Combine(CosmosRoot, "source", "Cosmos.Debug.DebugStub"); var xTask = new CompilerEngine(); xTask.DebugEnabled = true; xTask.StackCorruptionDetectionEnabled = true; xTask.StackCorruptionDetectionLevel = "AllInstructions"; xTask.DebugMode = "Source"; xTask.TraceAssemblies = "All"; xTask.DebugCom = 1; xTask.UseNAsm = true; xTask.OutputFilename = OutputFile; xTask.EnableLogging = true; xTask.EmitDebugSymbols = true; xTask.IgnoreDebugStubAttribute = false; xTask.References = GetReferences(); xTask.OnLogError = (m) => Console.WriteLine("Error: {0}", m); xTask.OnLogWarning = (m) => Console.WriteLine("Warning: {0}", m); xTask.OnLogMessage = (m) => { Console.WriteLine("Message: {0}", m); }; xTask.OnLogException = (m) => Console.WriteLine("Exception: {0}", m.ToString()); if (xTask.Execute()) { Console.WriteLine("Executed OK"); } else { Console.WriteLine("Errorred"); } xSW.Stop(); } catch (Exception E) { Console.Out.Flush(); Console.WriteLine(E.ToString()); //Console.ReadLine(); return; } Console.WriteLine("Run took {0}", xSW.Elapsed); Console.WriteLine("Generated {0} Guids", DebugInfo.GeneratedIdsCount()); Console.Out.Flush(); Console.ReadKey(); }
public void Execute() { if (String.IsNullOrWhiteSpace(OutputFile)) { throw new InvalidOperationException("No OutputFile specified!"); } if (References.Count == 0) { throw new InvalidOperationException("No References specified!"); } DebugInfo.SetRange(DebugInfo.AssemblerDebugSymbolsRange); Console.WriteLine("Compiling to '{0}'", OutputFile); var xTask = new CompilerEngine(); xTask.DebugEnabled = false; xTask.StackCorruptionDetectionEnabled = false; xTask.StackCorruptionDetectionLevel = "MethodFooters"; xTask.DebugMode = "Source"; xTask.TraceAssemblies = "User"; xTask.DebugCom = 1; xTask.UseNAsm = true; xTask.OutputFilename = OutputFile; xTask.EnableLogging = true; xTask.EmitDebugSymbols = true; xTask.IgnoreDebugStubAttribute = false; xTask.References = GetReferences(); xTask.AssemblerLog = AssemblerLogFile; xTask.OnLogError = m => { throw new Exception("Error during compilation: " + m); }; xTask.OnLogWarning = (m) => Console.WriteLine("Warning: {0}", m); xTask.OnLogMessage = (m) => { Console.WriteLine("Message: {0}", m); }; xTask.OnLogException = (m) => Console.WriteLine("Exception: {0}", m.ToString()); if (!xTask.Execute()) { throw new Exception("Error occurred while running compiler!"); } }
private static int Main(string[] args) { try { var tmp = ""; foreach (var s in args) { tmp += s; string[] s1 = s.Split(':'); string argID = s1[0].ToLower(); if (argID != "References".ToLower()) { CmdOptions.Add(argID, s.Replace(s1[0] + ":", "")); } else { References.Add(s.Replace(s1[0] + ":", "")); } } //File.WriteAllText("C:\\Users\\Emile\\Desktop\\dump.txt",tmp); var xTask = new CompilerEngine(); xTask.DebugEnabled = Convert.ToBoolean(CmdOptions["DebugEnabled".ToLower()]); Console.WriteLine("Loaded : DebugEnabled"); xTask.StackCorruptionDetectionEnabled = Convert.ToBoolean(CmdOptions["StackCorruptionDetectionEnabled".ToLower()]); Console.WriteLine("Loaded : StackCorruptionDetectionEnabled"); xTask.DebugMode = CmdOptions["DebugMode".ToLower()]; Console.WriteLine("Loaded : DebugMode"); xTask.TraceAssemblies = null; Console.WriteLine("Loaded : TraceAssemblies"); xTask.DebugCom = Convert.ToByte(CmdOptions["DebugCom".ToLower()]); Console.WriteLine("Loaded : DebugCom"); xTask.UseNAsm = Convert.ToBoolean(CmdOptions["UseNAsm".ToLower()]); Console.WriteLine("Loaded : UseNAsm"); xTask.OutputFilename = CmdOptions["OutputFilename".ToLower()];; Console.WriteLine("Loaded : OutputFilename"); xTask.EnableLogging = Convert.ToBoolean(CmdOptions["EnableLogging".ToLower()]);; Console.WriteLine("Loaded : EnableLogging"); xTask.EmitDebugSymbols = Convert.ToBoolean(CmdOptions["EmitDebugSymbols".ToLower()]);; Console.WriteLine("Loaded : EmitDebugSymbols"); xTask.IgnoreDebugStubAttribute = Convert.ToBoolean(CmdOptions["IgnoreDebugStubAttribute".ToLower()]); Console.WriteLine("Loaded : IgnoreDebugStubAttribute"); xTask.References = References.ToArray(); Console.WriteLine("Loaded : References"); xTask.OnLogError = (m) => Console.Error.WriteLine("Error: {0}", m); xTask.OnLogWarning = (m) => Console.WriteLine("Warning: {0}", m); xTask.OnLogMessage = (m) => { Console.WriteLine("Message: {0}", m); }; xTask.OnLogException = (m) => Console.Error.WriteLine("Exception: {0}", m.ToString()); xTask.AssemblerLog = "Cosmos.Assembler.log"; if (xTask.Execute()) { Console.WriteLine("Executed OK"); // File.WriteAllText(@"e:\compiler.log", "OK"); return(0); } else { Console.WriteLine("Errorred"); // File.WriteAllText(@"e:\compiler.log", "Errored"); return(2); } } catch (Exception E) { // Console.Out.Flush(); // File.WriteAllText("./ErrorDump.txt",E.ToString() + " " + E.Source); Console.WriteLine("Error occurred: " + E.ToString()); // File.WriteAllText(@"e:\compiler.log", "Exception: " + E.ToString()); return(1); } }
public static int Run(string[] args, Action <string> logMessage, Action <string> logError) { if (args == null) { throw new ArgumentNullException("args"); } if (logMessage == null) { throw new ArgumentNullException("logMessage"); } if (logError == null) { throw new ArgumentNullException("logError"); } try { var tmp = ""; foreach (var s in args) { tmp += s; string[] s1 = s.Split(':'); string argID = s1[0].ToLower(); if (argID != "References".ToLower()) { CmdOptions.Add(argID, s.Replace(s1[0] + ":", "")); } else { References.Add(s.Replace(s1[0] + ":", "")); } } var xTask = new CompilerEngine(); xTask.DebugEnabled = Convert.ToBoolean(CmdOptions["DebugEnabled".ToLower()]); logMessage("Loaded : DebugEnabled"); xTask.StackCorruptionDetectionEnabled = Convert.ToBoolean(CmdOptions["StackCorruptionDetectionEnabled".ToLower()]); logMessage("Loaded : StackCorruptionDetectionEnabled"); xTask.DebugMode = CmdOptions["DebugMode".ToLower()]; logMessage("Loaded : DebugMode"); xTask.TraceAssemblies = null; logMessage("Loaded : TraceAssemblies"); xTask.DebugCom = Convert.ToByte(CmdOptions["DebugCom".ToLower()]); logMessage("Loaded : DebugCom"); xTask.UseNAsm = Convert.ToBoolean(CmdOptions["UseNAsm".ToLower()]); logMessage("Loaded : UseNAsm"); xTask.OutputFilename = CmdOptions["OutputFilename".ToLower()];; logMessage("Loaded : OutputFilename"); xTask.EnableLogging = Convert.ToBoolean(CmdOptions["EnableLogging".ToLower()]);; logMessage("Loaded : EnableLogging"); xTask.EmitDebugSymbols = Convert.ToBoolean(CmdOptions["EmitDebugSymbols".ToLower()]);; logMessage("Loaded : EmitDebugSymbols"); xTask.IgnoreDebugStubAttribute = Convert.ToBoolean(CmdOptions["IgnoreDebugStubAttribute".ToLower()]); logMessage("Loaded : IgnoreDebugStubAttribute"); xTask.References = References.ToArray(); logMessage("Loaded : References"); xTask.OnLogError = logError; xTask.OnLogWarning = m => logMessage(String.Format("Warning: {0}", m)); xTask.OnLogMessage = logMessage; xTask.OnLogException = (m) => logError(String.Format("Exception: {0}", m.ToString())); xTask.AssemblerLog = "Cosmos.Assembler.log"; if (xTask.Execute()) { logMessage("Executed OK"); // File.WriteAllText(@"e:\compiler.log", "OK"); return(0); } else { logMessage("Errorred"); // File.WriteAllText(@"e:\compiler.log", "Errored"); return(2); } } catch (Exception E) { logError(String.Format("Error occurred: " + E.ToString())); return(1); } }