| 53 | import static io.airlift.bytecode.instruction.VariableInstruction.storeVariable; |
| 54 | |
| 55 | @SuppressWarnings("UnusedDeclaration") |
| 56 | @NotThreadSafe |
| 57 | public class BytecodeBlock |
| 58 | implements BytecodeNode |
| 59 | { |
| 60 | private final List<BytecodeNode> nodes = new ArrayList<>(); |
| 61 | |
| 62 | private String description; |
| 63 | private int currentLineNumber = -1; |
| 64 | |
| 65 | public String getDescription() |
| 66 | { |
| 67 | return description; |
| 68 | } |
| 69 | |
| 70 | public BytecodeBlock setDescription(String description) |
| 71 | { |
| 72 | this.description = description; |
| 73 | return this; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public List<BytecodeNode> getChildNodes() |
| 78 | { |
| 79 | return ImmutableList.copyOf(nodes); |
| 80 | } |
| 81 | |
| 82 | public BytecodeBlock append(BytecodeNode node) |
| 83 | { |
| 84 | nodes.add(node); |
| 85 | return this; |
| 86 | } |
| 87 | |
| 88 | public BytecodeBlock comment(String comment) |
| 89 | { |
| 90 | nodes.add(new Comment(comment)); |
| 91 | return this; |
| 92 | } |
| 93 | |
| 94 | public BytecodeBlock comment(String comment, Object... args) |
| 95 | { |
| 96 | nodes.add(new Comment(String.format(comment, args))); |
| 97 | return this; |
| 98 | } |
| 99 | |
| 100 | public boolean isEmpty() |
| 101 | { |
| 102 | return nodes.isEmpty(); |
| 103 | } |
| 104 | |
| 105 | public BytecodeBlock visitLabel(LabelNode label) |
| 106 | { |
| 107 | nodes.add(label); |
| 108 | return this; |
| 109 | } |
| 110 | |
| 111 | public BytecodeBlock gotoLabel(LabelNode label) |
| 112 | { |
nothing calls this directly
no outgoing calls
no test coverage detected