|
@@ -15,13 +15,14 @@
|
|
|
// BEGIN END Assemble;
|
|
|
//
|
|
|
//END MsilAsm.
|
|
|
-//
|
|
|
-//
|
|
|
-// NOTE: this needs (since 2005) to be compiled using
|
|
|
//
|
|
|
-// $ csc /t:library /r:RTS.dll MsilAsm.cs
|
|
|
+// Compile with :
|
|
|
+//
|
|
|
+// $ csc /t:library /debug MsilAsm.cs
|
|
|
//
|
|
|
|
|
|
+using System;
|
|
|
+using System.Text;
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
namespace MsilAsm {
|
|
@@ -35,77 +36,89 @@ public class MsilAsm {
|
|
|
{
|
|
|
// Get the path to mscorlib.dll
|
|
|
string s = typeof(object).Module.FullyQualifiedName;
|
|
|
-
|
|
|
// Remove the file part to get the directory
|
|
|
- return System.IO.Directory.GetParent(s).ToString() + "\\";
|
|
|
+ return System.IO.Directory.GetParent(s).ToString();
|
|
|
}
|
|
|
|
|
|
- public static void Init() {
|
|
|
- if (asm == null) {
|
|
|
- asm = new Process();
|
|
|
- asm.StartInfo.FileName = GetDotNetRuntimeInstallDirectory() + "ilasm";
|
|
|
- asm.StartInfo.CreateNoWindow = true;
|
|
|
- asm.StartInfo.UseShellExecute = false;
|
|
|
- }
|
|
|
- }
|
|
|
+ public static void Init() {
|
|
|
+ if (asm == null) {
|
|
|
+ asm = new Process();
|
|
|
+ System.String frameworkDir = GetDotNetRuntimeInstallDirectory();
|
|
|
+ //System.String frameworkDir = Environment.GetEnvironmentVariable("NET40", EnvironmentVariableTarget.User);
|
|
|
+ asm.StartInfo.FileName = frameworkDir + "\\" + "ilasm";
|
|
|
+ asm.StartInfo.CreateNoWindow = true;
|
|
|
+ asm.StartInfo.UseShellExecute = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- public static void Assemble(char[] fil, char[] opt, bool hasMain) {
|
|
|
- int retCode;
|
|
|
- System.String optNm;
|
|
|
- System.String suffx;
|
|
|
- System.String fName = CP_rts.mkStr(fil);
|
|
|
- if (hasMain) {
|
|
|
- optNm = "/exe ";
|
|
|
- suffx = ".exe";
|
|
|
- } else {
|
|
|
- optNm = "/dll ";
|
|
|
- suffx = ".dll";
|
|
|
- }
|
|
|
- optNm = optNm + CP_rts.mkStr(opt) + ' ';
|
|
|
- asm.StartInfo.Arguments = optNm + "/nologo /quiet " + fName + ".il";
|
|
|
- asm.Start();
|
|
|
- asm.WaitForExit();
|
|
|
- retCode = asm.ExitCode;
|
|
|
- if (retCode != 0)
|
|
|
- System.Console.WriteLine("#gpcp: ilasm FAILED " + retCode);
|
|
|
- else
|
|
|
- System.Console.WriteLine("#gpcp: created " + fName + suffx);
|
|
|
- }
|
|
|
-
|
|
|
- public static void DoAsm(char[] fil, char[] opt,
|
|
|
- bool hasMain,
|
|
|
- bool verbose,
|
|
|
- ref int rslt) {
|
|
|
- System.String optNm;
|
|
|
- System.String suffx;
|
|
|
- System.String fName = CP_rts.mkStr(fil);
|
|
|
- if (hasMain) {
|
|
|
- optNm ="/exe ";
|
|
|
- suffx = ".exe";
|
|
|
- } else {
|
|
|
- optNm = "/dll ";
|
|
|
- suffx = ".dll";
|
|
|
- }
|
|
|
- optNm = optNm + CP_rts.mkStr(opt) + ' ';
|
|
|
- if (verbose) {
|
|
|
- System.Console.WriteLine("#gpcp: Calling " + asm.StartInfo.FileName);
|
|
|
- asm.StartInfo.CreateNoWindow = false;
|
|
|
- asm.StartInfo.Arguments = optNm + "/nologo " + fName + ".il";
|
|
|
- } else {
|
|
|
- asm.StartInfo.CreateNoWindow = true;
|
|
|
- asm.StartInfo.Arguments = optNm + "/nologo /quiet " + fName + ".il";
|
|
|
- }
|
|
|
- asm.Start();
|
|
|
- asm.WaitForExit();
|
|
|
- rslt = asm.ExitCode;
|
|
|
- if (rslt == 0)
|
|
|
- System.Console.WriteLine("#gpcp: Created " + fName + suffx);
|
|
|
- }
|
|
|
+ private static int CPlen(char[] arr) {
|
|
|
+ int len = arr.Length;
|
|
|
+ for (int ix = 0; ix < len; ix++)
|
|
|
+ if (arr[ix] == '\0')
|
|
|
+ return ix;
|
|
|
+ return len;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void Assemble(char[] fil, char[] opt, bool hasMain) {
|
|
|
+ int retCode;
|
|
|
+ System.String optNm;
|
|
|
+ System.String suffx;
|
|
|
+ System.String fName = new String(fil, 0, CPlen(fil));
|
|
|
+ if (hasMain) {
|
|
|
+ optNm = "/exe ";
|
|
|
+ suffx = ".exe";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ optNm = "/dll ";
|
|
|
+ suffx = ".dll";
|
|
|
+ }
|
|
|
+ optNm = optNm + new String(opt, 0, CPlen(opt)) + ' ';
|
|
|
+ asm.StartInfo.Arguments = optNm + "/nologo /quiet " + fName + ".il";
|
|
|
+ asm.Start();
|
|
|
+ asm.WaitForExit();
|
|
|
+ retCode = asm.ExitCode;
|
|
|
+ if (retCode != 0)
|
|
|
+ System.Console.WriteLine("#gpcp: ilasm FAILED " + retCode);
|
|
|
+ else
|
|
|
+ System.Console.WriteLine("#gpcp: created " + fName + suffx);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void DoAsm(char[] fil, char[] opt,
|
|
|
+ bool hasMain,
|
|
|
+ bool verbose,
|
|
|
+ ref int rslt) {
|
|
|
+ System.String optNm;
|
|
|
+ System.String suffx;
|
|
|
+ System.String fName = new String(fil, 0, CPlen(fil));
|
|
|
|
|
|
-
|
|
|
- public static void Assemble(char[] fil, bool hasMain) {
|
|
|
+ if (hasMain) {
|
|
|
+ optNm = "/exe ";
|
|
|
+ suffx = ".exe";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ optNm = "/dll ";
|
|
|
+ suffx = ".dll";
|
|
|
+ }
|
|
|
+ optNm = optNm + new String(opt, 0, CPlen(opt)) + ' ';
|
|
|
+ if (verbose) {
|
|
|
+ asm.StartInfo.Arguments = optNm + "/nologo " + fName + ".il";
|
|
|
+ System.Console.WriteLine("#gpcp: Calling " + asm.StartInfo.FileName + ' ' + asm.StartInfo.Arguments);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ asm.StartInfo.Arguments = optNm + "/nologo /quiet " + fName + ".il";
|
|
|
+ }
|
|
|
+ asm.Start();
|
|
|
+ asm.WaitForExit();
|
|
|
+ rslt = asm.ExitCode;
|
|
|
+ if (rslt == 0)
|
|
|
+ System.Console.WriteLine("#gpcp: Created " + fName + suffx);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void Assemble(char[] fil, bool hasMain) {
|
|
|
char[] opt = {'/', 'd', 'e', 'b', 'u', 'g', '\0' };
|
|
|
Assemble(fil, opt, hasMain);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|