ExpressionStatement
using CLanguage.Compiler;
using CLanguage.Interpreter;
using System.Runtime.CompilerServices;
namespace CLanguage.Syntax
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class ExpressionStatement : Statement
{
public Expression Expression { get; set; }
public override bool AlwaysReturns => false;
public ExpressionStatement(Expression expr)
{
Expression = expr;
}
protected override void DoEmit(EmitContext ec)
{
if (Expression != null) {
Expression.Emit(ec);
ec.Emit(OpCode.Pop);
}
}
public override string ToString()
{
return $"{Expression}""";
}
}
}