tlang-interperter-cs/SubtractNode.cs

25 lines
598 B
C#

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)
{
var l = Left.Execute(nodeEnv) as TNumber;
var r = Right.Execute(nodeEnv) as TNumber;
if(l != null && r != null)
return new TNumber(l.Value - r.Value);
return new TNull();
}
}
}