package chocopy.common.analysis.types;

import chocopy.common.astnodes.ClassType;
import chocopy.common.astnodes.Identifier;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import chocopy.common.analysis.SymbolTable;
import java.util.Objects;

/** Represents the semantic value of a simple class reference. */
public class ClassVType extends ValueType {

    /** The name of the class. */
    public final String className;
    public SymbolTable<Type> scope;
    public ClassVType super_class;
    /** A class type for the class named CLASSNAME. */
    @JsonCreator
    public ClassVType(@JsonProperty String className) {
        this.className = className;
    }

    /** A class type for the class referenced by CLASSTYPEANNOTATION. */
    public ClassVType(ClassType classTypeAnnotation) {
        this.className = classTypeAnnotation.className;
    }

    @Override
    @JsonProperty
    public String className() {
        return className;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ClassVType classType = (ClassVType) o;
        return Objects.equals(className, classType.className);
    }

    @Override
    public int hashCode() {
        return Objects.hash(className);
    }

    @Override
    public String toString() {
        return className;
    }
}
