2023-03-09 19:40:14 +00:00
|
|
|
namespace tlang
|
|
|
|
{
|
|
|
|
internal class SubtractNode : Node
|
|
|
|
{
|
|
|
|
public Node Left {get;set;}
|
|
|
|
public Node Right {get;set;}
|
|
|
|
|
|
|
|
public SubtractNode(Node left, Node right)
|
|
|
|
{
|
|
|
|
this.Left = left;
|
|
|
|
this.Right = right;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override TObject Execute(IScopeEnvironment nodeEnv)
|
|
|
|
{
|
2023-03-09 23:57:16 +00:00
|
|
|
var l = Left.Execute(nodeEnv);
|
|
|
|
var r = Right.Execute(nodeEnv);
|
|
|
|
var lnum = l as TNumber;
|
|
|
|
var rnum = r as TNumber;
|
|
|
|
var dleft = l as TDictionary;
|
2023-03-09 19:40:14 +00:00
|
|
|
|
2023-03-09 23:57:16 +00:00
|
|
|
if(dleft != null)
|
|
|
|
{
|
|
|
|
if(dleft.MemberExists("sub"))
|
|
|
|
{
|
|
|
|
var mbm = dleft["sub"] as ICallable;
|
|
|
|
if(mbm != null)
|
|
|
|
{
|
|
|
|
return mbm.Call(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(lnum != null && rnum != null)
|
|
|
|
return new TNumber(lnum.Value - rnum.Value);
|
2023-03-09 19:40:14 +00:00
|
|
|
|
|
|
|
return new TNull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|