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


C# SourceUnit.Compile方法代码示例

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


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

示例1: ExecuteRubySourceUnit

        private void ExecuteRubySourceUnit(SourceUnit/*!*/ sourceUnit, Scope/*!*/ globalScope, LoadFlags flags) {
            Assert.NotNull(sourceUnit, globalScope);
            
            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile)) {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");
                compiledFile.CompiledCode.Run(globalScope);
            } else {
                Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");

                RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) {
                    IsIncluded = true,
                    IsWrapped = (flags & LoadFlags.LoadIsolated) != 0,
                };

                long ts1 = Stopwatch.GetTimestamp();
                ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);
                long ts2 = Stopwatch.GetTimestamp();
                Interlocked.Add(ref _ScriptCodeGenerationTimeTicks, ts2 - ts1);

                AddCompiledFile(fullPath, compiledCode);

                CompileAndRun(globalScope, compiledCode, _context.Options.InterpretedMode);
            }
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:27,代码来源:Loader.cs

示例2: ExecuteSourceUnit

 internal static PythonModule ExecuteSourceUnit(PythonContext context, SourceUnit/*!*/ sourceUnit) {
     ScriptCode compiledCode = sourceUnit.Compile();
     Scope scope = compiledCode.CreateScope();
     PythonModule res = ((PythonScopeExtension)context.EnsureScopeExtension(scope)).Module;
     compiledCode.Run(scope);
     return res;
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:Importer.cs

示例3: CompileRubySource

        private ScriptCode/*!*/ CompileRubySource(SourceUnit/*!*/ sourceUnit, LoadFlags flags) {
            Assert.NotNull(sourceUnit);
            
            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile)) {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");

                return compiledFile.CompiledCode;
            } else {
                Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");

                RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) {
                    FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.File
                };

                long ts1 = Stopwatch.GetTimestamp();
                ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);
                long ts2 = Stopwatch.GetTimestamp();
                Interlocked.Add(ref _ScriptCodeGenerationTimeTicks, ts2 - ts1);

                AddCompiledFile(fullPath, compiledCode);

                return compiledCode;
            }
        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:27,代码来源:Loader.cs

示例4: ExecuteSourceUnit

 internal static Scope ExecuteSourceUnit(SourceUnit/*!*/ sourceUnit) {
     ScriptCode compiledCode = sourceUnit.Compile();
     Scope scope = compiledCode.CreateScope();
     compiledCode.Run(scope);
     return scope;
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:6,代码来源:Importer.cs

示例5: CompileRubySource

        private ScriptCode/*!*/ CompileRubySource(SourceUnit/*!*/ sourceUnit, LoadFlags flags) {
            Assert.NotNull(sourceUnit);
            
            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);

#if FEATURE_FILESYSTEM
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile)) {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");

                return compiledFile.CompiledCode;
            } 

            Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");
#endif

            RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) {
                FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.File
            };

            ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);

#if FEATURE_FILESYSTEM
            AddCompiledFile(fullPath, compiledCode);
#endif
            return compiledCode;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:28,代码来源:Loader.cs


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