Upsilon/Upsilon/Binder/BoundStatements/BoundExpressionStatement.cs

36 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Upsilon.Evaluator;
using Upsilon.Text;
namespace Upsilon.Binder
{
public class BoundExpressionStatement : BoundStatement
{
public BoundExpression Expression { get; }
public override BoundKind Kind => BoundKind.BoundExpressionStatement;
public override IEnumerable<BoundNode> GetChildren()
{
yield return Expression;
}
public BoundExpressionStatement(BoundExpression expression, TextSpan span):base(span)
{
Expression = expression;
}
internal override void Evaluate(EvaluationScope scope, Diagnostics diagnostics, ref EvaluationState state)
{
var value = Expression.Evaluate(scope, diagnostics, ref state);
state.LastValue = value;
}
internal override IEnumerator EvaluateCoroutine(EvaluationScope scope, Diagnostics diagnostics, EvaluationState state)
{
var value = Expression.Evaluate(scope, diagnostics, ref state);
state.LastValue = value;
yield break;
}
}
}