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

/**
 *
 * @author matthew
 */
final public class FixedPointVariableType extends VariableType {

    public FixedPointVariableType(boolean signed, int digits, int fractionPart) {
        m_isSigned = signed;
        m_digits = digits;
        m_fractionPart = fractionPart;
    }

    public boolean isSigned() {
        return m_isSigned;
    }

    public int digits() {
        return m_digits;
    }

    public int fractionPart() {
        return m_fractionPart;
    }

    @Override
    public boolean canCastToType(VariableType type) {
        return false;
    }

    @Override
    public boolean equals(Object othero) {
        if (!(othero instanceof FixedPointVariableType)) {
            return false;
        } else {
            FixedPointVariableType other = (FixedPointVariableType) othero;
            if (other.m_isSigned == m_isSigned
                    && other.m_digits == m_digits
                    && other.m_fractionPart == m_fractionPart) {
                return true;
            } else {
                return false;
            }
        }
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (this.m_isSigned ? 1 : 0);
        hash = 2 * hash + this.m_fractionPart;
        hash = 83 * hash + this.m_digits;
        return hash;
    }

    private final int m_fractionPart;
    private final int m_digits;
    private final boolean m_isSigned;

    public static class Marker implements VariableTypeMarker {
        @Override
        public boolean isMarkerFor(VariableType m_type) {
            return m_type instanceof FixedPointVariableType;
        }
    }
}
