/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.matlab2smt;

/**
 *
 * @author matthew
 */
public class Variable implements MatlabExpression, MatlabExpressionValue {
    protected Variable(String name, VariableType type) {
        m_name = name;
        m_type = type;
    }

    public String name() {
        return m_name;
    }

    public VariableType type() {
        return m_type;
    }

    @Override
    public VariableType actualOutputTypeForRequestedOutput(VariableTypeMarker requestedType) {
        if (requestedType.isMarkerFor(m_type)) {
            return m_type;
        }
        return null;
    }

    private String m_name;
    private VariableType m_type;

    @Override
    public String getCheckerOutput(CheckerGenerator generator, VariableType requestedType) {
        if (!type().equals(requestedType)) {
            throw new IllegalArgumentException("Requested output type is not the expression's output type!");
        }
        return m_name;
    }

    @Override
    public String toString() {
        return m_name;
    }
}
