blob: 853f2c94f09b37bf709f584c50c3694fc4d87936 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package org.checkerframework.dataflow.cfg.block;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.checkerframework.dataflow.cfg.node.Node;
/**
* Implementation of a regular basic block.
*
* @author Stefan Heule
*
*/
public class RegularBlockImpl extends SingleSuccessorBlockImpl implements
RegularBlock {
/** Internal representation of the contents. */
protected List<Node> contents;
/**
* Initialize an empty basic block to be filled with contents and linked to
* other basic blocks later.
*/
public RegularBlockImpl() {
contents = new LinkedList<>();
type = BlockType.REGULAR_BLOCK;
}
/**
* Add a node to the contents of this basic block.
*/
public void addNode(Node t) {
contents.add(t);
t.setBlock(this);
}
/**
* Add multiple nodes to the contents of this basic block.
*/
public void addNodes(List<? extends Node> ts) {
for (Node t : ts) {
addNode(t);
}
}
@Override
public List<Node> getContents() {
return Collections.unmodifiableList(contents);
}
@Override
public BlockImpl getRegularSuccessor() {
return successor;
}
@Override
public String toString() {
return "RegularBlock(" + contents + ")";
}
@Override
public boolean isEmpty() {
return contents.isEmpty();
}
}
|