org.qbicc.graph.literal.ObjectLiteral Maven / Gradle / Ivy
package org.qbicc.graph.literal;
import java.util.Objects;
import org.qbicc.interpreter.VmObject;
import org.qbicc.type.PhysicalObjectType;
import org.qbicc.type.ReferenceType;
/**
*
*/
public final class ObjectLiteral extends WordLiteral {
private final ReferenceType type;
private final VmObject value;
private final int hashCode;
ObjectLiteral(final ReferenceType type, final VmObject value) {
this.type = type;
this.value = value;
hashCode = Objects.hash(type, value);
}
public ReferenceType getType() {
return type;
}
public PhysicalObjectType getObjectType() {
return value.getObjectType();
}
public VmObject getValue() {
return value;
}
public R accept(final LiteralVisitor visitor, final T param) {
return visitor.visit(param, this);
}
public boolean isZero() {
return false;
}
public boolean isNullable() {
return false;
}
public boolean equals(final Literal other) {
return other instanceof ObjectLiteral && equals((ObjectLiteral) other);
}
public boolean equals(final ObjectLiteral other) {
return this == other || other != null && type.equals(other.type) && value.equals(other.value);
}
public int hashCode() {
return hashCode;
}
@Override
public StringBuilder toString(StringBuilder b) {
return b.append("object").append('(').append(value).append(')');
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy