// Mike Maxim
// Abstract type

package edu.cmu.cs.l3.semant;

import java.util.*;

abstract public class Ty {

    public Ty(int size, String name) {
	m_size = size; m_name = name;
    }

    public boolean isEquivalent(Ty type) {

        //Variant check
        if (type instanceof TyPointer && this instanceof TyPointer) {
            if ( (((TyPointer)type).getUnderType() instanceof TyNonsense) ||
                 (((TyPointer)this).getUnderType() instanceof TyNonsense))
                return true;
        }

        //Variant check
        if (type instanceof TyNonsense || this instanceof TyNonsense) {
            return true;
        }

        return (type.getName().equals(m_name));
    }

    public String getName() {
	return m_name;
    }

    public int getSize() {
	return m_size;
    }

    public boolean isEscaping() {
        return m_escapes;
    }

    public void setEscape(boolean v) {
        m_escapes = v;
    }

    protected int m_size;
    protected String m_name;
    protected boolean m_escapes=false;
}