39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using Upsilon.BaseTypes;
|
|
using Upsilon.Text;
|
|
|
|
namespace Upsilon.Binder
|
|
{
|
|
public class BoundFunctionExpression : BoundExpression, IBoundNodeScopeOwner
|
|
{
|
|
public ImmutableArray<BoundVariableSymbol> Parameters { get; }
|
|
public BoundBlockStatement Block { get; set; }
|
|
|
|
public BoundFunctionExpression(ImmutableArray<BoundVariableSymbol> parameters, BoundBlockStatement block, TextSpan span,
|
|
BoundScope scope) : base(span)
|
|
{
|
|
Parameters = parameters;
|
|
Block = block;
|
|
Scope = scope;
|
|
}
|
|
|
|
public override BoundKind Kind => BoundKind.BoundFunctionExpression;
|
|
public override IEnumerable<BoundNode> GetNodeAtPosition(int characterPosition)
|
|
{
|
|
foreach (var parameter in Parameters)
|
|
{
|
|
if (characterPosition >= parameter.Span.Start && characterPosition <= parameter.Span.End)
|
|
foreach (var boundNode in parameter.GetNodeAtPosition(characterPosition))
|
|
yield return boundNode;
|
|
}
|
|
if (characterPosition >= Block.Span.Start && characterPosition <= Block.Span.End)
|
|
foreach (var boundNode in Block.GetNodeAtPosition(characterPosition))
|
|
yield return boundNode;
|
|
yield return this;
|
|
}
|
|
|
|
public override Type Type => Type.Function;
|
|
public BoundScope Scope { get; set; }
|
|
}
|
|
} |