PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/source2/Users/Orvid/IL2CPURunner/Program.cs

https://bitbucket.org/mvptracker/cosmos
C# | 63 lines | 62 code | 1 blank | 0 comment | 0 complexity | b7488fc7741c9bf83be11d08fc459a42 MD5 | raw file
Possible License(s): BSD-2-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Cosmos.Build.Common;
  6. using Cosmos.IL2CPU.X86;
  7. using Cosmos.Debug.Common;
  8. using Cosmos.IL2CPU;
  9. using System.IO;
  10. namespace IL2CPURunner
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
  17. StreamWriter strw = new StreamWriter("log.txt");
  18. s.Start();
  19. System.Reflection.Assembly.Load("Cosmos.Build.Common");
  20. System.Reflection.Assembly.Load("Cosmos.Compiler.Assembler");
  21. System.Reflection.Assembly.Load("Cosmos.Compiler.Assembler.X86");
  22. System.Reflection.Assembly.Load("Cosmos.Core.Plugs");
  23. System.Reflection.Assembly.Load("Cosmos.Debug.Common");
  24. System.Reflection.Assembly.Load("Cosmos.Debug.DebugStub");
  25. System.Reflection.Assembly.Load("Cosmos.Debug.Kernel");
  26. System.Reflection.Assembly.Load("Cosmos.Debug.Kernel.Plugs");
  27. System.Reflection.Assembly.Load("Cosmos.IL2CPU");
  28. System.Reflection.Assembly.Load("Cosmos.IL2CPU.Plugs");
  29. System.Reflection.Assembly.Load("Cosmos.IL2CPU.X86");
  30. System.Reflection.Assembly.Load("Cosmos.System");
  31. System.Reflection.Assembly.Load("Cosmos.System.Plugs.System");
  32. var xInitMethod = typeof(StructTest.Kernel).GetConstructor(Type.EmptyTypes);
  33. var xOutputFilename = System.Windows.Forms.Application.StartupPath + "\\" + "StructTest";
  34. var xAsm = new AppAssemblerNasm(0);
  35. using (var xDebugInfo = new DebugInfo())
  36. {
  37. xDebugInfo.CreateCPDB(xOutputFilename + ".cpdb");
  38. xAsm.DebugInfo = xDebugInfo;
  39. xAsm.DebugMode = DebugMode.None;
  40. xAsm.TraceAssemblies = TraceAssemblies.All;
  41. xAsm.ShouldOptimize = true;
  42. var xNasmAsm = (AssemblerNasm)xAsm.Assembler;
  43. xAsm.Assembler.Initialize();
  44. using (var xScanner = new ILScanner(xAsm))
  45. {
  46. // TODO: shouldn't be here?
  47. xScanner.QueueMethod(xInitMethod.DeclaringType.BaseType.GetMethod("Start"));
  48. xScanner.Execute(xInitMethod);
  49. using (var xOut = new StreamWriter(xOutputFilename + ".asm", false))
  50. {
  51. xAsm.Assembler.FlushText(xOut);
  52. }
  53. }
  54. }
  55. s.Stop();
  56. strw.Write("Total Time to Run: " + s.ElapsedMilliseconds.ToString() + "ms");
  57. strw.Close();
  58. }
  59. }
  60. }