Ejemplo n.º 1
0
        static void DisplayCompilerInfoForConfigLanguage(string configLanguage)
        {
            CompilerInfo info = CodeDomProvider.GetCompilerInfo(configLanguage);

            // Check whether there is a provider configured for this language.
            if (info.IsCodeDomProviderTypeValid)
            {
                // Get a provider instance using the configured type information.
                CodeDomProvider provider;
                provider = (CodeDomProvider)Activator.CreateInstance(info.CodeDomProviderType);

                // Display information about this language provider.
                Console.WriteLine("Language provider:  {0}",
                                  provider.ToString());
                Console.WriteLine();
                Console.WriteLine("  Default file extension:  {0}",
                                  provider.FileExtension);
                Console.WriteLine();

                // Get the compiler settings for this language.

                CompilerParameters langCompilerConfig = info.CreateDefaultCompilerParameters();

                Console.WriteLine("  Compiler options:        {0}",
                                  langCompilerConfig.CompilerOptions);
                Console.WriteLine("  Compiler warning level:  {0}",
                                  langCompilerConfig.WarningLevel);
            }
            else
            {
                // Tell the user that the language provider was not found.
                Console.WriteLine("There is no provider configured for input language \"{0}\".",
                                  configLanguage);
            }
        }
Ejemplo n.º 2
0
        static void DisplayCompilerInfoForLanguage(string language)
        {
            CodeDomProvider provider;

            // Check for a provider corresponding to the input language.
            if (CodeDomProvider.IsDefinedLanguage(language))
            {
                provider = CodeDomProvider.CreateProvider(language);

                // Display information about this language provider.

                Console.WriteLine("Language provider:  {0}",
                                  provider.ToString());
                Console.WriteLine();
                Console.WriteLine("  Default file extension:  {0}",
                                  provider.FileExtension);
                Console.WriteLine();

                // Get the compiler settings for this language.

                CompilerInfo       langCompilerInfo   = CodeDomProvider.GetCompilerInfo(language);
                CompilerParameters langCompilerConfig = langCompilerInfo.CreateDefaultCompilerParameters();

                Console.WriteLine("  Compiler options:        {0}",
                                  langCompilerConfig.CompilerOptions);
                Console.WriteLine("  Compiler warning level:  {0}",
                                  langCompilerConfig.WarningLevel);
            }
            else
            {
                // Tell the user that the language provider was not found.
                Console.WriteLine("There is no provider configured for input language \"{0}\".",
                                  language);
            }
        }
Ejemplo n.º 3
0
        // Constructor
        public NodesCompiler(CompilerInfo info) : base(info, true)
        {
            // Initialize

            // We have no destructor
            GC.SuppressFinalize(this);
        }
Ejemplo n.º 4
0
        private static string GetCompilerInfo(CompilerInfo compilerInfo)
        {
            var output   = new StringBuilder();
            var language = compilerInfo.GetLanguages()[0];

            output.AppendFormat("{0} features{1}", language, Environment.NewLine);

            try
            {
                var provider = CodeDomProvider.CreateProvider(language);
                output.AppendFormat("CaseInsensitive = {0}{1}",
                                    provider.LanguageOptions.HasFlag(LanguageOptions.CaseInsensitive), Environment.NewLine);
                var genSupport = Enum.GetValues(typeof(GeneratorSupport))
                                 .Cast <GeneratorSupport>()
                                 .Aggregate(string.Empty,
                                            (current, supportableFeature) =>
                                            current + $"{supportableFeature} = {provider.Supports(supportableFeature)}{Environment.NewLine}");
                output.Append(genSupport);
            }
            catch (ConfigurationErrorsException configErrorsEx)
            {
                output.Append(configErrorsEx.Message);
            }

            return(output.ToString());
        }
