29 lines
828 B
C#
29 lines
828 B
C#
using System.Collections.Generic;
|
|
using Upsilon.Evaluator;
|
|
using Upsilon.Text;
|
|
|
|
namespace Upsilon.Binder
|
|
{
|
|
public class BoundReturnStatement : BoundStatement
|
|
{
|
|
public BoundReturnStatement(BoundExpression expression, TextSpan span) : base(span)
|
|
{
|
|
Expression = expression;
|
|
}
|
|
|
|
public BoundExpression Expression { get; }
|
|
public override BoundKind Kind => BoundKind.BoundReturnStatement;
|
|
|
|
public override IEnumerable<BoundNode> GetChildren()
|
|
{
|
|
yield return Expression;
|
|
}
|
|
|
|
internal override void Evaluate(EvaluationScope scope, Diagnostics diagnostics, ref EvaluationState state)
|
|
{
|
|
state.ReturnValue = Expression?.Evaluate(scope, diagnostics, ref state);
|
|
state.Returned = true;
|
|
|
|
}
|
|
}
|
|
} |