当前位置: 首页>>代码示例>>C#>>正文


C# Compiler.Compile方法代码示例

本文整理汇总了C#中Compiler.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.Compile方法的具体用法?C# Compiler.Compile怎么用?C# Compiler.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Compiler的用法示例。


在下文中一共展示了Compiler.Compile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compile

 public void Compile(ProgramGraph graph, CompilerOutputInfo info)
 {
     if (!(info is ShaderOutputInfo))
     return;
      ShaderOutputInfo outputInfo = info as ShaderOutputInfo;
      RegisterDict = new Dictionary<string, int>();
      for(int i = 0; i < graph.getMaxDepth(); i++)
      {
     foreach (Vertex v in graph.getVerticesForLayer(i))
     {
        foreach (NodeItem outputItem in v.Data.Items.Where(item => item.Output.Enabled))
        {
           if(outputItem.OutputData is ShaderTypes.sampler2D)
           {
              ShaderTypes.sampler2D Sampler = (ShaderTypes.sampler2D)outputItem.OutputData;
              if (!RegisterDict.ContainsKey(Sampler.path))
                 RegisterDict.Add(Sampler.path, RegisterDict.Count);
           }
        }
     }
      }
      mCompiler = new HLSLCompiler(new Dictionary<object, string>(), RegisterDict);
      WritePostFxScript(outputInfo);
      if (mCompiler == null)
     return;
      mCompiler.Compile(graph, outputInfo);
 }
开发者ID:RichardRanft,项目名称:CGF,代码行数:27,代码来源:T3DPostFxCompiler.cs

示例2: Main

 public static void Main(string[] args)
 {
     InputStream input = new InputStream("source.c");
     BytecodeStream output = new BytecodeStream();
     Compiler compiler = new Compiler();
     compiler.Compile(input, output);
 }
开发者ID:possientis,项目名称:Prog,代码行数:7,代码来源:facade.cs

示例3: button1_Click

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            compiler = new Compiler(new PsiNodeParser());

            compiler.Compile(psimulex.Text, "s", false, ProgramPart.Statement);

            ProgramString();
        }
开发者ID:hunpody,项目名称:psimulex,代码行数:8,代码来源:ImmediateWindow.xaml.cs

示例4: Work

        public void Work()
        {
            var store = new FakeStore();
            var service = new FakeService();

            var myTableTypeSchema = new DataTable("my-table-type");
            myTableTypeSchema.Columns.Add(new DataColumn("Id", typeof(int)) { AllowDBNull = false});
            myTableTypeSchema.Columns.Add(new DataColumn("RequiredBoolean", typeof(bool)) { AllowDBNull = false});
            myTableTypeSchema.Columns.Add(new DataColumn("OptionalBoolean", typeof(bool)) { AllowDBNull = true});

            var tableTypeSelector = new FakeTableTypeSelector("my-table-type");

            store.IxSchemasByTableTypeFullName[myTableTypeSchema.TableName] = myTableTypeSchema;

            var input = new FakeCompilerInput();
            input.TableTypeSelectors.Add(tableTypeSelector);

            {
                var contract = new FakeContract("IExplicitlyMappedInterface");
                contract.Properties.Add(new FakeContractProperty("Id", typeof(int)));
                contract.Properties.Add(new FakeContractProperty("RequiredBoolean", typeof(bool)));
                contract.Properties.Add(new FakeContractProperty("OptionalBoolean", typeof(bool?)));

                var mapping = new FakeDataRowContractMapping(contract.InterfaceName);
                mapping.FieldMappings.Add(new FakeDataFieldsMapping("Id", "Id"));
                mapping.FieldMappings.Add(new FakeDataFieldsMapping("RequiredBoolean", "RequiredBoolean"));
                mapping.FieldMappings.Add(new FakeDataFieldsMapping("OptionalBoolean", "OptionaldBoolean"));

                tableTypeSelector.Mappings.Add(mapping);
                input.Contracts.Add(contract);
            }

            {
                var contract = new FakeContract("IAutoMappableInterface");
                contract.Properties.Add(new FakeContractProperty("Id", typeof(int)));
                contract.Properties.Add(new FakeContractProperty("RequiredBoolean", typeof(bool)));
                contract.Properties.Add(new FakeContractProperty("OptionalBoolean", typeof(bool?)));
                tableTypeSelector.Mappings.Add(new FakeDataRowContractMapping(contract.InterfaceName));
                input.Contracts.Add(contract);
            }

            var compiler = new Compiler(store, service);

            var output = compiler.Compile(input, null, null);
            var tableTypeInfo = output.TableTypes.Single();

            Assert.Equal(0, tableTypeInfo.Columns[0].Ordinal);
            Assert.Equal("Id", tableTypeInfo.Columns[0].ColumnName, StringComparer.Ordinal);
            Assert.Equal(typeof(int), tableTypeInfo.Columns[0].DataType);

            Assert.Equal(1, tableTypeInfo.Columns[1].Ordinal);
            Assert.Equal("RequiredBoolean", tableTypeInfo.Columns[1].ColumnName, StringComparer.Ordinal);
            Assert.Equal(typeof(bool), tableTypeInfo.Columns[1].DataType);

            Assert.Equal(2, tableTypeInfo.Columns[2].Ordinal);
            Assert.Equal("OptionalBoolean", tableTypeInfo.Columns[2].ColumnName, StringComparer.Ordinal);
            Assert.Equal(typeof(bool?), tableTypeInfo.Columns[2].DataType);
        }