Ejemplo n.º 5
0
        private static void DetectCompiler()
        {
            // Detect CXX from environment varibles
            string compilerCommand = Environment.GetEnvironmentVariable("CXX");
            if (compilerCommand != null)
            {
				string outputArg = Environment.GetEnvironmentVariable("OUTPUTARG");
				if (outputArg == null)
				{
					outputArg = "-o";
				}
				compiler = new CompilerInfo {
					Command=compilerCommand,
					AdditionalArgs="",
					OutputArg=outputArg
				};
                return;
            }
            // Try clang++ g++ and cl
            string suffix = ".exe";
            if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                suffix = string.Empty;
            }
			foreach (var compilerInfo in compilers)
			{
				compilerCommand = GetFullPath(compilerInfo.Command + suffix);
				if (compilerCommand != null)
				{
					compiler = compilerInfo;
					return;
				}
			}
            Program.Panic("No compiler detected on your system. You should specify one by using environment varible CXX.");
        }
Ejemplo n.º 6
0
        public override object GetValue(NodePort port)
        {
            var ctx      = Context.GetContext();
            var function = ctx.GetFunction(GetFunctionName());

            if (function == null)
            {
                return(null);
            }
            IEnumerable <string> inputs;

            if (function.Inputs == null)
            {
                inputs = Enumerable.Range(0, GetVaradicCount())
                         .Select(i => $"${i}");
            }
            else
            {
                inputs = function.Inputs.Select(p => p.Name);
            }
            var arguments = inputs
                            .Select(i => (GetInputPort(i).GetInputValue() as ElementNodeValue)?.Value)
                            .ToArray();

            if (arguments.Any(a => a == null))
            {
                return(null);
            }
            var info = new CompilerInfo {
            };

            return(new ElementNodeValue {
                Value = function.Call(arguments, info)
            });
        }
        private string GenerateCompilersReport(CompilerInfo[] compilers, string[] keywords)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("Used Keywords:").Append(',').Append(string.Join(";", keywords)).Append('\n')
            .Append('\n')
            .Append("GraphicsTier").Append(',')
            .Append("ShaderCompilerPlatform").Append(',')
            .Append("ShaderRequirements").Append(',')
            .Append("Keywords").Append(',')
            .Append("PlatformKeywords").Append('\n');

            for (int iCompiler = 0; iCompiler < compilers.Length; iCompiler++)
            {
                CompilerInfo compiler = compilers[iCompiler];
                stringBuilder.Append(compiler.GraphicsTier).Append(',')
                .Append(compiler.ShaderCompilerPlatform).Append(',')
                .Append(compiler.ShaderRequirements.ToString().Replace(',', ';')).Append(',')
                .Append(string.Join(";", compiler.Keywords)).Append(',')
                .Append(string.Join(";", compiler.PlatformKeywords)).Append(',')
                .Append('\n');
            }

            return(stringBuilder.ToString());
        }
Ejemplo n.º 8
0
        public void GetExtensions_Invoke_ReturnsExpected(string language, string[] extensions)
        {
            CompilerInfo compilerInfo = CodeDomProvider.GetCompilerInfo(language);

            Assert.Equal(extensions, compilerInfo.GetExtensions());
            Assert.NotSame(compilerInfo.GetExtensions(), compilerInfo.GetExtensions());
        }
Ejemplo n.º 9
0
        public static string getCompilerStr()
        {
            CompilerInfo info      = CodeDomProvider.GetCompilerInfo("CSharp");
            var          dotnetver = info.CodeDomProviderType.Assembly.ImageRuntimeVersion;

            return(dotnetver);
        }
Ejemplo n.º 10
0
        internal static CodeDomProvider CreateProvider(HttpContext context, string lang, out CompilerParameters par, out string tempdir)
        {
            CodeDomProvider ret = null;

            par = null;

            CompilationSection config = (CompilationSection)WebConfigurationManager.GetWebApplicationSection("system.web/compilation");
            Compiler           comp   = config.Compilers[lang];

            if (comp == null)
            {
                CompilerInfo info = CodeDomProvider.GetCompilerInfo(lang);
                if (info != null && info.IsCodeDomProviderTypeValid)
                {
                    ret = info.CreateProvider();
                    par = info.CreateDefaultCompilerParameters();
                }
            }
            else
            {
                Type t = HttpApplication.LoadType(comp.Type, true);
                ret = Activator.CreateInstance(t) as CodeDomProvider;

                par = new CompilerParameters();
                par.CompilerOptions = comp.CompilerOptions;
                par.WarningLevel    = comp.WarningLevel;
            }
            tempdir = config.TempDirectory;

            return(ret);
        }
