本文整理汇总了C#中Microsoft.Scripting.Interpreter.LightCompiler.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# LightCompiler.Compile方法的具体用法?C# LightCompiler.Compile怎么用?C# LightCompiler.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Scripting.Interpreter.LightCompiler
的用法示例。
在下文中一共展示了LightCompiler.Compile方法的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) {
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);
}
示例3: 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;
}
}
示例4: 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);
}
}
示例5: AddInstructions
public void AddInstructions(LightCompiler compiler)
{
compiler.Compile(FunctionDefinition._functionParam);
compiler.Instructions.Emit(GetLocalClosureFromFunctionInstruction.Instance);
}
示例6: AddInstructions
public override void AddInstructions(LightCompiler compiler) {
if (ArgumentCount > 15) {
compiler.Compile(Reduce());
} else if (GetArgument(0).Type == typeof(CodeContext)) {
for (int i = 0; i < ArgumentCount; i++) {
compiler.Compile(GetArgument(i));
}
switch(ArgumentCount) {
case 1: compiler.Instructions.EmitDynamic<CodeContext, object>(Binder); break;
case 2: compiler.Instructions.EmitDynamic<CodeContext, object, object>(Binder); break;
case 3: compiler.Instructions.EmitDynamic<CodeContext, object, object, object>(Binder); break;
case 4: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object>(Binder); break;
case 5: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object>(Binder); break;
case 6: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object>(Binder); break;
case 7: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object>(Binder); break;
case 8: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object>(Binder); break;
case 9: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object>(Binder); break;
case 10: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object>(Binder); break;
case 11: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
case 12: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
case 13: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
case 14: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
case 15: compiler.Instructions.EmitDynamic<CodeContext, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object>(Binder); break;
}
} else {
base.AddInstructions(compiler);
}
}
示例7: 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;
}
}
示例8: CreateFunctionInstructions
private void CreateFunctionInstructions(LightCompiler compiler) {
// emit context if we have a special local context
CodeContext globalContext = null;
// potential optimization to avoid loading the context:
/*if (Parent.LocalContext == PythonAst._globalContext) {
globalContext = GlobalParent.ModuleContext.GlobalContext;
} else*/ {
compiler.Compile(Parent.LocalContext);
}
// emit name if necessary
PythonGlobalVariableExpression name = GetVariableExpression(_nameVariable) as PythonGlobalVariableExpression;
PythonGlobal globalName = null;
if (name == null) {
compiler.Compile(((IPythonGlobalExpression)GetVariableExpression(_nameVariable)).RawValue());
} else {
globalName = name.Global;
}
// emit defaults
int defaultCount = 0;
for (int i = _parameters.Length - 1; i >= 0; i--) {
var param = _parameters[i];
if (param.DefaultValue != null) {
compiler.Compile(AstUtils.Convert(param.DefaultValue, typeof(object)));
defaultCount++;
}
}
compiler.Instructions.Emit(new FunctionDefinitionInstruction(globalContext, this, defaultCount, globalName));
}
示例9: AddInstructions
public void AddInstructions(LightCompiler compiler)
{
compiler.Compile(FunctionDefinition._functionParam);
compiler.Instructions.Emit(GetParentContextFromFunctionInstruction.Instance);
}
示例10: switch
void IInstructionProvider.AddInstructions(LightCompiler compiler) {
if (_target is NameExpression && ((NameExpression)_target).Name == "unicode") {
compiler.Compile(Reduce());
return;
}
for (int i = 0; i < _args.Length; i++) {
if (!_args[i].GetArgumentInfo().IsSimple) {
compiler.Compile(Reduce());
return;
}
}
switch (_args.Length) {
#region Generated Python Call Expression Instruction Switch
// *** BEGIN GENERATED CODE ***
// generated by function: gen_call_expression_instruction_switch from: generate_calls.py
case 0:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Instructions.Emit(new Invoke0Instruction(Parent.PyContext));
return;
case 1:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Compile(_args[0].Expression);
compiler.Instructions.Emit(new Invoke1Instruction(Parent.PyContext));
return;
case 2:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Compile(_args[0].Expression);
compiler.Compile(_args[1].Expression);
compiler.Instructions.Emit(new Invoke2Instruction(Parent.PyContext));
return;
case 3:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Compile(_args[0].Expression);
compiler.Compile(_args[1].Expression);
compiler.Compile(_args[2].Expression);
compiler.Instructions.Emit(new Invoke3Instruction(Parent.PyContext));
return;
case 4:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Compile(_args[0].Expression);
compiler.Compile(_args[1].Expression);
compiler.Compile(_args[2].Expression);
compiler.Compile(_args[3].Expression);
compiler.Instructions.Emit(new Invoke4Instruction(Parent.PyContext));
return;
case 5:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Compile(_args[0].Expression);
compiler.Compile(_args[1].Expression);
compiler.Compile(_args[2].Expression);
compiler.Compile(_args[3].Expression);
compiler.Compile(_args[4].Expression);
compiler.Instructions.Emit(new Invoke5Instruction(Parent.PyContext));
return;
case 6:
compiler.Compile(Parent.LocalContext);
compiler.Compile(_target);
compiler.Compile(_args[0].Expression);
compiler.Compile(_args[1].Expression);
compiler.Compile(_args[2].Expression);
compiler.Compile(_args[3].Expression);
compiler.Compile(_args[4].Expression);
compiler.Compile(_args[5].Expression);
compiler.Instructions.Emit(new Invoke6Instruction(Parent.PyContext));
return;
// *** END GENERATED CODE ***
#endregion
}
compiler.Compile(Reduce());
}
示例11:
void IInstructionProvider.AddInstructions(LightCompiler compiler) {
// the interpreter deals with jumps out of finally blocks just fine:
compiler.Compile(_body);
}
示例12: AddInstructions
public void AddInstructions(LightCompiler compiler) {
compiler.Compile(_target);
compiler.Compile(_codeContext);
compiler.Instructions.Emit(new GetMemberInstruction(_binder));
}
示例13: LookupGlobalInstruction
Instruction IInstructionProvider.GetInstruction(LightCompiler compiler) {
compiler.Compile(_scope);
return new LookupGlobalInstruction(_name, _isLocal);
}
示例14: GetInstruction
public Instruction GetInstruction(LightCompiler compiler) {
compiler.Compile(_value);
return new PythonSetGlobalInstruction(_global.Global);
}
示例15:
void IInstructionProvider.AddInstructions(LightCompiler compiler) {
// optimizing bool conversions does no good in the light compiler
compiler.Compile(ReduceWorker(false));
}