package heat; import st.TypeEnum; import st.ClassInstance; /** * A simple wrapper for TypeEnum, * meant to provide all helper methods * and structures for evaluating typing. */ class TypeBundle { private TypeEnum type; private ClassInstance instance; protected TypeBundle(TypeEnum type, ClassInstance instance) { this.type = type; this.instance = instance; } @Override public String toString() { String cls = (this.instance != null) ? String.format(" (%s)", this.instance) : ""; return String.format("%s%s", this.type, cls); } @Override public boolean equals(Object other) { TypeBundle tb; return (other instanceof TypeBundle) && (tb = (TypeBundle) other).type == this.type && (tb.instance == this.instance || (tb.instance != null && tb.instance.getExtend() != null && tb.instance.getExtend().equals(this.instance))); } public boolean isClass() { return this.type == TypeEnum.classname; } public boolean isMethod() { return this.type == TypeEnum.method; } public boolean isArray() { return this.type == TypeEnum.intarray; } public boolean isBool() { return this.type == TypeEnum.bool; } public boolean isInt() { return this.type == TypeEnum.integer; } public TypeEnum getType() { return this.type; } public ClassInstance getInstance() { return this.instance; } }