//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Reflection;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static partial class type {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool IsStdValue( Type type ) =>
   Type.GetTypeCode( type ) != TypeCode.Object;

//--------------------------------------------------------------------------------------------------

public static bool IsIntegral( Type type ) =>
   u.ops.IsOneOf( type,
      typeof(SByte), typeof(Int16), typeof(Int32), typeof(Int64),
      typeof(Byte), typeof(UInt16), typeof(UInt32), typeof(UInt64),
      typeof(Char) );

public static bool IsIntegralNumber( Type type ) =>
   IsIntegral( type ) && type != typeof( Char );

public static bool IsIntegralSignedNumber( Type type ) =>
   u.ops.IsOneOf( type,
      typeof(SByte), typeof(Int16), typeof(Int32), typeof(Int64) );

public static bool IsIntegralUnsignedNumber( Type type ) =>
   u.ops.IsOneOf( type,
      typeof(Byte), typeof(UInt16), typeof(UInt32), typeof(UInt64) );

//--------------------------------------------------------------------------------------------------

public static bool IsStdNumber( Type type ) =>
   IsStdSignedNumber( type ) || IsStdUnsignedNumber( type );

public static bool IsStdSignedNumber( Type type ) =>
   IsIntegralSignedNumber(type) ||
   u.ops.IsOneOf( type,
      typeof(Single), typeof(Double), typeof(Decimal) );

public static bool IsStdUnsignedNumber(Type type) =>
   IsIntegralUnsignedNumber( type );

//--------------------------------------------------------------------------------------------------

public static bool IsNullable( Type type ) =>
   type.IsGenericType && type.GetGenericTypeDefinition().Equals( typeof(Nullable<>) );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // type

} // user_rtx (.wasm)
