本文整理汇总了C#中Mono.CSharp.EmitContext.EmitLong方法的典型用法代码示例。如果您正苦于以下问题:C# EmitContext.EmitLong方法的具体用法?C# EmitContext.EmitLong怎么用?C# EmitContext.EmitLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.EmitContext
的用法示例。
在下文中一共展示了EmitContext.EmitLong方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit (EmitContext ec)
{
MethodSpec m;
int [] words = decimal.GetBits (Value);
int power = (words [3] >> 16) & 0xff;
if (power == 0) {
if (Value <= int.MaxValue && Value >= int.MinValue) {
m = ec.Module.PredefinedMembers.DecimalCtorInt.Resolve (loc);
if (m == null) {
return;
}
ec.EmitInt ((int) Value);
ec.Emit (OpCodes.Newobj, m);
return;
}
if (Value <= long.MaxValue && Value >= long.MinValue) {
m = ec.Module.PredefinedMembers.DecimalCtorLong.Resolve (loc);
if (m == null) {
return;
}
ec.EmitLong ((long) Value);
ec.Emit (OpCodes.Newobj, m);
return;
}
}
ec.EmitInt (words [0]);
ec.EmitInt (words [1]);
ec.EmitInt (words [2]);
// sign
ec.EmitInt (words [3] >> 31);
// power
ec.EmitInt (power);
m = ec.Module.PredefinedMembers.DecimalCtor.Resolve (loc);
if (m != null) {
ec.Emit (OpCodes.Newobj, m);
}
}
示例2: Emit
public override void Emit (EmitContext ec)
{
int [] words = decimal.GetBits (Value);
int power = (words [3] >> 16) & 0xff;
if (power == 0) {
if (Value <= int.MaxValue && Value >= int.MinValue) {
if (TypeManager.void_decimal_ctor_int_arg == null) {
TypeManager.void_decimal_ctor_int_arg = TypeManager.GetPredefinedConstructor (
TypeManager.decimal_type, loc, TypeManager.int32_type);
if (TypeManager.void_decimal_ctor_int_arg == null)
return;
}
ec.EmitInt ((int) Value);
ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_int_arg);
return;
}
if (Value <= long.MaxValue && Value >= long.MinValue) {
if (TypeManager.void_decimal_ctor_long_arg == null) {
TypeManager.void_decimal_ctor_long_arg = TypeManager.GetPredefinedConstructor (
TypeManager.decimal_type, loc, TypeManager.int64_type);
if (TypeManager.void_decimal_ctor_long_arg == null)
return;
}
ec.EmitLong ((long) Value);
ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_long_arg);
return;
}
}
ec.EmitInt (words [0]);
ec.EmitInt (words [1]);
ec.EmitInt (words [2]);
// sign
ec.EmitInt (words [3] >> 31);
// power
ec.EmitInt (power);
if (TypeManager.void_decimal_ctor_five_args == null) {
TypeManager.void_decimal_ctor_five_args = TypeManager.GetPredefinedConstructor (
TypeManager.decimal_type, loc, TypeManager.int32_type, TypeManager.int32_type,
TypeManager.int32_type, TypeManager.bool_type, TypeManager.byte_type);
if (TypeManager.void_decimal_ctor_five_args == null)
return;
}
ec.Emit (OpCodes.Newobj, TypeManager.void_decimal_ctor_five_args);
}
示例3: EmitObjectInteger
void EmitObjectInteger (EmitContext ec, object k)
{
if (k is int)
ec.EmitInt ((int) k);
else if (k is Constant) {
EmitObjectInteger (ec, ((Constant) k).GetValue ());
}
else if (k is uint)
ec.EmitInt (unchecked ((int) (uint) k));
else if (k is long)
{
if ((long) k >= int.MinValue && (long) k <= int.MaxValue)
{
ec.EmitInt ((int) (long) k);
ec.Emit (OpCodes.Conv_I8);
}
else
ec.EmitLong ((long) k);
}
else if (k is ulong)
{
ulong ul = (ulong) k;
if (ul < (1L<<32))
{
ec.EmitInt (unchecked ((int) ul));
ec.Emit (OpCodes.Conv_U8);
}
else
{
ec.EmitLong (unchecked ((long) ul));
}
}
else if (k is char)
ec.EmitInt ((int) ((char) k));
else if (k is sbyte)
ec.EmitInt ((int) ((sbyte) k));
else if (k is byte)
ec.EmitInt ((int) ((byte) k));
else if (k is short)
ec.EmitInt ((int) ((short) k));
else if (k is ushort)
ec.EmitInt ((int) ((ushort) k));
else if (k is bool)
ec.EmitInt (((bool) k) ? 1 : 0);
else
throw new Exception ("Unhandled case");
}