org.qbicc.pointer.ReferenceAsPointer Maven / Gradle / Ivy
package org.qbicc.pointer;
import org.qbicc.interpreter.Memory;
import org.qbicc.interpreter.VmObject;
/**
* A reference to an object which is converted into a pointer.
*/
public final class ReferenceAsPointer extends RootPointer {
private final VmObject reference;
public ReferenceAsPointer(VmObject reference) {
super(reference.getObjectType().getPointer());
this.reference = reference;
}
public VmObject getReference() {
return reference;
}
@Override
public Memory getRootMemoryIfExists() {
return reference.getMemory();
}
@Override
public int hashCode() {
return super.hashCode() * 19 + reference.hashCode();
}
@Override
public boolean equals(RootPointer other) {
return other instanceof ReferenceAsPointer rap && equals(rap);
}
public boolean equals(ReferenceAsPointer other) {
return this == other || super.equals(other) && reference == other.reference;
}
@Override
public StringBuilder toString(StringBuilder b) {
return b.append("refToPtr(").append(reference).append(")");
}
public R accept(final Visitor visitor, final T t) {
return visitor.visit(t, this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy