You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
902 B

package chocopy.common.analysis.types;
import chocopy.common.astnodes.ClassType;
import chocopy.common.astnodes.ListType;
import chocopy.common.astnodes.TypeAnnotation;
/**
* A ValueType references types that are assigned to variables and expressions.
*
* <p>In particular, ValueType can be a {@link ClassValueType} (e.g. "int") or a {@link
* ListValueType} (e.g. "[int]").
*/
public abstract class ValueType extends Type {
/** Returns the type corresponding to ANNOTATION. */
public static ValueType annotationToValueType(TypeAnnotation annotation) {
if (annotation instanceof ClassType) {
return new ClassValueType((ClassType) annotation);
} else {
assert annotation instanceof ListType;
return new ListValueType((ListType) annotation);
}
}
@Override
public boolean isValueType() {
return true;
}
}