63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
namespace tlang
|
|
{
|
|
internal class NotEqualsNode : Node
|
|
{
|
|
public Node Left {get;set;}
|
|
public Node Right {get;set;}
|
|
|
|
public NotEqualsNode(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;
|
|
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;
|
|
var dleft = l as TDictionary;
|
|
|
|
if(dleft != null)
|
|
{
|
|
if(dleft.MemberExists("neq"))
|
|
{
|
|
var mbm = dleft["neq"] as ICallable;
|
|
if(mbm != null)
|
|
{
|
|
return mbm.Call(r);
|
|
}else {
|
|
var dright = r as TDictionary;
|
|
if(dright != null)
|
|
{
|
|
return TObject.Boolean(dleft != dright);
|
|
}
|
|
}
|
|
} else {
|
|
var dright = r as TDictionary;
|
|
if(dright != null)
|
|
{
|
|
return TObject.Boolean(dleft != dright);
|
|
}
|
|
}
|
|
}
|
|
|
|
if(lnum != null && rnum != null)
|
|
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);
|
|
return TObject.Null;
|
|
}
|
|
}
|
|
} |