Ejemplo n.º 11
0
        internal CompilerType GetCompilerInfoFromExtension(string extension, bool throwOnFail)
        {
            CompilerType compilerTypeInternal;

            this.EnsureCompilerCacheInit();
            object   obj2     = this._compilerExtensions[extension];
            Compiler compiler = obj2 as Compiler;

            if (compiler != null)
            {
                compilerTypeInternal = compiler.CompilerTypeInternal;
                this._compilerExtensions[extension] = compilerTypeInternal;
            }
            else
            {
                compilerTypeInternal = obj2 as CompilerType;
            }
            if ((compilerTypeInternal == null) && CodeDomProvider.IsDefinedExtension(extension))
            {
                CompilerInfo compilerInfo = CodeDomProvider.GetCompilerInfo(CodeDomProvider.GetLanguageFromExtension(extension));
                compilerTypeInternal = new CompilerType(compilerInfo.CodeDomProviderType, compilerInfo.CreateDefaultCompilerParameters());
                this._compilerExtensions[extension] = compilerTypeInternal;
            }
            if (compilerTypeInternal == null)
            {
                if (throwOnFail)
                {
                    throw new HttpException(System.Web.SR.GetString("Invalid_lang_extension", new object[] { extension }));
                }
                return(null);
            }
            compilerTypeInternal = compilerTypeInternal.Clone();
            compilerTypeInternal.CompilerParameters.IncludeDebugInformation = this.Debug;
            return(compilerTypeInternal);
        }
Ejemplo n.º 12
0
        internal CompilerType GetCompilerInfoFromLanguage(string language)
        {
            CompilerType compilerTypeInternal;

            this.EnsureCompilerCacheInit();
            object   obj2     = this._compilerLanguages[language];
            Compiler compiler = obj2 as Compiler;

            if (compiler != null)
            {
                compilerTypeInternal = compiler.CompilerTypeInternal;
                this._compilerLanguages[language] = compilerTypeInternal;
            }
            else
            {
                compilerTypeInternal = obj2 as CompilerType;
            }
            if ((compilerTypeInternal == null) && CodeDomProvider.IsDefinedLanguage(language))
            {
                CompilerInfo compilerInfo = CodeDomProvider.GetCompilerInfo(language);
                compilerTypeInternal = new CompilerType(compilerInfo.CodeDomProviderType, compilerInfo.CreateDefaultCompilerParameters());
                this._compilerLanguages[language] = compilerTypeInternal;
            }
            if (compilerTypeInternal == null)
            {
                throw new HttpException(System.Web.SR.GetString("Invalid_lang", new object[] { language }));
            }
            CompilationUtil.CheckCompilerOptionsAllowed(compilerTypeInternal.CompilerParameters.CompilerOptions, true, null, 0);
            compilerTypeInternal = compilerTypeInternal.Clone();
            compilerTypeInternal.CompilerParameters.IncludeDebugInformation = this.Debug;
            return(compilerTypeInternal);
        }
Ejemplo n.º 13
0
        internal static IDictionary <string, string> GetProviderOptionsCollection(string fileExt)
        {
            Dictionary <string, string> opts = new Dictionary <string, string>();

            if (!CodeDomProvider.IsDefinedExtension(fileExt))
            {
                return(new ReadOnlyDictionary <string, string>(opts));
            }

            CompilerInfo ci = CodeDomProvider.GetCompilerInfo(CodeDomProvider.GetLanguageFromExtension(fileExt));

            if (ci == null)
            {
                return(new ReadOnlyDictionary <string, string>(opts));
            }

            // There is a fun little comment about this property in the framework code about making it
            // public after 3.5. Guess that didn't happen. Oh well. :)
            PropertyInfo pi = ci.GetType().GetProperty("ProviderOptions",
                                                       BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance);

            if (pi == null)
            {
                return(new ReadOnlyDictionary <string, string>(opts));
            }

            return(new ReadOnlyDictionary <string, string>((IDictionary <string, string>)pi.GetValue(ci, null)));
        }
