package code.term;

import code.instr.Instruction;
import code.table.UndefinedSymbol;
import code.term.visitor.TermVisitor;

public class TermImplRef implements TermImpl {
    private Term term;

    /**
     * Constructor for the TermImplRef object
     *
     * @param term Term to which the reference refers
     */
    public TermImplRef(Term term) {
        this.term = term;
    }

    public TermImpl getRepresentation() {
        return term.getRepresentation();
    }

    public void update(Term t) {
        term.update(t);
    }

    /**
     * Returns the root id for this term.
     *
     * @return The root value
     */
    public int getRoot() {
        return term.getRoot();
    }

    /**
     * Returns the root symbol.
     *
     * @return The rootSymbol value
     */
    public String getRootSymbol() {
        return term.getRootSymbol();
    }


    /**
     * Returns the list of arguments for this term.
     *
     * @return The argument value
     */
    public Term[] getArgument() {
        return term.getArgument();
    }


    /**
     * Gets the argument attribute of the TermImpl object
     *
     * @param number Description of the Parameter
     * @return The argument value
     */
    public Term getArgument(byte number) {
        return term.getArgument(number);
    }


    /**
     * Gets the kind attribute of the TermImpl object
     *
     * @return The kind value
     * @throws UndefinedSymbol Description of the Exception
     */
    public byte getKind() throws UndefinedSymbol {
        return term.getKind();
    }


    /**
     * Gets the hNF attribute of the TermImpl object
     *
     * @return The hNF value
     */
    public boolean isHNF() {
        return term.isHNF();
    }


    /**
     * Gets the nF attribute of the TermImpl object
     *
     * @return The nF value
     */
    public boolean isNF() {
        return term.isNF();
    }


    /**
     * Gets the code attribute of the TermImpl object
     *
     * @return The code value
     * @throws UndefinedSymbol Description of the Exception
     */
    public Instruction[] getCode() throws UndefinedSymbol {
        return term.getCode();
    }

    /**
     * This method accepts the visitor.
     *
     * @param v
     * @param o
     * @return Object
     */
    public <R,T> R accept(TermVisitor<R,T> v, T o) {
        return term.representation.accept(v, o);
    }

}

