org.qbicc.pointer.InitializerPointer Maven / Gradle / Ivy
package org.qbicc.pointer;
import org.qbicc.type.definition.classfile.ClassFile;
import org.qbicc.type.definition.element.InitializerElement;
/**
* A pointer to a static initializer.
*/
public final class InitializerPointer extends RootPointer implements ExecutableElementPointer {
private final InitializerElement initializerElement;
InitializerPointer(InitializerElement initializerElement) {
super(initializerElement.getType().getPointer());
this.initializerElement = initializerElement;
}
public static InitializerPointer of(final InitializerElement initializerElement) {
return initializerElement.getOrCreatePointer(InitializerPointer::new);
}
public InitializerElement getExecutableElement() {
return initializerElement;
}
@Override
public int hashCode() {
return super.hashCode() * 19 + initializerElement.hashCode();
}
@Override
public boolean equals(final RootPointer other) {
return other instanceof InitializerPointer smp && equals(smp);
}
public boolean equals(final InitializerPointer other) {
return super.equals(other) && initializerElement == other.initializerElement;
}
@Override
public StringBuilder toString(StringBuilder b) {
return b.append('&').append(initializerElement.getEnclosingType().getInternalName()).append("");
}
public boolean isNoThrow() {
return getExecutableElement().hasNoModifiersOf(ClassFile.I_ACC_NO_THROW);
}
@Override
public boolean isNoSafePoints() {
return getExecutableElement().hasNoModifiersOf(ClassFile.I_ACC_NO_SAFEPOINTS);
}
@Override
public boolean isNoReturn() {
return getExecutableElement().hasNoModifiersOf(ClassFile.I_ACC_NO_RETURN);
}
@Override
public boolean isNoSideEffect() {
return getExecutableElement().hasNoModifiersOf(ClassFile.I_ACC_NO_SIDE_EFFECTS);
}
public R accept(final Visitor visitor, final T t) {
return visitor.visit(t, this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy