tlang-interperter-cs/MultiplyNode.cs

25 lines
598 B
C#
Raw Normal View History

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