/// <summary> /// Used for "registering" options with their strings /// </summary> /// <param name="option"></param> /// <param name="optionText"></param> /// <returns></returns> public static ILasmAddResult Add(ILasm option, string optionText) { try { if (!Options.ContainsKey(option)) { Options.Add(option, optionText); return ILasmAddResult.SUCCESS; } else { return ILasmAddResult.EXISTS; } } catch { return ILasmAddResult.FAIL; } }
/// <summary> /// Used for "registering" options with their strings /// </summary> /// <param name="option"></param> /// <param name="optionText"></param> /// <returns></returns> public static ILasmAddResult Add(ILasm option, string optionText) { try { if (!Options.ContainsKey(option)) { Options.Add(option, optionText); return(ILasmAddResult.SUCCESS); } else { return(ILasmAddResult.EXISTS); } } catch { return(ILasmAddResult.FAIL); } }
/// <summary> /// Used for "registering" options with their strings /// </summary> /// <param name="option"></param> /// <param name="optionText"></param> /// <returns></returns> public static ILasmAddResult Add(ILasm option, string optionText, bool overwriteExisting) { try { if (!Options.ContainsKey(option)) { Options.Add(option, optionText); return(ILasmAddResult.SUCCESS); } else { if (overwriteExisting) { return(ILasmAddResult.OVERWRITE); } return(ILasmAddResult.EXISTS); } } catch { return(ILasmAddResult.FAIL); } }
/// <summary> /// Used for "registering" options with their strings /// </summary> /// <param name="option"></param> /// <param name="optionText"></param> /// <returns></returns> public static ILasmAddResult Add(ILasm option, string optionText, bool overwriteExisting) { try { if (!Options.ContainsKey(option)) { Options.Add(option, optionText); return ILasmAddResult.SUCCESS; } else { if (overwriteExisting) { return ILasmAddResult.OVERWRITE; } return ILasmAddResult.EXISTS; } } catch { return ILasmAddResult.FAIL; } }
/// <summary> /// Least lazy SelectOption /// Provides the very best way to add options you want to use for ILasm. If option needs to have extra info provided, put it into extraInfo. /// SelectOptions allows you to place options at four places: /// Start of options before name of the compiled file (Position.PRESTART) /// End of options before name of the compiled file (Position.PRE) /// Start of options after name of the compiled file (Position.POSTSTART) /// End of options after name of the compiled file (Position.POST) /// NOTE: When adding options with extra info required, don't add the '='. SelectOption already adds it itself. /// </summary> /// <param name="option"></param> /// <param name="extraInfo"></param> /// <param name="pos"></param> public static void SelectOption(ILasm option, string extraInfo, Position pos) { if (Enum.IsDefined(typeof(ILasmExtra), option) && String.IsNullOrEmpty(extraInfo)) { Exceptions.Exception(14); return; } if (Enum.IsDefined(typeof(ILasmExtra), option)) { int HackyInt = 0; if (!BenevolentOptions) { switch (option) { case ILasm.RESOURCE: if (!extraInfo.EndsWith(".res") && !Config.benevolentOptions) { Exceptions.Exception(16); Exceptions.Exception(19); return; } break; case ILasm.BASE: case ILasm.STACK: case ILasm.FLAGS: case ILasm.SUBSYSTEM: case ILasm.ALIGNMENT: if (!Int32.TryParse(extraInfo, out HackyInt)) { Exceptions.Exception(16); Exceptions.Exception(20); } break; } } switch (pos) { case Position.PRESTART: PreOptions.Insert(0, Options[option] + EquationChar + extraInfo); break; case Position.PRE: PreOptions.Add(Options[option] + EquationChar + extraInfo); break; case Position.POSTSTART: PostOptions.Insert(0, Options[option] + EquationChar + extraInfo); break; case Position.POST: PostOptions.Add(Options[option] + EquationChar + extraInfo); break; } } else { switch (pos) { case Position.PRESTART: PreOptions.Insert(0, Options[option]); break; case Position.PRE: PreOptions.Add(Options[option]); break; case Position.POSTSTART: PostOptions.Insert(0, Options[option]); break; case Position.POST: PostOptions.Add(Options[option]); break; } } }
/// <summary> /// Moderately lazy SelectOption /// </summary> /// <param name="option"> Option you want to add </param> /// <param name="extraInfo"> Extra information needed to be provided too ILasmExtra Options </param> public static void SelectOption(ILasm option, string extraInfo) { SelectOption(option, extraInfo, Position.PRE); }
/// <summary> /// Laziest SelectOption /// </summary> /// <param name="option"> Option you want to add </param> public static void SelectOption(ILasm option) { SelectOption(option, null); }
static int Main(string[] args) { string aname = "a.exe", oname = String.Empty; int i, nf = 0; bool verbose = false; TextWriter outfile = Console.Out; ArrayList thunks = new ArrayList(), unmanaged = new ArrayList(), asmargs = new ArrayList(new string[] { "-nologo", "-quiet" }); for (i = 0; i < args.Length; i++) { switch (args[i]) { case "-help": case "-?": usage(); continue; case "-log": // -log Log.New(Console.Error, argv); continue; case "-a": // -a name if (++i >= args.Length) { usage(); } aname = args[i]; continue; case "-debug": // -debug asmargs.Add(args[i]); continue; case "-o": // -o file if (++i >= args.Length) { usage(); } oname = args[i]; continue; case "-u": // -u ListUndefined(); continue; case "-v": // -v verbose = true; continue; case "-l": // -l file if (++i >= args.Length) { usage(); } Library.Search(args[i], verbose, Console.Out); continue; case "-": Pass1("-", Console.In, unmanaged); nf++; continue; } if (args[i].StartsWith("-log=")) { Log.New(args[i].Substring(5), argv); } else if (!args[i].StartsWith("-")) { try { StreamReader input = new StreamReader(args[i]); Pass1(args[i], input, unmanaged); input.Close(); asmargs.Add(args[i]); } catch { Warning("can't read {0}", args[i]); } nf++; } } if (nf == 0) { Pass1("-", Console.In, unmanaged); } if (Symbols.refs.Count > 0) { Warning("undefined symbols:"); ListUndefined(); } if (oname == String.Empty) { oname = Path.GetTempFileName(); } if (oname == "-") { Pass2(aname, unmanaged, Console.Out); } else { try { TextWriter output = new StreamWriter(oname); Pass2(aname, unmanaged, output); output.Close(); asmargs.Add(oname); } catch { Warning("can't write {0}", oname); } } if (aname != String.Empty) { asmargs.Add("-out=" + aname); } ILasm.Run(asmargs, verbose, Console.Out); return(0); }