45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Upsilon.BaseTypes;
|
|
using Upsilon.Text;
|
|
|
|
namespace Upsilon.Binder
|
|
{
|
|
public class BoundBinaryExpression : BoundExpression
|
|
{
|
|
public BoundBinaryExpression(BoundBinaryOperator op, BoundExpression leftExpression,
|
|
BoundExpression rightExpression, Type type, TextSpan span) : base(span)
|
|
{
|
|
Operator = op;
|
|
LeftExpression = leftExpression;
|
|
RightExpression = rightExpression;
|
|
Type = type;
|
|
}
|
|
|
|
public override BoundKind Kind => BoundKind.BoundBinaryExpression;
|
|
public override IEnumerable<BoundNode> GetNodeAtPosition(int line, int character)
|
|
{
|
|
if (LeftExpression.Span.Contains(line, character))
|
|
{
|
|
foreach (var exp in LeftExpression.GetNodeAtPosition(line, character))
|
|
{
|
|
yield return exp;
|
|
}
|
|
}
|
|
if (RightExpression.Span.Contains(line, character))
|
|
{
|
|
foreach (var exp in RightExpression.GetNodeAtPosition(line, character))
|
|
{
|
|
yield return exp;
|
|
}
|
|
}
|
|
yield return this;
|
|
}
|
|
|
|
public override Type Type { get; }
|
|
|
|
public BoundBinaryOperator Operator { get; }
|
|
public BoundExpression LeftExpression { get; }
|
|
public BoundExpression RightExpression { get; }
|
|
}
|
|
} |