开发者ID:AlexeyEvlampiev,项目名称:Alenosoft,代码行数:58,代码来源:Compiler_Compile_Should.cs

示例5: TestMethod1

        public void TestMethod1()
        {
            Compiler compiler = new Compiler();
            string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            compiler.InputAssemblyPaths.Add(Path.Combine(dir, "Refraxion.Test.Data.dll"));
            RxProjectInfo projectInfo = compiler.Compile();

            projectInfo.Build(compiler);
            projectInfo.Write(compiler);
        }
开发者ID:automatonic,项目名称:refraxion,代码行数:10,代码来源:TestDataAssembly.cs

示例6: CompileFile

        static void CompileFile(string filePath)
        {
            var directory = Path.GetDirectoryName(filePath);
            var fileName = Path.GetFileNameWithoutExtension(filePath);

            var compiler = new Compiler(File.ReadAllText(filePath));

            compiler.ClassPath.Add(directory);

            File.WriteAllBytes(Path.Combine(directory, fileName + ".class"), compiler.Compile());
        }
开发者ID:will14smith,项目名称:JavaCompiler,代码行数:11,代码来源:Program.cs

示例7: CompileTestExcel

        public void CompileTestExcel()
        {
            var compiler = new Compiler(
                new CompilerConfig
                {
                    CodeTemplates = new Dictionary<string, string>()
                    {
                        {File.ReadAllText("./GenCode.cs.tpl"), "../../TabConfigs.cs"},  // code template -> CodePath
                    },
                    ExportTabExt = ".bytes",

                });
            Assert.IsTrue(compiler.Compile("./test_excel.xls"));
        }
开发者ID:dannisliang,项目名称:CosmosTable,代码行数:14,代码来源:CosmosConfiguratorCompilerTest.cs

示例8: Compile

        private string Compile(string sourceFile)
        {
            // Arrange.
            string outputFilePath = Path.Combine("Binaries", Path.GetFileNameWithoutExtension(sourceFile) + ".exe");
            var compiler = new Compiler(new CompilerOptions(sourceFile, "Test", outputFilePath));

            // Act.
            var result = compiler.Compile();

            // Assert.
            Assert.That(result, Is.True);

            return outputFilePath;
        }
开发者ID:tgjones,项目名称:mincamlsharp,代码行数:14,代码来源:CompilerTests.cs