Ejemplo n.º 14
0
 public void Equals_Invoke_ReturnsExpected(CompilerInfo compilerInfo, object other, bool expected)
 {
     Assert.Equal(expected, compilerInfo.Equals(other));
     if (other is CompilerInfo)
     {
         Assert.Equal(expected, compilerInfo.GetHashCode().Equals(other.GetHashCode()));
     }
 }
Ejemplo n.º 15
0
        /*
         * Return a CompilerType that a extension maps to.
         */
        internal CompilerType GetCompilerInfoFromExtension(string extension, bool throwOnFail)
        {
            EnsureCompilerCacheInit();

            // First, try the cache (i.e. old <compilers> section)
            CompilerType compilerType;
            object       obj      = _compilerExtensions[extension];
            Compiler     compiler = obj as Compiler;

            if (compiler != null)
            {
                compilerType = compiler.CompilerTypeInternal;
                _compilerExtensions[extension] = compilerType;
            }
            else
            {
                compilerType = obj as CompilerType;
            }

            if (compilerType == null)
            {
                // If not, try the <codedom> section

                if (CodeDomProvider.IsDefinedExtension(extension))
                {
                    string language = CodeDomProvider.GetLanguageFromExtension(extension);

                    CompilerInfo ci = CodeDomProvider.GetCompilerInfo(language);

                    compilerType = new CompilerType(
                        ci.CodeDomProviderType, ci.CreateDefaultCompilerParameters());

                    // Cache it
                    _compilerExtensions[extension] = compilerType;
                }
            }

            if (compilerType == null)
            {
                if (!throwOnFail)
                {
                    return(null);
                }

                // Unsupported extension: throw an exception
                throw new HttpException(SR.GetString(SR.Invalid_lang_extension, extension));
            }

            // Clone it so the original is not modified
            compilerType = compilerType.Clone();

            // Set the value of the debug flag in the copy
            compilerType.CompilerParameters.IncludeDebugInformation = Debug;

            return(compilerType);
        }
Ejemplo n.º 16
0
        // This creates a compiler by interface name
        internal static Compiler Create(CompilerInfo info)
        {
            Compiler result;

            // Make list of assemblies to search in
            List <Assembly> asms = General.Plugins.GetPluginAssemblies();

            asms.Add(General.ThisAssembly);

            // Constructor arguments
            object[] args = new object[1];
            args[0] = info;

            try
            {
                // Go for all assemblies
                foreach (Assembly a in asms)
                {
                    Type[] types;

                    // Find the class
                    if (a == General.ThisAssembly)
                    {
                        types = a.GetTypes();
                    }
                    else
                    {
                        types = a.GetExportedTypes();
                    }

                    foreach (Type t in types)
                    {
                        if (t.IsSubclassOf(typeof(Compiler)) && (t.Name == info.ProgramInterface))
                        {
                            // Create instance
                            result = (Compiler)a.CreateInstance(t.FullName, false, BindingFlags.Default,
                                                                null, args, CultureInfo.CurrentCulture, new object[0]);
                            return(result);
                        }
                    }
                }
            }
            // Catch errors
            catch (TargetInvocationException e)
            {
                // Throw the actual exception
                Debug.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
                Debug.WriteLine(e.InnerException.Source + " throws " + e.InnerException.GetType().Name + ":");
                Debug.WriteLine(e.InnerException.Message);
                Debug.WriteLine(e.InnerException.StackTrace);
                throw e.InnerException;
            }

            // No such compiler
            return(null);
        }
Ejemplo n.º 17
0
        private static IDictionary <string, string> GetProviderOptions(CompilerInfo ci)
        {
            PropertyInfo property = ci.GetType().GetProperty("ProviderOptions", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);

            if (property != null)
            {
                return((IDictionary <string, string>)property.GetValue(ci, null));
            }
            return(null);
        }
