Fixes for equality
This commit is contained in:
parent
e1b9bb2002
commit
92586e4939
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue