本文整理汇总了C#中Microsoft.Scripting.Interpreter.LightCompiler.CompileTop方法的典型用法代码示例。如果您正苦于以下问题:C# LightCompiler.CompileTop方法的具体用法?C# LightCompiler.CompileTop怎么用?C# LightCompiler.CompileTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Interpreter.LightCompiler
的用法示例。
在下文中一共展示了LightCompiler.CompileTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureCompiled
private void EnsureCompiled(bool optimized) {
//TODO too much duplicated code between these two blocks
if (optimized) {
if (_optimizedCode != null) return;
var rewriter = new LightGlobalRewriter();
var newLambda = rewriter.RewriteLambda(Code, Code.Name, LanguageContext, optimized);
_optimizedScope = rewriter.Scope;
var compiler = new LightCompiler();
var interpreter = compiler.CompileTop(newLambda);
_optimizedCode = new LightLambda(interpreter);
} else {
if (_code != null) return;
var rewriter = new LightGlobalRewriter();
var newLambda = rewriter.RewriteLambda(Code, Code.Name, LanguageContext, optimized);
var compiler = new LightCompiler();
var interpreter = compiler.CompileTop(newLambda);
_code = new LightLambda(interpreter);
}
}
示例2: CompileLambdaExpression
private void CompileLambdaExpression(Expression expr) {
var node = (LambdaExpression)expr;
var compiler = new LightCompiler(this);
var interpreter = compiler.CompileTop(node);
int[] closureBoxes = new int[compiler._closureVariables.Count];
for (int i = 0; i < closureBoxes.Length; i++) {
var closureVar = compiler._closureVariables[i];
AddInstruction(GetBoxedVariable(closureVar));
}
AddInstruction(new CreateDelegateInstruction(node.Type, interpreter, compiler._closureVariables.Count));
}