本文整理汇总了C#中Dot42.CompilerLib.XModel.XTypeReference.IsFloat方法的典型用法代码示例。如果您正苦于以下问题:C# XTypeReference.IsFloat方法的具体用法?C# XTypeReference.IsFloat怎么用?C# XTypeReference.IsFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dot42.CompilerLib.XModel.XTypeReference
的用法示例。
在下文中一共展示了XTypeReference.IsFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAsEnumerableTMethodName
/// <summary>
/// Returns the method name when converting an array to an IEnumerableT in compiler helper.
///
/// (not sure if this is the best place for this method...)
/// </summary>
public static string GetAsEnumerableTMethodName(XTypeReference sourceArrayElementType)
{
var convertMethodName = "AsObjectEnumerable";
if (sourceArrayElementType.IsPrimitive)
{
if (sourceArrayElementType.IsBoolean()) convertMethodName = "AsBoolEnumerable";
else if (sourceArrayElementType.IsByte()) convertMethodName = "AsByteEnumerable";
else if (sourceArrayElementType.IsSByte()) convertMethodName = "AsSByteEnumerable";
else if (sourceArrayElementType.IsChar()) convertMethodName = "AsCharEnumerable";
else if (sourceArrayElementType.IsInt16()) convertMethodName = "AsInt16Enumerable";
else if (sourceArrayElementType.IsUInt16()) convertMethodName = "AsUInt16Enumerable";
else if (sourceArrayElementType.IsInt32()) convertMethodName = "AsInt32Enumerable";
else if (sourceArrayElementType.IsUInt32()) convertMethodName = "AsUInt32Enumerable";
else if (sourceArrayElementType.IsInt64()) convertMethodName = "AsInt64Enumerable";
else if (sourceArrayElementType.IsFloat()) convertMethodName = "AsFloatEnumerable";
else if (sourceArrayElementType.IsDouble()) convertMethodName = "AsDoubleEnumerable";
else throw new ArgumentOutOfRangeException("Unknown primitive array element type " + sourceArrayElementType);
}
return convertMethodName;
}
示例2: ReverseCode
/// <summary>
/// Reverses the code, taking account float/double NaN comparisons
/// </summary>
private static AstCode ReverseCode(AstCode code, XTypeReference type)
{
bool isFlt = type.IsDouble() || type.IsFloat();
if (!isFlt)
return code.Reverse();
switch (code)
{
case AstCode.Ceq:
return AstCode.Cne;
case AstCode.Cne:
return AstCode.Ceq;
case AstCode.Cle:
return AstCode.Cgt_Un;
case AstCode.Cle_Un:
return AstCode.Cgt;
case AstCode.Clt:
return AstCode.Cge_Un;
case AstCode.Clt_Un:
return AstCode.Cge;
case AstCode.Cgt:
return AstCode.Cle_Un;
case AstCode.Cgt_Un:
return AstCode.Cle;
case AstCode.Cge:
return AstCode.Clt_Un;
case AstCode.Cge_Un:
return AstCode.Clt;
default:
throw new ArgumentOutOfRangeException("code", code.ToString());
}
}
示例3: OpcodeForType
/// <summary>
/// Generate an Add opcode.
/// </summary>
private static RCode OpcodeForType(XTypeReference type, RCode[] opcodes)
{
if (type.IsInt32() || type.IsUInt32() || type.IsInt16() || type.IsUInt16() || type.IsChar() || type.IsByte() || type.IsSByte() || type.IsBoolean()) return opcodes[0];
if (type.IsInt64() || type.IsUInt64()) return opcodes[1];
if (type.IsFloat()) return opcodes[2];
if (type.IsDouble()) return opcodes[3];
XTypeDefinition typeDef;
if (type.TryResolve(out typeDef))
{
if (typeDef.IsEnum)
{
return OpcodeForType(typeDef.GetEnumUnderlyingType(), opcodes);
}
}
throw new ArgumentException("Unsupported type " + type);
}
示例4: CreateInitializeValueInstructions
//.........这里部分代码省略.........
}
}
else if (valueType.IsArray)
{
var array = (CustomAttributeArgument[])value.Value;
var elementType = valueType.ElementType;
Register rIndex = body.AllocateRegister(RCategory.Temp, RType.Value);
body.Instructions.Add(seqp, RCode.Const, array.Length, rIndex);
body.Instructions.Add(seqp, RCode.New_array, valueType.GetReference(targetPackage), result[0], rIndex);
// iterate through each value
for (int i = 0; i < array.Length; i++)
{
Register rLoaded = CreateInitializeValueInstructions(seqp, body, elementType, array[i], compiler, targetPackage)[0];
body.Instructions.Add(seqp, RCode.Const, i, rIndex);
body.Instructions.Add(seqp, valueType.APut(), rLoaded, result[0], rIndex);
}
}
else if (targetType.IsEnum())
{
var enumClass = (targetType.IsEnum()? targetType:valueType).GetReference(targetPackage) ;
Register rEnumClass = body.AllocateRegister(RCategory.Temp, RType.Object);
body.Instructions.Add(seqp, RCode.Const_class, enumClass, rEnumClass);
long lVal = Convert.ToInt64(value.Value);
if (lVal <= int.MaxValue && lVal >= int.MinValue)
{
Register regTmp = body.AllocateRegister(RCategory.Temp, RType.Value);
body.Instructions.Add(seqp, RCode.Const, (int)lVal, regTmp);
var get = compiler.GetDot42InternalType("Enum").Resolve()
.Methods.Single(p => p.Name == "Get" && p.Parameters.Count == 2 && !p.Parameters[1].ParameterType.IsWide())
.GetReference(targetPackage);
body.Instructions.Add(seqp, RCode.Invoke_static, get, rEnumClass, regTmp);
body.Instructions.Add(seqp, targetType.MoveResult(), result[0]);
}
else
{
var regTmp = body.AllocateWideRegister(RCategory.Temp);
body.Instructions.Add(seqp, RCode.Const, (long)lVal, regTmp.Item1);
var get = compiler.GetDot42InternalType("Enum").Resolve()
.Methods.Single(p => p.Name == "Get" && p.Parameters.Count == 2 && p.Parameters[1].ParameterType.IsWide())
.GetReference(targetPackage);
body.Instructions.Add(seqp, RCode.Invoke_static, get, rEnumClass, regTmp.Item1);
body.Instructions.Add(seqp, targetType.MoveResult(), result[0]);
}
body.Instructions.Add(seqp, RCode.Check_cast, targetType.GetReference(targetPackage), result[0]);
}
else if (valueType.IsSystemString())
{
body.Instructions.Add(seqp, RCode.Const_string, (string)value.Value, result[0]);
}
else if (valueType.IsSystemType())
{
var type = XBuilder.AsTypeReference(compiler.Module, (TypeReference)value.Value);
// TODO: this might not work with typeof(void) on ART runtime.
body.Instructions.Add(seqp, RCode.Const_class, type.GetReference(targetPackage), result[0]);
}
else if (!valueType.IsPrimitive)
{
// can this happen?
throw new Exception("invalid value type in attribute: " + targetType.FullName);
}
else
{
if (targetType.IsSystemObject())
{
// can this happen? or is this always handled above?
// boxing required.
var rUnboxed = CreateInitializeValueInstructions(seqp, body, valueType, value, compiler, targetPackage);
body.Instructions.Add(seqp, RCode.Invoke_static, valueType.GetBoxValueOfMethod(), rUnboxed);
body.Instructions.Add(seqp, RCode.Move_result_object, result[0]);
}
else if(targetType.IsDouble())
{
body.Instructions.Add(seqp, RCode.Const_wide, Convert.ToDouble(value.Value), result[0]);
}
else if (targetType.IsWide() && valueType.IsUInt64())
{
body.Instructions.Add(seqp, RCode.Const_wide, (long)Convert.ToUInt64(value.Value), result[0]);
}
else if (targetType.IsWide())
{
body.Instructions.Add(seqp, RCode.Const_wide, Convert.ToInt64(value.Value), result[0]);
}
else if (targetType.IsFloat())
{
body.Instructions.Add(seqp, RCode.Const, Convert.ToSingle(value.Value), result[0]);
}
else
{
body.Instructions.Add(seqp, RCode.Const, (int)Convert.ToInt64(value.Value), result[0]);
}
}
return result.ToArray();
}