All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.qbicc.pointer.InitializerPointer Maven / Gradle / Ivy

There is a newer version: 0.77.0
Show newest version
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