aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/checker_framework_dataflow/java/org/checkerframework/dataflow/cfg/block/BlockImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/checker_framework_dataflow/java/org/checkerframework/dataflow/cfg/block/BlockImpl.java')
-rw-r--r--third_party/checker_framework_dataflow/java/org/checkerframework/dataflow/cfg/block/BlockImpl.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/third_party/checker_framework_dataflow/java/org/checkerframework/dataflow/cfg/block/BlockImpl.java b/third_party/checker_framework_dataflow/java/org/checkerframework/dataflow/cfg/block/BlockImpl.java
new file mode 100644
index 0000000000..568b62b071
--- /dev/null
+++ b/third_party/checker_framework_dataflow/java/org/checkerframework/dataflow/cfg/block/BlockImpl.java
@@ -0,0 +1,63 @@
+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<BlockImpl> 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<BlockImpl> getPredecessors() {
+ return Collections.unmodifiableSet(predecessors);
+ }
+
+ public void addPredecessor(BlockImpl pred) {
+ predecessors.add(pred);
+ }
+
+ public void removePredecessor(BlockImpl pred) {
+ predecessors.remove(pred);
+ }
+
+}