private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output)
        {
            VsaEngine engine = new VsaEngine(true);
            VsaSite   site   = new VsaSite(output);

            engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site);

            // Ensure that all options are valid; throw a CmdLineException otherwise
            this.ValidateOptions(options, engine);

            // Set options on the engine (equivalent of cmdline args in out-of-proc scenario)
            engine.GenerateDebugInfo = options.IncludeDebugInformation;
            engine.SetOption("referenceLoaderAPI", "LoadFile");
            engine.SetOption("fast", true);
            engine.SetOption("print", false);
            engine.SetOption("VersionSafe", false);
            engine.SetOption("output", options.OutputAssembly);
            if (options.GenerateExecutable)
            {
                engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication);
            }
            else
            {
                engine.SetOption("PEFileKind", PEFileKinds.Dll);
            }
            site.treatWarningsAsErrors = options.TreatWarningsAsErrors;
            engine.SetOption("warnaserror", options.TreatWarningsAsErrors);
            site.warningLevel = options.WarningLevel;
            engine.SetOption("WarningLevel", options.WarningLevel);
            bool stdLibAdded = false;

            foreach (string assemblyName in options.ReferencedAssemblies)
            {
                if (String.Compare(Path.GetFileName(assemblyName), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    stdLibAdded = true;
                }
                this.AddAssemblyReference(engine, assemblyName);
            }
            if (!stdLibAdded)
            {
                this.AddAssemblyReference(engine, "mscorlib.dll");
            }

            // Parse any additional compiler options
            StringCollection compilerOptions = this.SplitCmdLineArguments(options.CompilerOptions);

            this.ParseCompilerOptions(engine, compilerOptions, output, options.GenerateExecutable);

            // Add the source files to the engine (as IVsaCodeItems)
            for (int j = 0; j < sourceFiles.Length; j++)
            {
                this.AddSourceFile(engine, sourceFiles[j]);
            }

            return(engine);
        }
Example #2
0
        private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output)
        {
            VsaEngine engine = new VsaEngine(true);
            VsaSite   site   = new VsaSite(output);

            engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site);
            this.ValidateOptions(options, engine);
            engine.GenerateDebugInfo = options.IncludeDebugInformation;
            engine.SetOption("referenceLoaderAPI", "LoadFile");
            engine.SetOption("fast", true);
            engine.SetOption("print", false);
            engine.SetOption("VersionSafe", false);
            engine.SetOption("output", options.OutputAssembly);
            if (options.GenerateExecutable)
            {
                engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication);
            }
            else
            {
                engine.SetOption("PEFileKind", PEFileKinds.Dll);
            }
            site.treatWarningsAsErrors = options.TreatWarningsAsErrors;
            engine.SetOption("warnaserror", options.TreatWarningsAsErrors);
            site.warningLevel = options.WarningLevel;
            engine.SetOption("WarningLevel", options.WarningLevel);
            if ((options.Win32Resource != null) && (options.Win32Resource.Length > 0))
            {
                engine.SetOption("win32resource", options.Win32Resource);
            }
            bool flag = false;

            foreach (string str in options.ReferencedAssemblies)
            {
                if (string.Compare(Path.GetFileName(str), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    flag = true;
                }
                this.AddAssemblyReference(engine, str);
            }
            if (!flag)
            {
                this.AddAssemblyReference(engine, "mscorlib.dll");
            }
            StringCollection args = this.SplitCmdLineArguments(options.CompilerOptions);

            this.ParseCompilerOptions(engine, args, output, options.GenerateExecutable);
            for (int i = 0; i < sourceFiles.Length; i++)
            {
                this.AddSourceFile(engine, sourceFiles[i]);
            }
            return(engine);
        }
Example #3
0
        public virtual void SetOption(string name, object value)
        {
            if (engine.Closed)
            {
                throw new VsaException(VsaError.EngineClosed);
            }
            else if (engine.Busy)
            {
                throw new VsaException(VsaError.EngineBusy);
            }
            else if (engine.Running)
            {
                throw new VsaException(VsaError.EngineRunning);
            }

            engine.SetOption(name, value);
        }
