- using Mono.MonoBASIC;
- using Mono.GetOptions;
-
- enum Target
- {
- Library, Exe, Module, WinExe
- };
-
- enum OptionCompare
- {
- Binary, Text
- };
-
- /// <summary>
- /// The compiler driver.
- /// </summary>
- public class Driver : Options
- {
- // Temporary options
- //------------------------------------------------------------------
- [Option("[Mono] Only parses the source file (for debugging the tokenizer)", "parse")]
- public bool parse_only = false;
-
- [Option("[Mono] Only tokenizes source files")]
- public bool tokenize = false;
-
- [Option("[Mono] Shows stack trace at Error location")]
- public bool stacktrace { set { Report.Stacktrace = value; } }
-
- [Option("[Mono] Displays time stamps of various compiler events")]
- public bool timestamp
- {
- set
- {
- timestamps = true;
- last_time = DateTime.Now;
- debug_arglist.Add("timestamp");
- }
- }
-
- // Mono-specific options
- //------------------------------------------------------------------
- [Option("About the MonoBASIC compiler", "about")]
- public override WhatToDoNext DoAbout()
- {
- return base.DoAbout();
- }
-
- [Option("[Mono] Don\'t assume the standard library", "nostdlib")]
- public bool NoStandardLibraries { set { RootContext.StdLib = !value; } }
-
- [Option("[Mono] Disables implicit references to assemblies", "noconfig")]
- public bool NoConfig { set { load_default_config = !value; } }
-
- [Option("[Mono] Allows unsafe code", "unsafe")]
- public bool AllowUnsafeCode { set { RootContext.Unsafe = value; } }
-
- [Option("[Mono] Set default context to checked", "checked")]
- public bool Checked { set { RootContext.Checked = value; } }
-
- [Option("[Mono] Debugger {arguments}", "debug-args")]
- public WhatToDoNext SetDebugArgs(string args)
- {
- char[] sep = { ',' };
- debug_arglist.AddRange (args.Split (sep));
- return WhatToDoNext.GoAhead;
- }
-
- [Option("[Mono] Ignores warning number {XXXX}", "ignorewarn")]
- public WhatToDoNext SetIgnoreWarning(int warn)
- {
- Report.SetIgnoreWarning(warn);
- return WhatToDoNext.GoAhead;
- }
-
- [Option("[Mono] Sets warning {level} (the highest is 4, the default)", "wlevel")]
- public int WarningLevel { set { RootContext.WarningLevel = value; } }
-
- [Option("[Mono] Makes errors fatal", "fatal")]
- public bool Fatal { set { Report.Fatal = value; } }
-
- // Output file options
- //------------------------------------------------------------------
- [Option("Specifies the output {file} name", 'o', "out")]
- public string OutputFileName = null;
-
- [Option("Specifies the target {type} for the output file (exe [default], winexe, library, module)", "target")]
- public WhatToDoNext SetTarget(string type)
- {
- switch (type.ToLower())
- {
- case "library":
- target = Target.Library;
- target_ext = ".dll";
- break;
-
- case "exe":
- target = Target.Exe;
- break;
-
- case "winexe":
- target = Target.WinExe;
- break;
-
- case "module":
- target = Target.Module;
- target_ext = ".dll";
- break;
- }
- return WhatToDoNext.GoAhead;
- }
-
- // input file options
- //------------------------------------------------------------------
- public ArrayList AddedModules = new ArrayList();
-
- [Option("[NOT IMPLEMENTED YET]References metadata from specified {module}", "addmodule")]
- public string AddedModule { set { AddedModules.Add(value); } }
-
- [Option("[NOT IMPLEMENTED YET]Include all files in the current directory and subdirectories according to the {wildcard}", "recurse")]
- public WhatToDoNext Recurse(string wildcard)
- {
- //AddFiles (DirName, true); // TODO wrong semantics
- return WhatToDoNext.GoAhead;
- }
-
- [Option(-1, "References metadata from the specified {assembly}", 'r', "reference")]
- public string AddedReference { set { references.Add(value); } }
-
- // support for the Compact Framework
- //------------------------------------------------------------------
- [Option("[NOT IMPLEMENTED YET]Sets the compiler to target the Compact Framework","netcf")]
- public bool CompileForCompactFramework = false;
-
- [Option("[NOT IMPLEMENTED YET]Specifies the {path} to the location of mscorlib.dll and microsoft.visualbasic.dll", "sdkpath")]
- public string SDKPath = null;
-
- // resource options
- //------------------------------------------------------------------
- public ArrayList EmbeddedResources = new ArrayList();
-
- [Option(-1, "Adds the specified {file} as an embedded assembly resource", "resource", "res")]
- public string AddedResource { set { EmbeddedResources.Add(value); } }
-
- public ArrayList LinkedResources = new ArrayList();
-
- [Option(-1, "[NOT IMPLEMENTED YET]Adds the specified {file} as a linked assembly resource", "linkresource", "linkres")]
- public string AddedLinkresource { set { LinkedResources.Add(value); } }
-
- public ArrayList Win32Resources = new ArrayList();
-
- [Option(-1, "[NOT IMPLEMENTED YET]Specifies a Win32 resource {file} (.res)", "win32resource")]
- public string AddedWin32resource { set { Win32Resources.Add(value); } }
-
- public ArrayList Win32Icons = new ArrayList();
-
- [Option(-1, "[NOT IMPLEMENTED YET]Specifies a Win32 icon {file} (.ico) for the default Win32 resources", "win32icon")]
- public string AddedWin32icon { set { Win32Icons.Add(value); } }
-
- // code generation options
- //------------------------------------------------------------------
- [Option("[NOT IMPLEMENTED YET]Enable optimizations", "optimize")]
- public bool optimize = false;
-
- [Option("[NOT IMPLEMENTED YET]Remove integer checks. Default off.")]
- public bool removeintchecks = false;
-
- // TODO: handle VB.NET [+|-] boolean syntax
- [Option("Emit debugging information", 'g', "debug")]
- public bool want_debugging_support = false;
-
- [Option("Emit full debugging information (default)", "debug:full")]
- public bool fullDebugging = false;
-
- [Option("[IGNORED]Emit PDB file only", "debug:pdbonly")]
- public bool pdbOnly = false;
-
- // errors and warnings options
- //------------------------------------------------------------------
- [Option("Treat warnings as errors", "warnaserror")]
- public bool WarningsAreErrors { set { Report.WarningsAreErrors = value; } }
-
- [Option("Disable warnings", "nowarn")]
- public bool NoWarnings { set { if (value) RootContext.WarningLevel = 0; } }
-
-
- // language options
- //------------------------------------------------------------------
- public Hashtable Defines = new Hashtable();
-
- [Option(-1, "Declares global conditional compilation symbol(s). {symbol-list}:name=value,...", 'd', "define")]
- public string define {
- set
- {
- foreach(string item in value.Split(','))
- {
- string[] dados = item.Split('=');
- try
- {
- if (dados.Length > 1)
- Defines.Add(dados[0], dados[1]);
- else
- Defines.Add(dados[0], string.Empty);
- }
- catch
- {
- Error ("Could not define symbol" + dados[0]);
- }
- }
- }
- }
-
- [Option("Declare global Imports for namespaces in referenced metadata files. {import-list}:namespace,...", "imports")]
- public WhatToDoNext imports(string importslist)
- {
- Mono.MonoBASIC.Parser.ImportsList.AddRange(importslist.Split(','));
- return WhatToDoNext.GoAhead;
- }
-
- // TODO: handle VB.NET [+|-] boolean syntax
- [Option("[NOT IMPLEMENTED YET]Require explicit declaration of variables")]
- public bool optionexplicit { set { Mono.MonoBASIC.Parser.InitialOptionExplicit = value; } }
-
- // TODO: handle VB.NET [+|-] boolean syntax
- [Option("[NOT IMPLEMENTED YET]Enforce strict language semantics")]
- public bool optionstrict { set { Mono.MonoBASIC.Parser.InitialOptionStrict = value; } }
-
- [Option("[NOT IMPLEMENTED YET]Specifies binary-style string comparisons. This is the default", "optioncompare:binary")]
- public bool optioncomparebinary { set { Mono.MonoBASIC.Parser.InitialOptionCompareBinary = true; } }
-
- [Option("[NOT IMPLEMENTED YET]Specifies text-style string comparisons.", "optioncompare:text")]
- public bool optioncomparetext { set { Mono.MonoBASIC.Parser.InitialOptionCompareBinary = false; } }
-
- [Option("Specifies de root {namespace} for all type declarations")]
- public string rootnamespace { set { RootContext.RootNamespace = value; } }
-
- // Miscellaneous options
- //------------------------------------------------------------------
-
- [Option("[IGNORED]Do not display compiler copyright banner")]
- public bool nologo = false;
-
- [Option("[NOT IMPLEMENTED YET]Quiet output mode")]
- public bool quiet = false;
-
- // TODO: semantics are different and should be adjusted
- [Option("Display verbose messages", 'v')]
- public bool verbose { set { GenericParser.yacc_verbose_flag = value; } }
-
- // Advanced options
- //------------------------------------------------------------------
- // TODO: force option to accept number in hex format
- [Option("[NOT IMPLEMENTED YET]The base {address} for a library or module (hex)")]
- public int baseaddress;
-
- [Option("[NOT IMPLEMENTED YET]Create bug report {file}")]
- public string bugreport;
-
- // TODO: handle VB.NET [+|-] boolean syntax
- [Option("[NOT IMPLEMENTED YET]Delay-sign the assembly using only the public portion of the strong name key")]
- public bool delaysign;
-
- [Option("[NOT IMPLEMENTED YET]Specifies a strong name key {container}")]
- public string keycontainer;
-
- [Option("[NOT IMPLEMENTED YET]Specifies a strong name key {file}")]
- public string keyfile;
-
- public string[] libpath = null;
-
- [Option("List of directories to search for metadata references {path-list}:path;...", "libpath")]
- public WhatToDoNext setlibpath(string pathlist)
- {
- libpath = pathlist.Split(';');
- return WhatToDoNext.GoAhead;
- }