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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2015-10-14 22:22:59 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2015-10-14 22:23:11 +0300
commitb72ee9135d031f4eee81e59c5c263ee0c16ac2c2 (patch)
tree5adae15f9be924fbb688704cc7f7c631eede8b31 /mcs/class/dlr
parent4f714afa7cd263daa294f688cb4efb8a255476b2 (diff)
[interpreter] Implement comparing string values in (Not)EqualInstruction
When comparing a string with null the other checks in the interpreter for type equality didn't catch this case and this ultimately resulted in a NotImplementedException in EqualInstruction and NotEqualInstruction. The fix is to handle the TypeCode.String case in those instructions. We don't need to do it for CreateLifted() as that method only applies for Nullable<T> types which doesn't make sense for string. Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=34334
Diffstat (limited to 'mcs/class/dlr')
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs10
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs10
2 files changed, 18 insertions, 2 deletions
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
index 4da895bd203..ad4c33d19fb 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
@@ -24,7 +24,7 @@ using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
internal abstract class EqualInstruction : ComparisonInstruction {
// Perf: EqualityComparer<T> but is 3/2 to 2 times slower.
- private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _String, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
private static Instruction _BooleanLifted, _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted,
_ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
@@ -64,6 +64,13 @@ namespace Microsoft.Scripting.Interpreter {
}
}
+ internal sealed class EqualString : EqualInstruction {
+ protected override object DoCalculate (object l, object r)
+ {
+ return (String)l == (String)r;
+ }
+ }
+
internal sealed class EqualInt32 : EqualInstruction {
protected override object DoCalculate (object l, object r)
{
@@ -140,6 +147,7 @@ namespace Microsoft.Scripting.Interpreter {
case TypeCode.SByte: return _SByte ?? (_SByte = new EqualSByte());
case TypeCode.Byte: return _Byte ?? (_Byte = new EqualByte());
case TypeCode.Char: return _Char ?? (_Char = new EqualChar());
+ case TypeCode.String: return _String ?? (_String = new EqualString());
case TypeCode.Int16: return _Int16 ?? (_Int16 = new EqualInt16());
case TypeCode.Int32: return _Int32 ?? (_Int32 = new EqualInt32());
case TypeCode.Int64: return _Int64 ?? (_Int64 = new EqualInt64());
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
index 396c3ff7159..ebf5e68885a 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
@@ -24,7 +24,7 @@ using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
internal abstract class NotEqualInstruction : ComparisonInstruction {
// Perf: EqualityComparer<T> but is 3/2 to 2 times slower.
- private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _String, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
private static Instruction _BooleanLifted, _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted,
_ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
@@ -64,6 +64,13 @@ namespace Microsoft.Scripting.Interpreter {
}
}
+ internal sealed class NotEqualString : NotEqualInstruction {
+ protected override object DoCalculate (object l, object r)
+ {
+ return (String)l != (String)r;
+ }
+ }
+
internal sealed class NotEqualInt32 : NotEqualInstruction {
protected override object DoCalculate (object l, object r)
{
@@ -140,6 +147,7 @@ namespace Microsoft.Scripting.Interpreter {
case TypeCode.SByte: return _SByte ?? (_SByte = new NotEqualSByte());
case TypeCode.Byte: return _Byte ?? (_Byte = new NotEqualByte());
case TypeCode.Char: return _Char ?? (_Char = new NotEqualChar());
+ case TypeCode.String: return _String ?? (_String = new NotEqualString());
case TypeCode.Int16: return _Int16 ?? (_Int16 = new NotEqualInt16());
case TypeCode.Int32: return _Int32 ?? (_Int32 = new NotEqualInt32());
case TypeCode.Int64: return _Int64 ?? (_Int64 = new NotEqualInt64());