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

org.qbicc.graph.literal.PointerLiteral Maven / Gradle / Ivy

There is a newer version: 0.77.0
Show newest version
package org.qbicc.graph.literal;

import org.qbicc.pointer.Pointer;
import org.qbicc.type.PointerType;
import org.qbicc.type.ValueType;

/**
 * A literal referring to some program object.
 */
public final class PointerLiteral extends WordLiteral {
    private final Pointer pointer;

    PointerLiteral(Pointer pointer) {
        this.pointer = pointer;
    }

    @Override
    public StringBuilder toString(StringBuilder b) {
        return b.append(pointer);
    }

    @Override
    public PointerType getType() {
        return pointer.getType();
    }

    public ValueType getValueType() {
        return getType().getPointeeType();
    }

    public  T getValueType(Class expected) {
        return getType().getPointeeType(expected);
    }

    public Pointer getPointer() {
        return pointer;
    }

    public 

P getPointer(Class

expected) { return expected.cast(getPointer()); } @Override public R accept(LiteralVisitor visitor, T param) { return visitor.visit(param, this); } @Override public boolean isZero() { return false; } @Override public boolean equals(Literal other) { return other instanceof PointerLiteral pol && equals(pol); } public boolean equals(PointerLiteral other) { return this == other || other != null && pointer.equals(other.pointer); } @Override public int hashCode() { return pointer.hashCode(); } @Override public boolean isNoThrow() { return pointer.isNoThrow(); } @Override public boolean isNoSafePoints() { return pointer.isNoSafePoints(); } @Override public boolean isNoReturn() { return pointer.isNoReturn(); } @Override public boolean isNoSideEffect() { return pointer.isNoSideEffect(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy