本文整理汇总了C#中Microsoft.Scripting.Interpreter.LightCompiler类的典型用法代码示例。如果您正苦于以下问题:C# LightCompiler类的具体用法?C# LightCompiler怎么用?C# LightCompiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LightCompiler类属于Microsoft.Scripting.Interpreter命名空间,在下文中一共展示了LightCompiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInstruction
public virtual Instruction GetInstruction(LightCompiler compiler) {
compiler.Compile(_context);
if (_isLocal) {
return new LookupNameInstruction(_name);
} else {
return new LookupGlobalNameInstruction(_name);
}
}
示例2: AddInstructions
public void AddInstructions(LightCompiler compiler) {
compiler.Compile(_target);
switch (Type.GetTypeCode(_binder.Type)) {
case TypeCode.Boolean:
compiler.Instructions.Emit(BooleanConversionInstruction.Instance);
break;
default:
compiler.Instructions.Emit(new TypedConversionInstruction(_binder.Type));
break;
}
}
示例3: 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);
}
}
示例4: AddInstructions
public void AddInstructions(LightCompiler compiler) {
Instruction instr = DynamicInstructionN.CreateUntypedInstruction(_binder, ArgumentCount);
if (instr == null) {
var lightBinder = _binder as ILightCallSiteBinder;
if (lightBinder == null || !lightBinder.AcceptsArgumentArray) {
compiler.Compile(Reduce());
return;
}
Debug.Assert(Type == typeof(object));
instr = new DynamicSplatInstruction(ArgumentCount, CallSite<Func<CallSite, ArgumentArray, object>>.Create(_binder));
}
for (int i = 0; i < ArgumentCount; i++) {
compiler.Compile(GetArgument(i));
}
compiler.Instructions.Emit(instr);
}
示例5: AddInstructions
public override void AddInstructions(LightCompiler compiler)
{
if (Argument0.Type == typeof(CodeContext))
{
compiler.Compile(Argument0);
compiler.Compile(Argument1);
compiler.Instructions.EmitDynamic<CodeContext, object, object>(Binder);
}
else if (Argument1.Type == typeof(CodeContext))
{
// GetMember sites
compiler.Compile(Argument0);
compiler.Compile(Argument1);
compiler.Instructions.EmitDynamic<object, CodeContext, object>(Binder);
}
else
{
base.AddInstructions(compiler);
}
}
示例6: GetExpression
internal override ParameterExpression GetExpression(LightCompiler compiler) {
return compiler.ClosureVariables[_index];
}
示例7: ToString
public override string ToString(LightCompiler compiler) {
return InstructionName + "(" + GetExpression(compiler).Name + ": " + _index + ")";
}
示例8: switch
void IInstructionProvider.AddInstructions(LightCompiler compiler) {
if (NeedComparisonTransformation()) {
// chained comparisons aren't supported for optimized light compiling
compiler.Compile(Reduce());
return;
}
switch (_op) {
case PythonOperator.Is:
compiler.Compile(_left);
compiler.Compile(_right);
compiler.Instructions.Emit(IsInstruction.Instance);
break;
case PythonOperator.IsNot:
compiler.Compile(_left);
compiler.Compile(_right);
compiler.Instructions.Emit(IsNotInstruction.Instance);
break;
default:
compiler.Compile(Reduce());
break;
}
}
示例9: GetDebugCookie
public virtual object GetDebugCookie(LightCompiler compiler) {
return null;
}
示例10: AddInstructions
public void AddInstructions(LightCompiler compiler) {
compiler.Instructions.EmitLoad(_value);
}
示例11: AddInstructions
public void AddInstructions(LightCompiler compiler)
{
compiler.Compile(_value);
compiler.Instructions.Emit(new TotemSetGlobalInstruction(_global.Global));
}
示例12: AddInstructions
public void AddInstructions(LightCompiler compiler) {
compiler.Instructions.Emit(MakeClosureCellInstruction.Instance);
}
示例13: if
void IInstructionProvider.AddInstructions(LightCompiler compiler) {
if (_value is bool) {
compiler.Instructions.EmitLoad((bool)_value);
} else if (_value is UnicodeWrapper) {
compiler.Instructions.EmitLoad(((UnicodeWrapper)_value).Value);
} else {
compiler.Instructions.EmitLoad(_value);
}
}
示例14: AddInstructions
public override void AddInstructions(LightCompiler compiler) {
if (Argument0.Type == typeof(CodeContext)) {
compiler.Compile(Argument0);
compiler.Compile(Argument1);
compiler.Compile(Argument2);
compiler.Compile(Argument3);
compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object>(Binder);
return;
} else {
base.AddInstructions(compiler);
}
}
示例15:
void IInstructionProvider.AddInstructions(LightCompiler compiler) {
// optimizing bool conversions does no good in the light compiler
compiler.Compile(ReduceWorker(false));
}