Ejemplo n.º 18
0
        public CompilerInfo GetCompilerInfo()
        {
            if (datamake == null)
            {
                return(null);
            }
            CompilerInfo ci = datamake.GetCompilerInfo();

            return(ci);
        }
Ejemplo n.º 19
0
        public CompilerInfo FindWordsInsideSyntax()
        {
            CompilerInfo info = FillWordsInsideSyntax.Invoke(InputInsideSyntax);

            if (info.Errors.Count == 0)
            {
                WordsInsideSyntax = info.Lexemes;
            }
            return(info);
        }
Ejemplo n.º 20
0
        public void OnGUI(string name, IFunction value, CompilerInfo info, Action <string, IFunction> drawOther)
        {
            EditorGUILayout.LabelField(name);
            EditorGUI.indentLevel++;
            foreach (var o in value.Outputs)
            {
                drawOther(o.Name, value.Call(o.Name, info));
            }

            EditorGUI.indentLevel--;
        }
        /// <summary>
        /// 生成CompilerInfo
        /// </summary>
        private CompilerInfo GenerateCompilerInfo(ShaderCompilerData data)
        {
            CompilerInfo compilerInfo = new CompilerInfo();

            compilerInfo.Keywords               = ConvertToKeywords(data.shaderKeywordSet);
            compilerInfo.PlatformKeywords       = ConvertToPlatformKeywords(data.platformKeywordSet);
            compilerInfo.ShaderRequirements     = data.shaderRequirements;
            compilerInfo.GraphicsTier           = data.graphicsTier;
            compilerInfo.ShaderCompilerPlatform = data.shaderCompilerPlatform;
            return(compilerInfo);
        }
Ejemplo n.º 22
0
        /*
         * Return a CompilerType that a language maps to.
         */
        internal CompilerType GetCompilerInfoFromLanguage(string language)
        {
            EnsureCompilerCacheInit();

            // First, try the cache (i.e. old <compilers> section)
            CompilerType compilerType;
            object       obj      = _compilerLanguages[language];
            Compiler     compiler = obj as Compiler;

            if (compiler != null)
            {
                compilerType = compiler.CompilerTypeInternal;
                _compilerLanguages[language] = compilerType;
            }
            else
            {
                compilerType = obj as CompilerType;
            }

            if (compilerType == null)
            {
                // Try the <codedom> section

                if (CodeDomProvider.IsDefinedLanguage(language))
                {
                    CompilerInfo ci = CodeDomProvider.GetCompilerInfo(language);

                    compilerType = new CompilerType(ci.CodeDomProviderType,
                                                    ci.CreateDefaultCompilerParameters());

                    // Cache it
                    _compilerLanguages[language] = compilerType;
                }
            }

            if (compilerType == null)
            {
                // Unsupported language: throw an exception
                throw new HttpException(SR.GetString(SR.Invalid_lang, language));
            }

            // Only allow the use of compilerOptions when we have UnmanagedCode access (ASURT 73678)
            CompilationUtil.CheckCompilerOptionsAllowed(compilerType.CompilerParameters.CompilerOptions,
                                                        true /*config*/, null, 0);

            // Clone it so the original is not modified
            compilerType = compilerType.Clone();

            // Set the value of the debug flag in the copy
            compilerType.CompilerParameters.IncludeDebugInformation = Debug;

            return(compilerType);
        }
Ejemplo n.º 23
0
        public WordScriptExecuter(string language, string codeText, List<string> namespaces)
        {
            Language = language;
            _namespaces = namespaces;
            _rootClassName = "AutomationKoboScript" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
            _codeText = codeText;

            _compilerInfo = CreateCompilerInfo(Language);

            _compiler = _compilerInfo.Compiler;
            _parameters = new CompilerParameters {GenerateExecutable = false, GenerateInMemory = true, MainClass = _rootClassName};
        }