示例9: ApplicationTest2

        public void ApplicationTest2()
        {
            Compiler TempCompiler = new Compiler(new[] { new GeneralParser() }, new[] { new GeneralOptimizer() }, new[] { new GeneralGenerator() }, new IValidator[] { new GeneralValidator(), new TypeValidator() });
            TempCompiler.Compile(new FileInfo(@"./TestingData/Application2.txt").Read(), @"./TestingData/ApplicationResult2.txt");
            Assert.Equal(@"namespace ASDF
            {
            using System;

            internal class Program
            {
            private static void Main(string[] args)
            {
            Number x = 1 + 2;
            String y = ""ASDF"" + (String)x;
            Number z = x * 23.51;
            String a = y + ""1234"";
            }
            }
            }", new FileInfo(@"./TestingData/ApplicationResult2.txt").Read());
        }
开发者ID:JaCraig,项目名称:PNZR,代码行数:20,代码来源:CompilerTests.cs

示例10: ApplicationTest3

        public void ApplicationTest3()
        {
            Compiler TempCompiler = new Compiler(new[] { new GeneralParser() }, new[] { new GeneralOptimizer() }, new[] { new GeneralGenerator() }, new IValidator[] { new GeneralValidator(), new TypeValidator() });
            TempCompiler.Compile(new FileInfo(@"./TestingData/Application3.txt").Read(), @"./TestingData/ApplicationResult3.txt");
            Assert.Equal(@"namespace ASDF
            {
            using System;

            internal class Program
            {
            private static void Main(string[] args)
            {
            Number x = 1 + 2;
            String y = ""ASDF"" + (String)x;
            Func<dynamic,dynamic> z = (dynamic x,dynamic y)=>{
            dynamic q = x + y;
            };
            }
            }
            }", new FileInfo(@"./TestingData/ApplicationResult3.txt").Read());
        }
开发者ID:JaCraig,项目名称:PNZR,代码行数:21,代码来源:CompilerTests.cs

示例11: Main

        static void Main(string[] args)
        {
            try {
                Settings settings = new Settings(args);
                Compiler comp = new Compiler(settings.DummyFile);

                comp.Compile(settings.InputFile);

                using (FileStream fs = new FileStream(settings.OutputFile, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    comp.SaveStream(fs);
                }
                Console.WriteLine("Done");
            }catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Usage: GLSLCompiler -i InputFile [-o OutputFile] [-d DummyFile]");
                Console.WriteLine("\t-i/--input:\t Specifies the input file to compile");
                Console.WriteLine("\t-o/--output:\t Specifies the output file for the compiled xnb");
                Console.WriteLine("\t-d/--dummy:\t Specifies a dummy file to use the xnb header from");
            }
        }
开发者ID:jvbsl,项目名称:MonoGame.GLSLCompiler,代码行数:22,代码来源:Program.cs

示例12: TestCompile

        public void TestCompile()
        {
            var compiler = new Compiler
            {
                ReferencedAssemblies = new[] { "System.dll" }
            };

            var code = "namespace Test"
                + "{"
                + "    public class Abc"
                + "    {"
                + "        public string Get()"
                + "        {"
                + "            return \"abc\";"
                + "        }"
                + "    }"
                + "}";

            var assembly = compiler.Compile(code);
            var type = assembly.GetType("Test.Abc");
            Assert.IsNotNull(type);
            Contract.Assume(type != null);

            var abc = Activator.CreateInstance(type);

            var method = type.GetMethod("Get");
            Assert.IsNotNull(method);
            Contract.Assume(method != null);

            var result = method.Invoke(abc, null);
            Assert.AreEqual("abc", result);
        }
开发者ID:tommyinb,项目名称:TommiUtility,代码行数:32,代码来源:Compiler.cs

示例13: CreateView

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private TinyView CreateView(IControllerContext context, IViewData data)
        {
            string templateName = context.ViewPath + ".tiny";
            Resource resource = _provider.Get(templateName);
            if (resource == null)
            {
                _logger.Warning("Failed to load " + templateName);
                return null;
            }

            // Add all namespaces and assemblies needed.
            var compiler = new Compiler();
            compiler.Add(typeof (IView));
            compiler.Add(typeof (string));
            compiler.Add(typeof (TextWriter));
            foreach (var parameter in data)
                compiler.Add(parameter.Value.GetType());

            using (resource.Stream)
            {
                var buffer = new byte[resource.Stream.Length];
                resource.Stream.Read(buffer, 0, buffer.Length);

                TextReader reader = new StreamReader(resource.Stream);
                var sb = new StringBuilder();

                // parse
                Parse(reader, sb);

                // and add it in the type.
                string code = ClassContents;
                code = code.Replace("{body}", sb.ToString());

                // add view data types.
                string types = string.Empty;
                foreach (var parameter in data)
                {
                    types = Compiler.GetTypeName(parameter.Value.GetType()) + " " + parameter.Key + " = (" +
                            Compiler.GetTypeName(parameter.Value.GetType()) + ")viewData[\"" + parameter.Key + "\"];";
                }
                code = code.Replace("{viewDataTypes}", types);

                try
                {
                    compiler.Compile(code);
                }
                catch (Exception err)
                {
                    _logger.Error("Failed to compile template " + templateName + ", reason: " + err);
                }
                return compiler.CreateInstance<TinyView>();
            }
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:59,代码来源:TinyViewEngine.cs

示例14: CompileSchemaInSet

#pragma warning restore 618

        internal void CompileSchemaInSet(XmlNameTable nameTable, ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings) {
            Debug.Assert(this.isPreprocessed);
            Compiler setCompiler = new Compiler(nameTable, eventHandler, null, compilationSettings);
            setCompiler.Prepare(this, true);
            this.isCompiledBySet = setCompiler.Compile();
        }
开发者ID:uQr,项目名称:referencesource,代码行数:8,代码来源:XmlSchema.cs

示例15: Run

        /// <summary>
        /// Main running method for the application.
        /// </summary>
        /// <param name="args">Commandline arguments to the application.</param>
        /// <returns>Returns the application error code.</returns>
        private int Run(string[] args)
        {
            try
            {
                FileInfo currentFile = null;

                // parse the command line
                this.ParseCommandLine(args);

                // exit if there was an error parsing the command line (otherwise the logo appears after error messages)
                if (this.messageHandler.FoundError)
                {
                    return this.messageHandler.PostProcess();
                }

                if (0 == this.sourceFiles.Count)
                {
                    this.showHelp = true;
                }
                else if (1 < this.sourceFiles.Count && null != this.outputFile)
                {
                    throw new ArgumentException("cannot specify more than one source file with single output file.  Either specify an output directory for the -out argument by ending the argument with a '\\' or remove the -out argument to have the source files compiled to the current directory.", "-out");
                }

                if (this.showLogo)
                {
                    Assembly candleAssembly = Assembly.GetExecutingAssembly();

                    Console.WriteLine("Microsoft (R) Windows Installer Xml Compiler version {0}", candleAssembly.GetName().Version.ToString());
                    Console.WriteLine("Copyright (C) Microsoft Corporation 2003. All rights reserved.");
                    Console.WriteLine();
                }
                if (this.showHelp)
                {
                    Console.WriteLine(" usage:  candle.exe [-?] [-nologo] [-out outputFile] sourceFile [sourceFile ...]");
                    Console.WriteLine();
                    Console.WriteLine("   -d<name>=<value>  define a parameter for the preprocessor");
                    Console.WriteLine("   -p<file>  preprocess to a file (or stdout if no file supplied)");
                    Console.WriteLine("   -I<dir>  add to include search path");
                    Console.WriteLine("   -nologo  skip printing candle logo information");
                    Console.WriteLine("   -out     specify output file (default: write to current directory)");
                    Console.WriteLine("   -pedantic:<level>  pedantic checks (levels: easy, heroic, legendary)");
                    Console.WriteLine("   -ss      suppress schema validation of documents (performance boost)");
                    Console.WriteLine("   -ust     use small table definitions (for backwards compatiblity)");
                    Console.WriteLine("   -trace   show source trace for errors, warnings, and verbose messages");
                    Console.WriteLine("   -ext     extension (class, assembly), should extend CompilerExtension");
                    Console.WriteLine("   -zs      only do validation of documents (no output)");
                    Console.WriteLine("   -wx      treat warnings as errors");
                    Console.WriteLine("   -w<N>    set the warning level (0: show all, 3: show none)");
                    Console.WriteLine("   -sw      suppress all warnings (same as -w3)");
                    Console.WriteLine("   -sw<N>   suppress warning with specific message ID");
                    Console.WriteLine("   -v       verbose output (same as -v2)");
                    Console.WriteLine("   -v<N>    sets the level of verbose output (0: most output, 3: none)");
                    Console.WriteLine("   -?       this help information");
                    Console.WriteLine();
                    Console.WriteLine("Common extensions:");
                    Console.WriteLine("   .wxs    - Windows installer Xml Source file");
                    Console.WriteLine("   .wxi    - Windows installer Xml Include file");
                    Console.WriteLine("   .wxl    - Windows installer Xml Localization file");
                    Console.WriteLine("   .wixobj - Windows installer Xml Object file (in XML format)");
                    Console.WriteLine("   .wixlib - Windows installer Xml Library file (in XML format)");
                    Console.WriteLine("   .wixout - Windows installer Xml Output file (in XML format)");
                    Console.WriteLine();
                    Console.WriteLine("   .msm - Windows installer Merge Module");
                    Console.WriteLine("   .msi - Windows installer Product Database");
                    Console.WriteLine("   .mst - Windows installer Transform");
                    Console.WriteLine("   .pcp - Windows installer Patch Creation Package");
                    Console.WriteLine();
                    Console.WriteLine("For more information see: http://wix.sourceforge.net");

                    return this.messageHandler.PostProcess();
                }

                // create the preprocessor and compiler
                Preprocessor preprocessor = new Preprocessor();
                preprocessor.Message += new MessageEventHandler(this.messageHandler.Display);
                for (int i = 0; i < this.includeSearchPaths.Count; ++i)
                {
                    preprocessor.IncludeSearchPaths.Add(this.includeSearchPaths[i]);
                }

                Compiler compiler = new Compiler(this.useSmallTables);
                compiler.Message += new MessageEventHandler(this.messageHandler.Display);
                compiler.PedanticLevel = this.pedanticLevel;
                compiler.SuppressValidate = this.suppressSchema;

                // load any extensions
                foreach (string extension in this.extensionList)
                {
                    Type extensionType = Type.GetType(extension);
                    if (null == extensionType)
                    {
                        throw new WixInvalidExtensionException(extension);
                    }

//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:101,代码来源:candle.cs


注:本文中的Compiler.Compile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。