tlang-interperter-cs/tlanglib/IfNode.cs

23 lines
587 B
C#
Raw Normal View History

2023-03-09 19:40:14 +00:00
namespace tlang
{
internal class IfNode : Node
{
public Node Condition {get;set;}
public Node Yes {get;set;}
public Node No {get;set;}
public IfNode(Node condition, Node yes, Node no)
{
this.Condition = condition;
this.Yes = yes;
this.No = no;
}
public override TObject Execute(IScopeEnvironment nodeEnv)
{
var condition = Condition.Execute(nodeEnv);
2023-03-09 23:57:16 +00:00
return condition.AsBoolean ? Yes.Execute(nodeEnv) : No.Execute(nodeEnv);
2023-03-09 19:40:14 +00:00
}
}
}