Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Numerics/GenerationConfig.ttinclude')
-rw-r--r--src/System.Private.CoreLib/shared/System/Numerics/GenerationConfig.ttinclude61
1 files changed, 50 insertions, 11 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Numerics/GenerationConfig.ttinclude b/src/System.Private.CoreLib/shared/System/Numerics/GenerationConfig.ttinclude
index cdd9c9521..a4466e1a8 100644
--- a/src/System.Private.CoreLib/shared/System/Numerics/GenerationConfig.ttinclude
+++ b/src/System.Private.CoreLib/shared/System/Numerics/GenerationConfig.ttinclude
@@ -1,5 +1,6 @@
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
+<#@ import namespace="System.Text" #>
<#+
/* This file includes static data used as compilation configuration for the rest of the code generation.
It is shared here to ensure that all generated code compiles with the same constants and configurations. */
@@ -7,27 +8,40 @@
// The set of supported numeric types to compile
public static Type[] supportedTypes = new[]
{
- typeof(Byte), typeof(SByte), typeof(UInt16), typeof(Int16),
- typeof(UInt32), typeof(Int32), typeof(UInt64), typeof(Int64),
- typeof(Single), typeof(Double)
+ typeof(byte), typeof(sbyte), typeof(ushort), typeof(short),
+ typeof(uint), typeof(int), typeof(ulong), typeof(long),
+ typeof(float), typeof(double)
};
// The set of unsigned types, a subset of the above. Used for excluding from certain methods, i.e. Abs and Negate
public static Type[] unsignedTypes = new[]
{
- typeof(Byte), typeof(UInt16), typeof(UInt32), typeof(UInt64)
+ typeof(byte), typeof(ushort), typeof(uint), typeof(ulong)
};
public static Type[] integralTypes = new[]
{
- typeof(Byte), typeof(SByte), typeof(UInt16), typeof(Int16),
- typeof(UInt32), typeof(Int32), typeof(UInt64), typeof(Int64)
+ typeof(byte), typeof(sbyte), typeof(ushort), typeof(short),
+ typeof(uint), typeof(int), typeof(ulong), typeof(long)
};
public static Type[] nonClsCompliantTypes = new[]
{
- typeof(SByte), typeof(UInt16),
- typeof(UInt32), typeof(UInt64)
+ typeof(sbyte), typeof(ushort), typeof(uint), typeof(ulong)
+ };
+
+ public static Dictionary<Type, string> typeAliases = new Dictionary<Type, string>()
+ {
+ { typeof(byte), "byte" },
+ { typeof(sbyte), "sbyte" },
+ { typeof(ushort), "ushort" },
+ { typeof(short), "short" },
+ { typeof(uint), "uint" },
+ { typeof(int), "int" },
+ { typeof(ulong), "ulong" },
+ { typeof(long), "long" },
+ { typeof(float), "float" },
+ { typeof(double), "double" }
};
// The total register size, in bytes. 16 for SSE2, 32 for AVX, 64 for AVX512
@@ -136,12 +150,37 @@
public string GenerateIfStatementHeader(Type type)
{
string keyword = (type == supportedTypes[0]) ? "if" : "else if";
- return string.Format("{0} (typeof(T) == typeof({1}))", keyword, type.Name);
+ return string.Format("{0} (typeof(T) == typeof({1}))", keyword, typeAliases[type]);
}
public string GenerateIfStatementHeader(Type type, IEnumerable<Type> allTypes)
{
string keyword = (type == allTypes.ToArray()[0]) ? "if" : "else if";
- return string.Format("{0} (typeof(T) == typeof({1}))", keyword, type.Name);
+ return string.Format("{0} (typeof(T) == typeof({1}))", keyword, typeAliases[type]);
+ }
+
+ public string MakeTypeComparisonCondition(Type type)
+ {
+ return string.Format("(typeof(T) == typeof({0}))", typeAliases[type]);
+ }
+
+ public string GenerateIfConditionAllTypes(IEnumerable<Type> allTypes)
+ {
+ StringBuilder sbuilder = new StringBuilder();
+ bool firstTime = true;
+ foreach (var type in allTypes)
+ {
+ if (firstTime)
+ {
+ sbuilder.Append("if (").Append(MakeTypeComparisonCondition(type));
+ firstTime = false;
+ }
+ else
+ {
+ sbuilder.AppendLine().Append(" || ").Append(MakeTypeComparisonCondition(type));
+ }
+ }
+ sbuilder.Append(")");
+ return sbuilder.ToString();
}
-#> \ No newline at end of file
+#>