Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jurassic/Compiler/Binders/BinderUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static int ResolveOverloads(RuntimeMethodHandle[] methodHandles, ScriptEn
demeritPoints[i] += disqualification;
break;

case TypeCode.DBNull:
case TypeCode.DateTime:
case TypeCode.Object:
if (input == null || input == Undefined.Value)
Expand All @@ -115,7 +116,6 @@ public static int ResolveOverloads(RuntimeMethodHandle[] methodHandles, ScriptEn


case TypeCode.Empty:
case TypeCode.DBNull:
throw new NotSupportedException(string.Format("{0} is not a supported parameter type.", outputType));
}
}
Expand Down
6 changes: 2 additions & 4 deletions Jurassic/Compiler/Binders/ClrBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ internal static void EmitConversionToType(ILGenerator generator, Type toType, bo
generator.LoadInt32(0);
generator.Call(ReflectionHelpers.String_GetChars);
break;
case TypeCode.DBNull:
throw new NotSupportedException("DBNull is not a supported parameter type.");
case TypeCode.Decimal:
EmitConversion.ToNumber(generator, PrimitiveType.Any);
generator.NewObject(ReflectionHelpers.Decimal_Constructor_Double);
Expand All @@ -213,6 +211,7 @@ internal static void EmitConversionToType(ILGenerator generator, Type toType, bo
generator.ConvertToInt64();
break;

case TypeCode.DBNull:
case TypeCode.DateTime:
case TypeCode.Object:
// Check if the type must be unwrapped.
Expand Down Expand Up @@ -340,8 +339,6 @@ internal static void EmitConversionToObject(ILGenerator generator, Type fromType
generator.NewObject(ReflectionHelpers.String_Constructor_Char_Int);
break;

case TypeCode.DBNull:
throw new NotSupportedException("DBNull is not a supported return type.");
case TypeCode.Decimal:
generator.Call(ReflectionHelpers.Decimal_ToDouble);
generator.Box(typeof(double));
Expand All @@ -362,6 +359,7 @@ internal static void EmitConversionToObject(ILGenerator generator, Type fromType
generator.Box(typeof(double));
break;

case TypeCode.DBNull:
case TypeCode.DateTime:
case TypeCode.Object:
// Check if the type must be wrapped with a ClrInstanceWrapper.
Expand Down
156 changes: 156 additions & 0 deletions Jurassic/Core/TypeComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,54 @@ public static class TypeComparer
{
x = x ?? Undefined.Value;
y = y ?? Undefined.Value;
if (x is sbyte)
x = (double)(sbyte)x;
if (x is byte)
x = (double)(byte)x;
if (x is char)
x = (double)(char)x;
if (x is short)
x = (double)(short)x;
if (x is ushort)
x = (double)(ushort)x;
if (x is int)
x = (double)(int)x;
if (x is uint)
x = (double)(uint)x;
if (x is long)
x = (double)(long)x;
if (x is ulong)
x = (double)(ulong)x;
if (x is Enum)
x = (double)(int)x;
if (x is float)
x = (double)(float)x;
if (x is decimal)
x = decimal.ToDouble((decimal)x);
if (y is sbyte)
y = (double)(sbyte)y;
if (y is byte)
y = (double)(byte)y;
if (y is char)
y = (double)(char)y;
if (y is short)
y = (double)(short)y;
if (y is ushort)
y = (double)(ushort)y;
if (y is int)
y = (double)(int)y;
if (y is uint)
y = (double)(uint)y;
if (y is long)
y = (double)(long)y;
if (y is ulong)
y = (double)(ulong)y;
if (y is Enum)
y = (double)(int)y;
if (y is float)
y = (double)(float)y;
if (y is decimal)
y = decimal.ToDouble((decimal)y);
if (x is ConcatenatedString)
x = x.ToString();
if (y is ConcatenatedString)
Expand Down Expand Up @@ -81,14 +121,50 @@ public static bool StrictEquals(object x, object y)
{
x = x ?? Undefined.Value;
y = y ?? Undefined.Value;
if (x is sbyte)
x = (double)(sbyte)x;
if (x is byte)
x = (double)(byte)x;
if (x is char)
x = (double)(char)x;
if (x is short)
x = (double)(short)x;
if (x is ushort)
x = (double)(ushort)x;
if (x is int)
x = (double)(int)x;
if (x is uint)
x = (double)(uint)x;
if (x is long)
x = (double)(long)x;
if (x is ulong)
x = (double)(ulong)x;
if (x is float)
x = (double)(float)x;
if (x is decimal)
x = decimal.ToDouble((decimal)x);
if (y is sbyte)
y = (double)(sbyte)y;
if (y is byte)
y = (double)(byte)y;
if (y is char)
y = (double)(char)y;
if (y is short)
y = (double)(short)y;
if (y is ushort)
y = (double)(ushort)y;
if (y is int)
y = (double)(int)y;
if (y is uint)
y = (double)(uint)y;
if (y is long)
y = (double)(long)y;
if (y is ulong)
y = (double)(ulong)y;
if (y is float)
y = (double)(float)y;
if (y is decimal)
y = decimal.ToDouble((decimal)y);
if (x is double && double.IsNaN((double)x) == true)
return false;
if (x is ConcatenatedString)
Expand Down Expand Up @@ -224,14 +300,54 @@ public static bool SameValue(object x, object y)
x = Undefined.Value;
if (y == null)
y = Undefined.Value;
if (x is sbyte)
x = (double)(sbyte)x;
if (x is byte)
x = (double)(byte)x;
if (x is char)
x = (double)(char)x;
if (x is short)
x = (double)(short)x;
if (x is ushort)
x = (double)(ushort)x;
if (x is int)
x = (double)(int)x;
if (x is uint)
x = (double)(uint)x;
if (x is long)
x = (double)(long)x;
if (x is ulong)
x = (double)(ulong)x;
if (x is Enum)
x = (double)(int)x;
if (x is float)
x = (double)(float)x;
if (x is decimal)
x = decimal.ToDouble((decimal)x);
if (y is sbyte)
y = (double)(sbyte)y;
if (y is byte)
y = (double)(byte)y;
if (y is char)
y = (double)(char)y;
if (y is short)
y = (double)(short)y;
if (y is ushort)
y = (double)(ushort)y;
if (y is int)
y = (double)(int)y;
if (y is uint)
y = (double)(uint)y;
if (y is long)
y = (double)(long)y;
if (y is ulong)
y = (double)(ulong)y;
if (y is Enum)
y = (double)(int)y;
if (y is float)
y = (double)(float)y;
if (y is decimal)
y = decimal.ToDouble((decimal)y);
if (x is double && (double) x == 0.0 && y is double && (double)y == 0.0)
if ((1 / (double)x) != (1 / (double)y))
return false;
Expand Down Expand Up @@ -260,14 +376,54 @@ public static bool SameValueZero(object x, object y)
x = Undefined.Value;
if (y == null)
y = Undefined.Value;
if (x is sbyte)
x = (double)(sbyte)x;
if (x is byte)
x = (double)(byte)x;
if (x is char)
x = (double)(char)x;
if (x is short)
x = (double)(short)x;
if (x is ushort)
x = (double)(ushort)x;
if (x is int)
x = (double)(int)x;
if (x is uint)
x = (double)(uint)x;
if (x is long)
x = (double)(long)x;
if (x is ulong)
x = (double)(ulong)x;
if (x is Enum)
x = (double)(int)x;
if (x is float)
x = (double)(float)x;
if (x is decimal)
x = decimal.ToDouble((decimal)x);
if (y is sbyte)
y = (double)(sbyte)y;
if (y is byte)
y = (double)(byte)y;
if (y is char)
y = (double)(char)y;
if (y is short)
y = (double)(short)y;
if (y is ushort)
y = (double)(ushort)y;
if (y is int)
y = (double)(int)y;
if (y is uint)
y = (double)(uint)y;
if (y is long)
y = (double)(long)y;
if (y is ulong)
y = (double)(ulong)y;
if (y is Enum)
y = (double)(int)y;
if (y is float)
y = (double)(float)y;
if (y is decimal)
y = decimal.ToDouble((decimal)y);
if (x is ConcatenatedString)
x = x.ToString();
if (y is ConcatenatedString)
Expand Down
Loading