本文整理汇总了C#中IKVM.Internal.CodeEmitter.EmitLdc_I4方法的典型用法代码示例。如果您正苦于以下问题:C# CodeEmitter.EmitLdc_I4方法的具体用法?C# CodeEmitter.EmitLdc_I4怎么用?C# CodeEmitter.EmitLdc_I4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKVM.Internal.CodeEmitter
的用法示例。
在下文中一共展示了CodeEmitter.EmitLdc_I4方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitGetImpl
protected override void EmitGetImpl(CodeEmitter ilgen)
{
// Reading a field should trigger the cctor, but since we're inlining the value
// we have to trigger it explicitly
DeclaringType.EmitRunClassConstructor(ilgen);
// NOTE even though you're not supposed to access a constant static final (the compiler is supposed
// to inline them), we have to support it (because it does happen, e.g. if the field becomes final
// after the referencing class was compiled, or when we're accessing an unsigned primitive .NET field)
object v = GetConstantValue();
if(v == null)
{
ilgen.Emit(OpCodes.Ldnull);
}
else if(constant is int ||
constant is short ||
constant is ushort ||
constant is byte ||
constant is sbyte ||
constant is char ||
constant is bool)
{
ilgen.EmitLdc_I4(((IConvertible)constant).ToInt32(null));
}
else if(constant is string)
{
ilgen.Emit(OpCodes.Ldstr, (string)constant);
}
else if(constant is float)
{
ilgen.EmitLdc_R4((float)constant);
}
else if(constant is double)
{
ilgen.EmitLdc_R8((double)constant);
}
else if(constant is long)
{
ilgen.EmitLdc_I8((long)constant);
}
else if(constant is uint)
{
ilgen.EmitLdc_I4(unchecked((int)((IConvertible)constant).ToUInt32(null)));
}
else if(constant is ulong)
{
ilgen.EmitLdc_I8(unchecked((long)(ulong)constant));
}
else
{
throw new InvalidOperationException(constant.GetType().FullName);
}
}
示例2: EmitCheckcast
internal override void EmitCheckcast(CodeEmitter ilgen)
{
if(IsGhost)
{
ilgen.Emit(OpCodes.Dup);
ilgen.Emit(OpCodes.Call, ghostCastMethod);
ilgen.Emit(OpCodes.Pop);
}
else if(IsGhostArray)
{
ilgen.Emit(OpCodes.Dup);
TypeWrapper tw = this;
int rank = 0;
while(tw.IsArray)
{
rank++;
tw = tw.ElementTypeWrapper;
}
ilgen.EmitLdc_I4(rank);
ilgen.Emit(OpCodes.Call, ghostCastArrayMethod);
ilgen.Emit(OpCodes.Castclass, ArrayTypeWrapper.MakeArrayType(Types.Object, rank));
}
else
{
base.EmitCheckcast(ilgen);
}
}
示例3: Generate
internal override void Generate(CodeGenContext context, CodeEmitter ilgen)
{
ilgen.EmitLdc_I4(val);
}