Ejemplo n.º 24
0
        private static IDictionary <string, string> GetProviderOptions(CompilerInfo ci)
        {
            Debug.Assert(ci != null, "CompilerInfo ci should not be null");
            PropertyInfo pi = ci.GetType().GetProperty("ProviderOptions",
                                                       BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance);

            if (pi != null)
            {
                return((IDictionary <string, string>)pi.GetValue(ci, null));
            }
            return(null);
        }
Ejemplo n.º 25
0
        private string GetLanguageName(CompilerInfo compilerInfo)
        {
            Regex alphaNumeric = new Regex("^[0-9a-zA-Z]+$");

            foreach (string name in compilerInfo.GetLanguages())
            {
                if (alphaNumeric.IsMatch(name))
                {
                    return(name);
                }
            }
            return("script" + (++assemblyCounter).ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 26
0
        public void InitDriver(
            string fileName
            , Action <ChipDatum> OPL4Write
            , Action <long, int> OPL4WaitSend
            , musicDriverInterface.MmlDatum[] mdrBuf
            , ChipRegister chipRegister
            )
        {
            musicDriverInterface.Log.writeMethod = disp;
            musicDriverInterface.Log.off         = 0;
            setting           = Audio.setting;
            this.chipRegister = chipRegister;

            int jumpIndex = -1;

            if (compiler != null)
            {
                CompilerInfo ci = compiler.GetCompilerInfo();
                if (ci.jumpClock != -1)
                {
                    jumpIndex = ci.jumpClock;
                }
            }

            object addtionalMoonDriverDotNETOption = new object[] {
                fileName,//string srcFile;
                (Func <string, Stream>)appendFileReaderCallback,
                Common.SampleRate,
                jumpIndex
            };

            object[] addOp = new object[] {
                fileName,
                //(Func<string, Stream>)appendFileReaderCallback,
                (double)Common.SampleRate,
                jumpIndex
            };

            List <ChipAction>    lca = new List <ChipAction>();
            MoonDriverChipAction ca  = new MoonDriverChipAction(OPL4Write); lca.Add(ca);

            driver.Init(
                //fileName
                //, OPL4Write
                lca
                , mdrBuf
                , appendFileReaderCallback
                //,OPL4WaitSend
                , addOp
                );
        }
Ejemplo n.º 27
0
        public ScriptClass(string ns, CompilerInfo compilerInfo)
        {
            this.ns                  = ns;
            this.compilerInfo        = compilerInfo;
            this.refAssemblies       = new StringCollection();
            this.nsImports           = new StringCollection();
            this.typeDecl            = new CodeTypeDeclaration(GenerateUniqueClassName());
            this.refAssembliesByHref = false;
            this.scriptUris          = new Dictionary <string, string>(
#if !FEATURE_CASE_SENSITIVE_FILESYSTEM
                StringComparer.OrdinalIgnoreCase
#endif
                );
        }
Ejemplo n.º 28
0
        public override object GetValue(NodePort port)
        {
            var ctx   = Context.GetContext();
            var info  = new CompilerInfo {
            };
            var iface = ctx.GetType(Type, info);
            int idx   = 0;
            Func <Expression> getNextValue = () => idx < TestValue.Length
                                ? new Constant(TestValue[idx++]) : Constant.Zero;

            return(new ElementNodeValue {
                Value = iface.Deserialize(getNextValue)
            });
        }
Ejemplo n.º 29
0
        internal static IDictionary <string, string> GetProviderOptions(Type codeDomProviderType)
        {
            // Using reflection to get the property for the time being.
            // This could simply return CompilerInfo.PropertyOptions if it goes public in future.
            CodeDomProvider provider  = (CodeDomProvider)Activator.CreateInstance(codeDomProviderType);
            string          extension = provider.FileExtension;

            if (CodeDomProvider.IsDefinedExtension(extension))
            {
                CompilerInfo ci = CodeDomProvider.GetCompilerInfo(CodeDomProvider.GetLanguageFromExtension(extension));
                return(GetProviderOptions(ci));
            }
            return(null);
        }
Ejemplo n.º 30
0
        static void DisplayCompilerInfoUsingExtension(string fileExtension)
        {
            // <Snippet5>
            if (fileExtension[0] != '.')
            {
                fileExtension = "." + fileExtension;
            }

            // Get the language associated with the file extension.
            if (CodeDomProvider.IsDefinedExtension(fileExtension))
            {
                CodeDomProvider provider;
                String          language = CodeDomProvider.GetLanguageFromExtension(fileExtension);

                Console.WriteLine("The language \"{0}\" is associated with file extension \"{1}\"",
                                  language, fileExtension);
                Console.WriteLine();

                // Next, check for a corresponding language provider.

                if (CodeDomProvider.IsDefinedLanguage(language))
                {
                    provider = CodeDomProvider.CreateProvider(language);

                    // Display information about this language provider.

                    Console.WriteLine("Language provider:  {0}",
                                      provider.ToString());
                    Console.WriteLine();

                    // Get the compiler settings for this language.

                    CompilerInfo       langCompilerInfo   = CodeDomProvider.GetCompilerInfo(language);
                    CompilerParameters langCompilerConfig = langCompilerInfo.CreateDefaultCompilerParameters();

                    Console.WriteLine("  Compiler options:        {0}",
                                      langCompilerConfig.CompilerOptions);
                    Console.WriteLine("  Compiler warning level:  {0}",
                                      langCompilerConfig.WarningLevel);
                }
            }
            else
            {
                // Tell the user that the language provider was not found.
                Console.WriteLine("There is no language provider associated with input file extension \"{0}\".",
                                  fileExtension);
            }
            // </Snippet5>
        }
Ejemplo n.º 31
0
        public override object GetValue(NodePort port)
        {
            var function = Object.Value;

            if (function == null)
            {
                return(null);
            }
            var info = new CompilerInfo {
            };

            return(new ElementNodeValue {
                Value = function.Call(port.fieldName, info)
            });
        }
Ejemplo n.º 32
0
        // Constructor
        public Compiler(CompilerInfo info)
        {
            // Initialize
            this.info   = info;
            this.errors = new List <CompilerError>();

            General.WriteLogLine("Creating compiler '" + info.Name + "' on interface '" + this.GetType().Name + "'...");

            // Create temporary directory
            tempdir    = Directory.CreateDirectory(General.MakeTempDirname());
            workingdir = tempdir.FullName;

            // Copy required files to the temp directory
            General.WriteLogLine("Copying required files for compiler...");
            CopyRequiredFiles();
        }
        public bool CompileSource(GenericDirectory Directory, CompilerInfo cInfo)
        {
            foreach (string asmReference in cInfo.ReferencedAssemblies)
                cmpParams.ReferencedAssemblies.Add(asmReference);

            if (cInfo.EmbeddedResources.Count > 0)
                cmpParams.EmbeddedResources.AddRange(cInfo.EmbeddedResources.ToArray());

            if (cInfo.GenerateExe)
            {
                cmpParams.CompilerOptions += string.Concat(" ", "/target:winexe", " ");
                cmpParams.GenerateExecutable = true;
            }

            if (cInfo.GenerateLibrary)
            {
                cmpParams.CompilerOptions += string.Concat(" ", "/target:library", " ");
                cmpParams.GenerateExecutable = false;
            }

            if (cInfo.ExCompilerOptions.Count > 0)
                foreach (string cmpSwitch in cInfo.ExCompilerOptions)
                    cmpParams.CompilerOptions += string.Concat(" ", cmpSwitch, " ");

            if (!string.IsNullOrEmpty(cInfo.IconPath))
                cmpParams.CompilerOptions += string.Concat(" \"/win32icon:", cInfo.IconPath, "\" ");

            cmpParams.OutputAssembly = cInfo.OutputDestination;

            CompilerResults cmpResults = csharpProvider.CompileAssemblyFromFile(
                cmpParams,
                new List<string>(Directory.Source.Files.Values).ToArray());

#if DEBUG
            if (cmpResults.Errors.HasErrors)
                foreach (var err in cmpResults.Errors)
                    Console.WriteLine(err.ToString());
#endif

            if (cmpResults.NativeCompilerReturnValue != 0)
                return false;

            return true;
        }