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

dataflow.src.org.checkerframework.dataflow.cfg.block.BlockImpl Maven / Gradle / Ivy

Go to download

The Checker Framework enhances Java’s type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins ("checkers") that find bugs or verify their absence. It also permits you to write your own compiler plug-ins.

There is a newer version: 3.42.0
Show newest version
package org.checkerframework.dataflow.cfg.block;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * Base class of the {@link Block} implementation hierarchy.
 *
 * @author Stefan Heule
 *
 */
public abstract class BlockImpl implements Block {

    /** A unique ID for this node. */
    protected long id = BlockImpl.uniqueID();

    /** The last ID that has already been used. */
    protected static long lastId = 0;

    /** The type of this basic block. */
    protected BlockType type;

    /** The set of predecessors. */
    protected Set predecessors;

    /**
     * @return a fresh identifier
     */
    private static long uniqueID() {
        return lastId++;
    }

    public BlockImpl() {
        predecessors = new HashSet<>();
    }

    @Override
    public long getId() {
        return id;
    }

    @Override
    public BlockType getType() {
        return type;
    }

    /**
     * @return the list of predecessors of this basic block
     */
    public Set getPredecessors() {
        return Collections.unmodifiableSet(predecessors);
    }

    public void addPredecessor(BlockImpl pred) {
        predecessors.add(pred);
    }

    public void removePredecessor(BlockImpl pred) {
        predecessors.remove(pred);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy