namespace Eflat
{
    /// <summary>
    /// A statement that assigns some binding to a new value.
    /// </summary>
    public sealed class AssignmentStatement : Statement
    {
        /// <summary>
        /// The binding being assigned to.
        /// </summary>
        public readonly Token Identifier; // TODO(zac, 28/06/2017): We need to be able to support struct members here...

        /// <summary>
        /// The value being assigned to the binding.
        /// </summary>
        public readonly Expression Value;

        public AssignmentStatement(Token identifier, Expression expression)
        {
            Identifier = identifier;
            Value = expression;
        }

        /// <summary>
        /// The location of this statement.
        /// </summary>
        public override StreamLocation Location => Identifier.Location;

        /// <summary>
        /// Whether this assignment requires a semicolon depends on the expression assigned to it.
        /// </summary>
        public override bool RequiresSemicolon => Value.RequiresSemicolon;
    }
}