本文整理汇总了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);
}
}
示例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;
}
示例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;
}
}
示例4: ExecuteSourceUnit
internal static Scope ExecuteSourceUnit(SourceUnit/*!*/ sourceUnit) {
ScriptCode compiledCode = sourceUnit.Compile();
Scope scope = compiledCode.CreateScope();
compiledCode.Run(scope);
return scope;
}
示例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;
}