/* This file was generated by SableCC (http://www.sablecc.org/).  
 * Then modified.
 */
package ast.node;

import ast.visitor.*;

@SuppressWarnings("nls")
public final class AssignStatement extends IStatement
{
    private String _id_;
    private IExp _exp_;

    public AssignStatement(int _line_, int _pos_, String _id_, IExp _exp_)
    {
        super(_line_, _pos_);

        setId(_id_);
        setExp(_exp_);

    }

    @Override
    public int getNumExpChildren() { return 1; }
    
    @Override
    public Object clone()
    {
        return new AssignStatement(
                this.getLine(),
                this.getPos(),
                this._id_,
                cloneNode(this._exp_));
    }

    public void accept(Visitor v)
    {
        v.visitAssignStatement(this);
    }

    public void setId(String id) {
        this._id_ = id;
    }
    
    public String getId() {
        return this._id_;
    }

    public IExp getExp()
    {
        return this._exp_;
    }

    public void setExp(IExp node)
    {
        if(this._exp_ != null)
        {
            this._exp_.parent(null);
        }

        if(node != null)
        {
            if(node.parent() != null)
            {
                node.parent().removeChild(node);
            }

            node.parent(this);
        }

        this._exp_ = node;
    }

    @Override
    void removeChild(Node child)
    {
        if(this._exp_ == child)
        {
            this._exp_ = null;
            return;
        }

        throw new RuntimeException("Not a child.");
    }

    @Override
    void replaceChild(Node oldChild, Node newChild)
    {
        if(this._exp_ == oldChild)
        {
            setExp((IExp) newChild);
            return;
        }

        throw new RuntimeException("Not a child.");
    }
}
