Upsilon/Upsilon/Binder/BoundStatements/BoundIfStatement.cs

58 lines
1.9 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Upsilon.Text;
2018-11-13 11:48:50 +00:00
namespace Upsilon.Binder
{
public class BoundIfStatement : BoundStatement
{
public BoundIfStatement(BoundExpressionStatement condition, BoundBlockStatement block, TextSpan span): base(span)
2018-11-13 11:48:50 +00:00
{
Condition = condition;
2018-11-13 12:54:51 +00:00
Block = block;
}
2018-11-13 14:15:44 +00:00
public BoundIfStatement(BoundExpressionStatement condition, BoundBlockStatement block, BoundElseStatement elseStatement, TextSpan span) : base(span)
2018-11-13 12:54:51 +00:00
{
2018-11-13 14:15:44 +00:00
Condition = condition;
Block = block;
2018-11-13 12:54:51 +00:00
ElseStatement = elseStatement;
2018-11-13 11:48:50 +00:00
}
public BoundIfStatement(BoundExpressionStatement condition, BoundBlockStatement block, BoundIfStatement nextElseIf, TextSpan span) : base(span)
2018-11-13 14:15:44 +00:00
{
Condition = condition;
Block = block;
NextElseIf = nextElseIf;
}
2018-11-13 11:48:50 +00:00
public override BoundKind Kind => BoundKind.BoundIfStatement;
2019-01-17 12:56:53 +00:00
public override IEnumerable<BoundNode> GetChildren()
{
yield return Condition;
yield return Block;
if (NextElseIf != null) yield return NextElseIf;
if (ElseStatement != null) yield return ElseStatement;
}
2018-11-13 11:48:50 +00:00
public BoundExpressionStatement Condition { get; }
public BoundBlockStatement Block { get; }
2018-11-13 14:15:44 +00:00
public BoundIfStatement NextElseIf { get; }
2018-11-13 12:54:51 +00:00
public BoundElseStatement ElseStatement { get; }
}
public class BoundElseStatement : BoundStatement
{
public BoundBlockStatement Block { get; }
public BoundElseStatement(BoundBlockStatement block, TextSpan span) : base(span)
2018-11-13 12:54:51 +00:00
{
Block = block;
}
public override BoundKind Kind => BoundKind.BoundElseStatement;
2019-01-17 12:56:53 +00:00
public override IEnumerable<BoundNode> GetChildren()
{
yield return Block;
}
2018-11-13 11:48:50 +00:00
}
}