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

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

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

import java.util.Objects;

import org.qbicc.graph.BasicBlock;
import org.qbicc.graph.BlockLabel;
import org.qbicc.type.BlockType;

public final class BlockLiteral extends Literal {
    private final BlockType type;
    private final BlockLabel blockLabel;
    private final int hashCode;

    BlockLiteral(final BlockType type, final BlockLabel blockLabel) {
        this.type = type;
        this.blockLabel = blockLabel;
        hashCode = Objects.hash(BlockLiteral.class, blockLabel);
    }

    public BlockType getType() {
        return type;
    }

    public BlockLabel getBlockLabel() {
        return blockLabel;
    }

    public BasicBlock getBlock() {
        return BlockLabel.getTargetOf(blockLabel);
    }

    public boolean isZero() {
        return false;
    }

    public boolean equals(final Literal other) {
        return other instanceof BlockLiteral && equals((BlockLiteral) other);
    }

    public boolean equals(final BlockLiteral other) {
        return this == other || other != null && blockLabel.equals(other.blockLabel) && type.equals(other.type);
    }

    public int hashCode() {
        return hashCode;
    }

    public  R accept(final LiteralVisitor visitor, final T param) {
        return visitor.visit(param, this);
    }

    @Override
    public StringBuilder toString(StringBuilder b) {
        return b.append("block").append('(').append(blockLabel).append(')');
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy