tlang-interperter-cs/DivideNode.cs

25 lines
594 B
C#
Raw Normal View History

2023-03-09 19:40:14 +00:00
namespace tlang
{
internal class DivideNode : Node
{
public Node Left {get;set;}
public Node Right {get;set;}
public DivideNode(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();
}
}
}