本文整理汇总了C#中Microsoft.CodeAnalysis.CodeGen.ILBuilder.EmitOpCode方法的典型用法代码示例。如果您正苦于以下问题:C# ILBuilder.EmitOpCode方法的具体用法?C# ILBuilder.EmitOpCode怎么用?C# ILBuilder.EmitOpCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CodeGen.ILBuilder
的用法示例。
在下文中一共展示了ILBuilder.EmitOpCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitLoadTarget
public void EmitLoadTarget(ILBuilder il)
{
this.Place.EmitLoad(il);
il.EmitOpCode(ILOpCode.Ldfld);
il.EmitSymbolToken(_factory._cg.Module, _factory._cg.Diagnostics, _target, null);
}
示例2: EmitStore
public void EmitStore(ILBuilder il)
{
//if (_property.Setter == null)
// throw new InvalidOperationException();
var stack = 0;
var setter = _property.SetMethod;
if (_holder != null)
{
stack -= 1;
}
//
il.EmitOpCode(setter.IsVirtual ? ILOpCode.Callvirt : ILOpCode.Call, stack);
il.EmitToken(setter, null, DiagnosticBag.GetInstance());
//
Debug.Assert(setter.ReturnType.SpecialType == SpecialType.System_Void);
}
示例3: EmitLoad
public TypeSymbol EmitLoad(ILBuilder il)
{
//if (_property.Getter == null)
// throw new InvalidOperationException();
var stack = +1;
var getter = _property.GetMethod;
if (_holder != null)
{
Debug.Assert(!getter.IsStatic);
_holder.EmitLoad(il); // {holder}
stack -= 1;
}
il.EmitOpCode(getter.IsVirtual ? ILOpCode.Callvirt : ILOpCode.Call, stack);
il.EmitToken(getter, null, DiagnosticBag.GetInstance());
//
return getter.ReturnType;
}
示例4: EmitOpCode
void EmitOpCode(ILBuilder il, ILOpCode code)
{
il.EmitOpCode(code);
il.EmitToken(_field, null, DiagnosticBag.GetInstance()); // .{field}
}
示例5: EmitConvertToPhpValue
public static TypeSymbol EmitConvertToPhpValue(TypeSymbol from, TypeRefMask fromHint, ILBuilder il, Emit.PEModuleBuilder module, DiagnosticBag diagnostic)
{
Contract.ThrowIfNull(from);
var compilation = module.Compilation;
switch (from.SpecialType)
{
case SpecialType.System_Boolean:
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_Boolean);
break;
case SpecialType.System_Int32:
il.EmitOpCode(ILOpCode.Conv_i8); // Int32 -> Int64
goto case SpecialType.System_Int64; // PhpValue.Create((long)<stack>)
case SpecialType.System_Int64:
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_Long);
break;
case SpecialType.System_Double:
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_Double);
break;
case SpecialType.System_Void:
Emit_PhpValue_Void(il, module, diagnostic);
break;
default:
if (from == compilation.CoreTypes.PhpAlias)
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_PhpAlias)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else if (from == compilation.CoreTypes.PhpValue)
{
// nop
break;
}
else if (from == compilation.CoreTypes.String)
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_String)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else if (from == compilation.CoreTypes.PhpString)
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_PhpString)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else if (from == compilation.CoreTypes.PhpNumber)
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_PhpNumber)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else if (from.IsOfType(compilation.CoreTypes.PhpArray))
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_PhpArray)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else if (from == compilation.CoreTypes.IntStringKey)
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.Create_IntStringKey)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else if (from.IsReferenceType)
{
il.EmitCall(module, diagnostic, ILOpCode.Call, compilation.CoreMethods.PhpValue.FromClass_Object)
.Expect(compilation.CoreTypes.PhpValue);
break;
}
else
{
throw new NotImplementedException($"{from.Name}");
}
}
//
return compilation.CoreTypes.PhpValue;
}
示例6: Emit_PhpValue_Void
/// <summary>
/// Emits load of PhpValue representing void.
/// </summary>
static TypeSymbol Emit_PhpValue_Void(ILBuilder il, Emit.PEModuleBuilder module, DiagnosticBag diagnostic)
{
il.EmitOpCode(ILOpCode.Ldsfld);
il.EmitSymbolToken(module, diagnostic, module.Compilation.CoreMethods.PhpValue.Void, null);
return module.Compilation.CoreTypes.PhpValue;
}