tlang-interperter-cs/tlanglib/IfNode.cs

28 lines
600 B
C#

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);
return condition.AsBoolean ? Yes.Execute(nodeEnv) : No.Execute(nodeEnv);
}
}
}