package pp.s1184725.boppi.type;

import pp.iloc.eval.Machine;

/**
 * A vector type of run-time defined size. Takes a type parameter.
 * 
 * @author Frank Wibbelink
 */
public class ArrayType implements ReferenceType {
	private Type elType;

	/**
	 * Creates a new array type with the given number of elements and their
	 * type.
	 * 
	 * @param type
	 *            the type of elements
	 */
	public ArrayType(Type type) {
		this.elType = type;
	}

	@Override
	public int getSize() {
		return Machine.INT_SIZE;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof ArrayType))
			return false;

		ArrayType other = (ArrayType) obj;
		return elType.equals(other.elType);
	}
	
	@Override
	public String toString() {
		return elType.toString()+"[]";
	}

	/**
	 * Returns the type of the elements in this array.
	 * 
	 * @return the type of the elements
	 */
	public Type getType() {
		return elType;
	}
}