Example #4
0
        //
        // Entry point
        //
        private static void Main(string [] args)
        {
            if (args.Length < 1)
            {
                Usage();
                Environment.Exit(0);
            }
            MainDriver(args);
            VsaEngine engine = new VsaEngine();

            engine.InitVsaEngine("mjs:com.mono-project", new MonoEngineSite());

            foreach (string asm in references)
            {
                IVsaReferenceItem item = (IVsaReferenceItem)engine.Items.CreateItem(asm, VsaItemType.Reference, VsaItemFlag.None);
                item.AssemblyName = asm;
            }

            string asm_name = String.Empty;

            foreach (Assembly assembly in assemblies)
            {
                asm_name = assembly.GetName().FullName;
                IVsaReferenceItem item = (IVsaReferenceItem)engine.Items.CreateItem(asm_name, VsaItemType.Reference, VsaItemFlag.None);
                item.AssemblyName = asm_name;
            }

            foreach (string file in files)
            {
                IVsaCodeItem item = (IVsaCodeItem)engine.Items.CreateItem(file, VsaItemType.Code, VsaItemFlag.None);
                item.SourceText = GetCodeFromFile(file);
            }
            engine.SetOption("debug", want_debugging_support);
            engine.SetOption("link_path", link_paths);
            engine.SetOption("first_source", first_source);
            engine.SetOption("assemblies", assemblies);
            engine.SetOption("out", output_file);
            if (warning_level != -1)
            {
                engine.SetOption("WarningLevel", warning_level);
            }
            engine.Compile();
        }
        private void ParseCompilerOptions(VsaEngine engine, StringCollection args, TextWriter output, bool generateExe)
        {
            // Process compiler options and return command line fragment to complete the partial debug command line
            // that was formed by examining the CompilerParameters structure only.
            string    libpath         = System.Environment.GetEnvironmentVariable("LIB");
            bool      generateWinExe  = false;
            Hashtable defines         = new Hashtable(10);
            Hashtable resources       = new Hashtable(10);
            Hashtable resourceFiles   = new Hashtable(10);
            bool      targetSpecified = false;

            StringBuilder fullCmdLine = null;

            if (this.debugCommandLine != null)
            {
                fullCmdLine = new StringBuilder(this.debugCommandLine);
            }

            // if '/' separates dir, use '-' as switch
            string cmdLineSwitch = Path.DirectorySeparatorChar == '/' ? "-" : "/";

            for (int i = 0, n = args.Count; i < n; i++)
            {
                object argument;
                string option;

                string arg = args[i];
                if (arg == null || arg.Length == 0)
                {
                    continue;
                }

                if (arg[0] == '@')
                {
                    throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "@<filename>", engine.ErrorCultureInfo);
                }

                // slash ('/') character is a valid filename character on UNIX, so we can't use it as a switch
                if ('-' != arg[0] && ('/' != arg[0] || Path.DirectorySeparatorChar == '/'))
                {
                    break;
                }

                option = arg.Substring(1);

                if (option.Length > 0)
                {
                    switch (option[0])
                    {
                    case '?':
                        throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/?", engine.ErrorCultureInfo);

                    case 'a':
                    case 'A':
                        argument = CmdLineOptionParser.IsBooleanOption(option, "autoref");
                        if (argument != null)
                        {
                            engine.SetOption("autoref", argument);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        break;

                    case 'c':
                    case 'C':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "codepage");
                        if (argument != null)
                        {
                            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/codepage:<id>", engine.ErrorCultureInfo);
                        }
                        break;

                    case 'd':
                    case 'D':
                        argument = CmdLineOptionParser.IsBooleanOption(option, "debug");
                        if (argument != null)
                        {
                            engine.GenerateDebugInfo = (bool)argument;
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        argument = CmdLineOptionParser.IsArgumentOption(option, "d", "define");
                        if (argument != null)
                        {
                            this.GetAllDefines((string)argument, defines, engine);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(cmdLineSwitch + "d:\"");
                                fullCmdLine.Append((string)argument);
                                fullCmdLine.Append("\" ");
                            }
                            continue;
                        }
                        break;

                    case 'f':
                    case 'F':
                        argument = CmdLineOptionParser.IsBooleanOption(option, "fast");
                        if (argument != null)
                        {
                            engine.SetOption("fast", argument);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        break;

                    case 'l':
                    case 'L':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "lcid");
                        if (argument != null)
                        {
                            if (((string)argument).Length == 0)
                            {
                                throw new CmdLineException(CmdLineError.NoLocaleID, arg, engine.ErrorCultureInfo);
                            }
                            try
                            {
                                engine.LCID = Int32.Parse((string)argument, CultureInfo.InvariantCulture);
                            }
                            catch
                            {
                                throw new CmdLineException(CmdLineError.InvalidLocaleID, (string)argument, engine.ErrorCultureInfo);
                            }
                            continue;
                        }
                        argument = CmdLineOptionParser.IsArgumentOption(option, "lib");
                        if (argument != null)
                        {
                            string newPaths = (string)argument;
                            if (newPaths.Length == 0)
                            {
                                throw new CmdLineException(CmdLineError.MissingLibArgument, engine.ErrorCultureInfo);
                            }
                            newPaths = newPaths.Replace(',', Path.PathSeparator);
                            libpath  = newPaths + Path.PathSeparator + libpath;
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(cmdLineSwitch + "lib:\"");
                                fullCmdLine.Append((string)argument);
                                fullCmdLine.Append("\" ");
                            }
                            continue;
                        }
                        argument = CmdLineOptionParser.IsArgumentOption(option, "linkres", "linkresource");
                        if (argument != null)
                        {
                            try
                            {
                                ResInfo resinfo = new ResInfo((string)argument, true /* isLinked */);
                                this.AddResourceFile(resinfo, resources, resourceFiles, engine);
                            }
                            catch (CmdLineException)
                            {
                                throw;
                            }
                            catch
                            {
                                throw new CmdLineException(CmdLineError.ManagedResourceNotFound, engine.ErrorCultureInfo);
                            }
                            continue;
                        }
                        break;

                    case 'n':
                    case 'N':
                        argument = CmdLineOptionParser.IsBooleanOption(option, "nologo");
                        if (argument != null)
                        {
                            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/nologo[+|-]", engine.ErrorCultureInfo);
                        }
                        argument = CmdLineOptionParser.IsBooleanOption(option, "nostdlib");
                        if (argument != null)
                        {
                            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/nostdlib[+|-]", engine.ErrorCultureInfo);
                        }
                        break;

                    case 'o':
                    case 'O':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "out");
                        if (argument != null)
                        {
                            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/out:<filename>", engine.ErrorCultureInfo);
                        }
                        break;

                    case 'p':
                    case 'P':
                        argument = CmdLineOptionParser.IsBooleanOption(option, "print");
                        if (argument != null)
                        {
                            engine.SetOption("print", argument);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        argument = CmdLineOptionParser.IsArgumentOption(option, "platform");
                        if (argument != null)
                        {
                            string platform = (string)argument;
                            PortableExecutableKinds PEKindFlags;
                            ImageFileMachine        PEMachineArchitecture;
                            if (String.Compare(platform, "x86", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                PEKindFlags           = PortableExecutableKinds.ILOnly | PortableExecutableKinds.Required32Bit;
                                PEMachineArchitecture = ImageFileMachine.I386;
                            }
                            else if (String.Compare(platform, "Itanium", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                PEKindFlags           = PortableExecutableKinds.ILOnly | PortableExecutableKinds.PE32Plus;
                                PEMachineArchitecture = ImageFileMachine.IA64;
                            }
                            else if (String.Compare(platform, "x64", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                PEKindFlags           = PortableExecutableKinds.ILOnly | PortableExecutableKinds.PE32Plus;
                                PEMachineArchitecture = ImageFileMachine.AMD64;
                            }
                            else if (String.Compare(platform, "anycpu", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                PEKindFlags           = PortableExecutableKinds.ILOnly;
                                PEMachineArchitecture = ImageFileMachine.I386;
                            }
                            else
                            {
                                throw new CmdLineException(CmdLineError.InvalidPlatform, (string)argument, engine.ErrorCultureInfo);
                            }
                            engine.SetOption("PortableExecutableKind", PEKindFlags);
                            engine.SetOption("ImageFileMachine", PEMachineArchitecture);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        break;

                    case 'r':
                    case 'R':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "r", "reference");
                        if (argument != null)
                        {
                            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/r[eference]:<file list>", engine.ErrorCultureInfo);
                        }
                        argument = CmdLineOptionParser.IsArgumentOption(option, "res", "resource");
                        if (argument != null)
                        {
                            try
                            {
                                ResInfo resinfo = new ResInfo((string)argument, false /* isLinked */);
                                this.AddResourceFile(resinfo, resources, resourceFiles, engine);
                            }
                            catch (CmdLineException)
                            {
                                throw;
                            }
                            catch
                            {
                                throw new CmdLineException(CmdLineError.ManagedResourceNotFound, engine.ErrorCultureInfo);
                            }
                            continue;
                        }
                        break;

                    case 't':
                    case 'T':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "t", "target");
                        if (argument != null)
                        {
                            if (String.Compare((string)argument, "exe", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                if (!generateExe)
                                {
                                    throw new CmdLineException(CmdLineError.IncompatibleTargets, arg, engine.ErrorCultureInfo);
                                }
                                if (targetSpecified)
                                {
                                    throw new CmdLineException(CmdLineError.MultipleTargets, engine.ErrorCultureInfo);
                                }
                                // no change -- /t:exe is the default when GenerateExecutable is true
                                targetSpecified = true;
                                continue;
                            }
                            if (String.Compare((string)argument, "winexe", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                if (!generateExe)
                                {
                                    throw new CmdLineException(CmdLineError.IncompatibleTargets, arg, engine.ErrorCultureInfo);
                                }
                                if (targetSpecified)
                                {
                                    throw new CmdLineException(CmdLineError.MultipleTargets, engine.ErrorCultureInfo);
                                }
                                engine.SetOption("PEFileKind", PEFileKinds.WindowApplication);
                                generateWinExe  = true;
                                targetSpecified = true;
                                continue;
                            }
                            if (String.Compare((string)argument, "library", StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                if (generateExe)
                                {
                                    throw new CmdLineException(CmdLineError.IncompatibleTargets, engine.ErrorCultureInfo);
                                }
                                if (targetSpecified)
                                {
                                    throw new CmdLineException(CmdLineError.MultipleTargets, engine.ErrorCultureInfo);
                                }
                                // no change -- /t:library is the default when GenerateExecutable is false
                                targetSpecified = true;
                                continue;
                            }
                            throw new CmdLineException(CmdLineError.InvalidTarget, (string)argument, engine.ErrorCultureInfo);
                        }
                        break;

                    case 'u':
                    case 'U':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "utf8output");
                        if (argument != null)
                        {
                            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/utf8output[+|-]", engine.ErrorCultureInfo);
                        }
                        break;

                    case 'v':
                    case 'V':
                        argument = CmdLineOptionParser.IsBooleanOption(option, "VersionSafe");
                        if (argument != null)
                        {
                            engine.SetOption("VersionSafe", argument);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        break;

                    case 'w':
                    case 'W':
                        argument = CmdLineOptionParser.IsArgumentOption(option, "w", "warn");
                        if (argument != null)
                        {
                            if (((string)argument).Length == 0)
                            {
                                throw new CmdLineException(CmdLineError.NoWarningLevel, arg, engine.ErrorCultureInfo);
                            }
                            if (((string)argument).Length == 1)
                            {
                                if (fullCmdLine != null)
                                {
                                    fullCmdLine.Append(arg);
                                    fullCmdLine.Append(" ");
                                }
                                switch (((string)argument)[0])
                                {
                                case '0': engine.SetOption("WarningLevel", (object)0); continue;

                                case '1': engine.SetOption("WarningLevel", (object)1); continue;

                                case '2': engine.SetOption("WarningLevel", (object)2); continue;

                                case '3': engine.SetOption("WarningLevel", (object)3); continue;

                                case '4': engine.SetOption("WarningLevel", (object)4); continue;
                                }
                            }
                            throw new CmdLineException(CmdLineError.InvalidWarningLevel, arg, engine.ErrorCultureInfo);
                        }
                        argument = CmdLineOptionParser.IsBooleanOption(option, "warnaserror");
                        if (argument != null)
                        {
                            engine.SetOption("warnaserror", argument);
                            if (fullCmdLine != null)
                            {
                                fullCmdLine.Append(arg);
                                fullCmdLine.Append(" ");
                            }
                            continue;
                        }
                        break;

                    default:
                        break;
                    }
                }
                throw new CmdLineException(CmdLineError.UnknownOption, arg, engine.ErrorCultureInfo);
            }
            if (fullCmdLine != null)
            {
                // append target type to debug command line
                if (generateExe)
                {
                    if (generateWinExe)
                    {
                        fullCmdLine.Append(cmdLineSwitch + "t:winexe ");
                    }
                    else
                    {
                        fullCmdLine.Append(cmdLineSwitch + "t:exe ");
                    }
                }
                else
                {
                    fullCmdLine.Append(cmdLineSwitch + "t:library ");
                }
                this.debugCommandLine = fullCmdLine.ToString();
            }
            // set options on engine that were possibly built from multiple arguments
            engine.SetOption("libpath", libpath);
            engine.SetOption("defines", defines);
        }
Example #6
0
        private void ParseCompilerOptions(VsaEngine engine, StringCollection args, TextWriter output, bool generateExe)
        {
            string        environmentVariable = Environment.GetEnvironmentVariable("LIB");
            bool          flag          = false;
            Hashtable     defines       = new Hashtable(10);
            Hashtable     resources     = new Hashtable(10);
            Hashtable     resourceFiles = new Hashtable(10);
            bool          flag2         = false;
            StringBuilder builder       = null;

            if (this.debugCommandLine != null)
            {
                builder = new StringBuilder(this.debugCommandLine);
            }
            string str2  = (Path.DirectorySeparatorChar == '/') ? "-" : "/";
            int    num   = 0;
            int    count = args.Count;

            while (num < count)
            {
                object obj2;
                string str4 = args[num];
                if ((str4 == null) || (str4.Length == 0))
                {
                    goto Label_09C7;
                }
                if (str4[0] == '@')
                {
                    throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "@<filename>", engine.ErrorCultureInfo);
                }
                if (('-' != str4[0]) && (('/' != str4[0]) || (Path.DirectorySeparatorChar == '/')))
                {
                    break;
                }
                string option = str4.Substring(1);
                if (option.Length > 0)
                {
                    switch (option[0])
                    {
                    case '?':
                        throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/?", engine.ErrorCultureInfo);

                    case 'A':
                    case 'a':
                        goto Label_01DE;

                    case 'C':
                    case 'c':
                        goto Label_0223;

                    case 'D':
                    case 'd':
                        goto Label_024E;

                    case 'F':
                    case 'f':
                        goto Label_02F5;

                    case 'L':
                    case 'l':
                        goto Label_033A;

                    case 'N':
                    case 'n':
                        goto Label_0488;

                    case 'O':
                    case 'o':
                        goto Label_04DB;

                    case 'P':
                    case 'p':
                        goto Label_0506;

                    case 'R':
                    case 'r':
                        goto Label_0631;

                    case 'T':
                    case 't':
                        goto Label_06AD;

                    case 'U':
                    case 'u':
                        goto Label_07C8;

                    case 'V':
                    case 'v':
                        goto Label_07F3;

                    case 'W':
                    case 'w':
                        goto Label_0838;
                    }
                }
                goto Label_09B4;
Label_01DE:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "autoref");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                engine.SetOption("autoref", obj2);
                if (builder != null)
                {
                    builder.Append(str4);
                    builder.Append(" ");
                }
                goto Label_09C7;
Label_0223:
                if (CmdLineOptionParser.IsArgumentOption(option, "codepage") == null)
                {
                    goto Label_09B4;
                }
                throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/codepage:<id>", engine.ErrorCultureInfo);
Label_024E:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "debug");
                if (obj2 != null)
                {
                    engine.GenerateDebugInfo = (bool)obj2;
                    if (builder != null)
                    {
                        builder.Append(str4);
                        builder.Append(" ");
                    }
                }
                else
                {
                    obj2 = CmdLineOptionParser.IsArgumentOption(option, "d", "define");
                    if (obj2 == null)
                    {
                        goto Label_09B4;
                    }
                    this.GetAllDefines((string)obj2, defines, engine);
                    if (builder != null)
                    {
                        builder.Append(str2 + "d:\"");
                        builder.Append((string)obj2);
                        builder.Append("\" ");
                    }
                }
                goto Label_09C7;
Label_02F5:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "fast");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                engine.SetOption("fast", obj2);
                if (builder != null)
                {
                    builder.Append(str4);
                    builder.Append(" ");
                }
                goto Label_09C7;
Label_033A:
                obj2 = CmdLineOptionParser.IsArgumentOption(option, "lcid");
                if (obj2 != null)
                {
                    if (((string)obj2).Length == 0)
                    {
                        throw new CmdLineException(CmdLineError.NoLocaleID, str4, engine.ErrorCultureInfo);
                    }
                    try
                    {
                        engine.LCID = int.Parse((string)obj2, CultureInfo.InvariantCulture);
                        goto Label_09C7;
                    }
                    catch
                    {
                        throw new CmdLineException(CmdLineError.InvalidLocaleID, (string)obj2, engine.ErrorCultureInfo);
                    }
                }
                obj2 = CmdLineOptionParser.IsArgumentOption(option, "lib");
                if (obj2 != null)
                {
                    string str5 = (string)obj2;
                    if (str5.Length == 0)
                    {
                        throw new CmdLineException(CmdLineError.MissingLibArgument, engine.ErrorCultureInfo);
                    }
                    environmentVariable = str5.Replace(',', Path.PathSeparator) + Path.PathSeparator + environmentVariable;
                    if (builder != null)
                    {
                        builder.Append(str2 + "lib:\"");
                        builder.Append((string)obj2);
                        builder.Append("\" ");
                    }
                    goto Label_09C7;
                }
                obj2 = CmdLineOptionParser.IsArgumentOption(option, "linkres", "linkresource");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                try
                {
                    ResInfo resinfo = new ResInfo((string)obj2, true);
                    this.AddResourceFile(resinfo, resources, resourceFiles, engine);
                    goto Label_09C7;
                }
                catch (CmdLineException)
                {
                    throw;
                }
                catch
                {
                    throw new CmdLineException(CmdLineError.ManagedResourceNotFound, engine.ErrorCultureInfo);
                }
Label_0488:
                if (CmdLineOptionParser.IsBooleanOption(option, "nologo") != null)
                {
                    throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/nologo[+|-]", engine.ErrorCultureInfo);
                }
                if (CmdLineOptionParser.IsBooleanOption(option, "nostdlib") == null)
                {
                    goto Label_09B4;
                }
                throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/nostdlib[+|-]", engine.ErrorCultureInfo);
Label_04DB:
                if (CmdLineOptionParser.IsArgumentOption(option, "out") == null)
                {
                    goto Label_09B4;
                }
                throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/out:<filename>", engine.ErrorCultureInfo);
Label_0506:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "print");
                if (obj2 != null)
                {
                    engine.SetOption("print", obj2);
                    if (builder != null)
                    {
                        builder.Append(str4);
                        builder.Append(" ");
                    }
                }
                else
                {
                    PortableExecutableKinds iLOnly;
                    ImageFileMachine        machine;
                    obj2 = CmdLineOptionParser.IsArgumentOption(option, "platform");
                    if (obj2 == null)
                    {
                        goto Label_09B4;
                    }
                    string strA = (string)obj2;
                    if (string.Compare(strA, "x86", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        iLOnly  = PortableExecutableKinds.Required32Bit | PortableExecutableKinds.ILOnly;
                        machine = ImageFileMachine.I386;
                    }
                    else if (string.Compare(strA, "Itanium", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        iLOnly  = PortableExecutableKinds.PE32Plus | PortableExecutableKinds.ILOnly;
                        machine = ImageFileMachine.IA64;
                    }
                    else if (string.Compare(strA, "x64", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        iLOnly  = PortableExecutableKinds.PE32Plus | PortableExecutableKinds.ILOnly;
                        machine = ImageFileMachine.AMD64;
                    }
                    else
                    {
                        if (string.Compare(strA, "anycpu", StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            throw new CmdLineException(CmdLineError.InvalidPlatform, (string)obj2, engine.ErrorCultureInfo);
                        }
                        iLOnly  = PortableExecutableKinds.ILOnly;
                        machine = ImageFileMachine.I386;
                    }
                    engine.SetOption("PortableExecutableKind", iLOnly);
                    engine.SetOption("ImageFileMachine", machine);
                    if (builder != null)
                    {
                        builder.Append(str4);
                        builder.Append(" ");
                    }
                }
                goto Label_09C7;
Label_0631:
                if (CmdLineOptionParser.IsArgumentOption(option, "r", "reference") != null)
                {
                    throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/r[eference]:<file list>", engine.ErrorCultureInfo);
                }
                obj2 = CmdLineOptionParser.IsArgumentOption(option, "res", "resource");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                try
                {
                    ResInfo info2 = new ResInfo((string)obj2, false);
                    this.AddResourceFile(info2, resources, resourceFiles, engine);
                    goto Label_09C7;
                }
                catch (CmdLineException)
                {
                    throw;
                }
                catch
                {
                    throw new CmdLineException(CmdLineError.ManagedResourceNotFound, engine.ErrorCultureInfo);
                }
Label_06AD:
                obj2 = CmdLineOptionParser.IsArgumentOption(option, "t", "target");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                if (string.Compare((string)obj2, "exe", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (!generateExe)
                    {
                        throw new CmdLineException(CmdLineError.IncompatibleTargets, str4, engine.ErrorCultureInfo);
                    }
                    if (flag2)
                    {
                        throw new CmdLineException(CmdLineError.MultipleTargets, engine.ErrorCultureInfo);
                    }
                    flag2 = true;
                }
                else if (string.Compare((string)obj2, "winexe", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (!generateExe)
                    {
                        throw new CmdLineException(CmdLineError.IncompatibleTargets, str4, engine.ErrorCultureInfo);
                    }
                    if (flag2)
                    {
                        throw new CmdLineException(CmdLineError.MultipleTargets, engine.ErrorCultureInfo);
                    }
                    engine.SetOption("PEFileKind", PEFileKinds.WindowApplication);
                    flag  = true;
                    flag2 = true;
                }
                else
                {
                    if (string.Compare((string)obj2, "library", StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        throw new CmdLineException(CmdLineError.InvalidTarget, (string)obj2, engine.ErrorCultureInfo);
                    }
                    if (generateExe)
                    {
                        throw new CmdLineException(CmdLineError.IncompatibleTargets, engine.ErrorCultureInfo);
                    }
                    if (flag2)
                    {
                        throw new CmdLineException(CmdLineError.MultipleTargets, engine.ErrorCultureInfo);
                    }
                    flag2 = true;
                }
                goto Label_09C7;
Label_07C8:
                if (CmdLineOptionParser.IsArgumentOption(option, "utf8output") == null)
                {
                    goto Label_09B4;
                }
                throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/utf8output[+|-]", engine.ErrorCultureInfo);
Label_07F3:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "VersionSafe");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                engine.SetOption("VersionSafe", obj2);
                if (builder != null)
                {
                    builder.Append(str4);
                    builder.Append(" ");
                }
                goto Label_09C7;
Label_0838:
                obj2 = CmdLineOptionParser.IsArgumentOption(option, "w", "warn");
                if (obj2 != null)
                {
                    if (((string)obj2).Length == 0)
                    {
                        throw new CmdLineException(CmdLineError.NoWarningLevel, str4, engine.ErrorCultureInfo);
                    }
                    if (((string)obj2).Length == 1)
                    {
                        if (builder != null)
                        {
                            builder.Append(str4);
                            builder.Append(" ");
                        }
                        switch (((string)obj2)[0])
                        {
                        case '0':
                            engine.SetOption("WarningLevel", 0);
                            goto Label_09C7;

                        case '1':
                            engine.SetOption("WarningLevel", 1);
                            goto Label_09C7;

                        case '2':
                            engine.SetOption("WarningLevel", 2);
                            goto Label_09C7;

                        case '3':
                            engine.SetOption("WarningLevel", 3);
                            goto Label_09C7;

                        case '4':
                            engine.SetOption("WarningLevel", 4);
                            goto Label_09C7;
                        }
                    }
                    throw new CmdLineException(CmdLineError.InvalidWarningLevel, str4, engine.ErrorCultureInfo);
                }
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "warnaserror");
                if (obj2 != null)
                {
                    engine.SetOption("warnaserror", obj2);
                    if (builder != null)
                    {
                        builder.Append(str4);
                        builder.Append(" ");
                    }
                    goto Label_09C7;
                }
                if (CmdLineOptionParser.IsArgumentOption(option, "win32res") != null)
                {
                    throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/win32res:<filename>", engine.ErrorCultureInfo);
                }
Label_09B4:
                throw new CmdLineException(CmdLineError.UnknownOption, str4, engine.ErrorCultureInfo);
Label_09C7:
                num++;
            }
            if (builder != null)
            {
                if (generateExe)
                {
                    if (flag)
                    {
                        builder.Append(str2 + "t:winexe ");
                    }
                    else
                    {
                        builder.Append(str2 + "t:exe ");
                    }
                }
                else
                {
                    builder.Append(str2 + "t:library ");
                }
                this.debugCommandLine = builder.ToString();
            }
            engine.SetOption("libpath", environmentVariable);
            engine.SetOption("defines", defines);
        }