本文整理汇总了C#中Jurassic.Compiler.ILGenerator.ConvertToUnsignedInteger方法的典型用法代码示例。如果您正苦于以下问题:C# ILGenerator.ConvertToUnsignedInteger方法的具体用法?C# ILGenerator.ConvertToUnsignedInteger怎么用?C# ILGenerator.ConvertToUnsignedInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jurassic.Compiler.ILGenerator
的用法示例。
在下文中一共展示了ILGenerator.ConvertToUnsignedInteger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToInt32
/// <summary>
/// Pops the value on the stack, converts it to an integer, then pushes the integer result
/// onto the stack. Large numbers wrap (i.e. 4294967296 -> 0).
/// </summary>
/// <param name="generator"> The IL generator. </param>
/// <param name="fromType"> The type to convert from. </param>
public static void ToInt32(ILGenerator generator, PrimitiveType fromType)
{
// Check that a conversion is actually necessary.
if (fromType == PrimitiveType.Int32 || fromType == PrimitiveType.UInt32 || fromType == PrimitiveType.Bool)
return;
switch (fromType)
{
case PrimitiveType.Undefined:
case PrimitiveType.Null:
// Converting from undefined or null produces 0.
generator.Pop();
generator.LoadInt32(0);
break;
case PrimitiveType.Number:
// Converting from a number produces the number mod 4294967296. NaN produces 0.
generator.ConvertToUnsignedInteger();
break;
case PrimitiveType.String:
case PrimitiveType.ConcatenatedString:
case PrimitiveType.Any:
case PrimitiveType.Object:
// Otherwise, fall back to calling TypeConverter.ToInt32()
generator.Call(ReflectionHelpers.TypeConverter_ToInt32);
break;
default:
throw new NotImplementedException(string.Format("Unsupported primitive type: {0}", fromType));
}
}