diff --git a/Upsilon/BaseTypes/ScriptBoolean.cs b/Upsilon/BaseTypes/ScriptBoolean.cs index ecce633..14388f0 100644 --- a/Upsilon/BaseTypes/ScriptBoolean.cs +++ b/Upsilon/BaseTypes/ScriptBoolean.cs @@ -39,5 +39,19 @@ namespace Upsilon.BaseTypes { return Value.ToString(); } + + protected bool Equals(ScriptBoolean other) + { + return other.Value == Value; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((ScriptBoolean) obj); + } + } } \ No newline at end of file diff --git a/Upsilon/BaseTypes/ScriptNull.cs b/Upsilon/BaseTypes/ScriptNull.cs index ef7dcfb..37e8014 100644 --- a/Upsilon/BaseTypes/ScriptNull.cs +++ b/Upsilon/BaseTypes/ScriptNull.cs @@ -2,6 +2,7 @@ namespace Upsilon.BaseTypes { internal class ScriptNull : ScriptType { + public override Type Type => Type.Nil; public override object ToCSharpObject() { @@ -17,5 +18,18 @@ namespace Upsilon.BaseTypes { return "null"; } + + protected bool Equals(ScriptNull other) + { + return true; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((ScriptNull) obj); + } } } \ No newline at end of file diff --git a/Upsilon/BaseTypes/UserData/DictionaryUserData.cs b/Upsilon/BaseTypes/UserData/DictionaryUserData.cs index 03900c7..c7ec453 100644 --- a/Upsilon/BaseTypes/UserData/DictionaryUserData.cs +++ b/Upsilon/BaseTypes/UserData/DictionaryUserData.cs @@ -55,5 +55,19 @@ namespace Upsilon.BaseTypes.UserData { return new ScriptNumberLong(Dictionary.Count); } + + protected bool Equals(DictionaryUserData other) + { + return Dictionary.Equals(other.Dictionary); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((DictionaryUserData) obj); + } + } } \ No newline at end of file diff --git a/Upsilon/BaseTypes/UserData/GenericUserData.cs b/Upsilon/BaseTypes/UserData/GenericUserData.cs index ce943d3..7bea836 100644 --- a/Upsilon/BaseTypes/UserData/GenericUserData.cs +++ b/Upsilon/BaseTypes/UserData/GenericUserData.cs @@ -55,5 +55,19 @@ namespace Upsilon.BaseTypes.UserData { return _typeInfo.UnaryOperator(Value, par1, op); } + + protected bool Equals(GenericUserData other) + { + return Value.Equals(other.Value); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((GenericUserData) obj); + } + } } \ No newline at end of file diff --git a/Upsilon/BaseTypes/UserData/ListUserData.cs b/Upsilon/BaseTypes/UserData/ListUserData.cs index 5018e36..3db4bd5 100644 --- a/Upsilon/BaseTypes/UserData/ListUserData.cs +++ b/Upsilon/BaseTypes/UserData/ListUserData.cs @@ -71,5 +71,19 @@ namespace Upsilon.BaseTypes.UserData { return new ScriptNumberLong(List.Count); } + + protected bool Equals(ListUserData other) + { + return List.Equals(other.List); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((ListUserData) obj); + } + } } \ No newline at end of file diff --git a/Upsilon/Evaluator/Evaluator.cs b/Upsilon/Evaluator/Evaluator.cs index c5158f5..0ae9d62 100644 --- a/Upsilon/Evaluator/Evaluator.cs +++ b/Upsilon/Evaluator/Evaluator.cs @@ -382,9 +382,9 @@ namespace Upsilon.Evaluator } goto default; case BoundBinaryOperator.OperatorKind.Equality: - return new ScriptBoolean(Equals(left, right)); + return new ScriptBoolean(left.Equals(right)); case BoundBinaryOperator.OperatorKind.Inequality: - return new ScriptBoolean(!Equals(left, right)); + return new ScriptBoolean(!left.Equals(right)); case BoundBinaryOperator.OperatorKind.Less: if (left.Type == Type.Number && right.Type == Type.Number) {