1 // (* ========================================================= *)
2 // (** Interface to the ILASM Byte-code assembler. *)
3 // (* K John Gough, 10th June 1999 *)
4 // (* Modifications: *)
5 // (* Version for GPCP V0.3 April 2000 (kjg) *)
6 // (* ========================================================= *)
7 // (* The real code is in MsilAsm.cs *)
8 // (* ========================================================= *)
12 // PROCEDURE Init*(); BEGIN END Init;
14 // PROCEDURE Assemble*(IN fil, opt : ARRAY OF CHAR; main : BOOLEAN);
15 // BEGIN END Assemble;
20 // NOTE: this needs (as at 13-Jun-2000) to be compiled using
22 // $ csc /t:library /r:System.Diagnostics.dll /r:RTS.dll MsilAsm.cs
24 // NOTE: for Beta2 this finds System.Diagnostics in mscorlib.dll
26 // $ csc /t:library /r:RTS.dll MsilAsm.cs
32 using System.Diagnostics;
36 public class MsilAsm {
38 private static Process asm = null;
41 public static string GetDotNetRuntimeInstallDirectory()
43 // Get the path to mscorlib.dll
44 string s = typeof(object).Module.FullyQualifiedName;
46 // Remove the file part to get the directory
47 return System.IO.Directory.GetParent(s).ToString() + "\\";
50 public static void Init() {
53 asm.StartInfo.FileName = GetDotNetRuntimeInstallDirectory() + "ilasm";
55 asm.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
57 asm.StartInfo.CreateNoWindow = true;
58 asm.StartInfo.UseShellExecute = false;
63 public static void Assemble(char[] fil, char[] opt, bool hasMain) {
67 System.String fName = CP_rts.mkStr(fil);
75 optNm = optNm + CP_rts.mkStr(opt) + ' ';
76 asm.StartInfo.Arguments = optNm + "/nologo /quiet " + fName + ".il";
79 retCode = asm.ExitCode;
81 System.Console.WriteLine("#gpcp: ilasm FAILED " + retCode);
83 System.Console.WriteLine("#gpcp: created " + fName + suffx);
86 public static void DoAsm(char[] fil, char[] opt,
92 System.String fName = CP_rts.mkStr(fil);
100 optNm = optNm + CP_rts.mkStr(opt) + ' ';
102 System.Console.WriteLine("#gpcp: Calling " + asm.StartInfo.FileName);
104 asm.StartInfo.CreateNoWindow = false;
106 asm.StartInfo.Arguments = optNm + "/nologo " + fName + ".il";
109 asm.StartInfo.CreateNoWindow = true;
111 asm.StartInfo.Arguments = optNm + "/nologo /quiet " + fName + ".il";
117 System.Console.WriteLine("#gpcp: Created " + fName + suffx);
121 public static void Assemble(char[] fil, bool hasMain) {
122 char[] opt = {'/', 'd', 'e', 'b', 'u', 'g', '\0' };
123 Assemble(fil, opt, hasMain);