2023-03-10 10:12:51 +00:00
|
|
|
namespace tlang
|
|
|
|
{
|
|
|
|
internal class EqualsNode : Node
|
|
|
|
{
|
|
|
|
public Node Left {get;set;}
|
|
|
|
public Node Right {get;set;}
|
|
|
|
|
|
|
|
public EqualsNode(Node left, Node right)
|
|
|
|
{
|
|
|
|
this.Left = left;
|
|
|
|
this.Right = right;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override TObject Execute(IScopeEnvironment nodeEnv)
|
|
|
|
{
|
|
|
|
var l = Left.Execute(nodeEnv);
|
|
|
|
var r = Right.Execute(nodeEnv);
|
|
|
|
var lnum = l as TNumber;
|
|
|
|
var rnum = r as TNumber;
|
2023-06-08 18:14:35 +00:00
|
|
|
var lstr = l as TString;
|
|
|
|
var rstr = r as TString;
|
|
|
|
var lbool = l as TBoolean;
|
|
|
|
var rbool = r as TBoolean;
|
|
|
|
var lchar = l as TChar;
|
|
|
|
var rchar = r as TChar;
|
2023-03-10 10:12:51 +00:00
|
|
|
var dleft = l as TDictionary;
|
|
|
|
|
|
|
|
if(dleft != null)
|
|
|
|
{
|
|
|
|
if(dleft.MemberExists("eq"))
|
|
|
|
{
|
|
|
|
var mbm = dleft["eq"] as ICallable;
|
|
|
|
if(mbm != null)
|
|
|
|
{
|
|
|
|
return mbm.Call(r);
|
|
|
|
}
|
2023-06-08 18:14:35 +00:00
|
|
|
else {
|
|
|
|
var dright = r as TDictionary;
|
|
|
|
if(dright != null)
|
|
|
|
{
|
|
|
|
return TObject.Boolean(dleft == dright);
|
|
|
|
}
|
|
|
|
}
|
2023-03-10 10:12:51 +00:00
|
|
|
}
|
2023-06-08 18:14:35 +00:00
|
|
|
else {
|
|
|
|
var dright = r as TDictionary;
|
|
|
|
if(dright != null)
|
|
|
|
{
|
|
|
|
return TObject.Boolean(dleft == dright);
|
|
|
|
}
|
|
|
|
}
|
2023-03-10 10:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(lnum != null && rnum != null)
|
2023-06-08 18:14:35 +00:00
|
|
|
return TObject.Boolean(lnum.Value == rnum.Value);
|
|
|
|
if(lbool != null && rbool != null)
|
|
|
|
return TObject.Boolean(lbool.Value == rbool.Value);
|
|
|
|
if(lstr != null && rstr != null)
|
|
|
|
return TObject.Boolean(lstr.Value == rstr.Value);
|
|
|
|
if(lchar != null && rchar != null)
|
|
|
|
return TObject.Boolean(lchar.Value == rchar.Value);
|
|
|
|
|
2023-03-10 10:12:51 +00:00
|
|
|
|
2023-06-08 18:14:35 +00:00
|
|
|
return TObject.Null;
|
2023-03-10 10:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|