ASTPointerType.java

package edu.udel.cis.vsl.tass.front.minimp.ast.type;

public class ASTPointerType extends ASTType implements ASTTypeIF {
  private ASTTypeIF baseType;

  public ASTPointerType(ASTTypeIF baseType) {
    if (baseType == null) {
      throw new NullPointerException(
          "Base type of a pointer type can not be null.");
    }
    this.baseType = baseType;
    this.hashCode = baseType.hashCode() + "pointer".hashCode();
  }

  public ASTTypeIF getBaseType() {
    return this.baseType;
  }

  public String toString() {
    return baseType.toString() + "*";
  }

  public boolean equals(Object that) {
    if (that instanceof ASTPointerType) {
      ASTPointerType temp = (ASTPointerType) that;
      if (temp.baseType.equals(this.baseType)) {
        return true;
      }
    }
    return false;
  }
}