MCPcopy Create free account
hub / github.com/airlift/bytecode / accept

Method accept

src/main/java/io/airlift/bytecode/control/TryCatch.java:67–116  ·  view source on GitHub ↗
(MethodVisitor visitor, MethodGenerationContext generationContext)

Source from the content-addressed store, hash-verified

65 }
66
67 @Override
68 public void accept(MethodVisitor visitor, MethodGenerationContext generationContext)
69 {
70 LabelNode tryStart = new LabelNode("tryStart");
71 LabelNode tryEnd = new LabelNode("tryEnd");
72 List<LabelNode> handlers = new ArrayList<>();
73 LabelNode done = new LabelNode("done");
74
75 BytecodeBlock block = new BytecodeBlock();
76
77 // try block
78 block.visitLabel(tryStart)
79 .append(tryNode)
80 .visitLabel(tryEnd)
81 .gotoLabel(done);
82
83 // catch blocks
84 for (int i = 0; i < catchBlocks.size(); i++) {
85 BytecodeNode handlerBlock = catchBlocks.get(i).getHandler();
86 LabelNode handler = new LabelNode("handler" + i);
87 handlers.add(handler);
88 block.visitLabel(handler)
89 .append(handlerBlock);
90 }
91
92 // all done
93 block.visitLabel(done);
94
95 block.accept(visitor, generationContext);
96
97 // exception table
98 for (int i = 0; i < catchBlocks.size(); i++) {
99 LabelNode handler = handlers.get(i);
100 List<ParameterizedType> exceptionTypes = catchBlocks.get(i).getExceptionTypes();
101 for (ParameterizedType type : exceptionTypes) {
102 visitor.visitTryCatchBlock(
103 tryStart.getLabel(),
104 tryEnd.getLabel(),
105 handler.getLabel(),
106 type.getClassName());
107 }
108 if (exceptionTypes.isEmpty()) {
109 visitor.visitTryCatchBlock(
110 tryStart.getLabel(),
111 tryEnd.getLabel(),
112 handler.getLabel(),
113 null);
114 }
115 }
116 }
117
118 @Override
119 public List<BytecodeNode> getChildNodes()

Callers

nothing calls this directly

Calls 12

visitLabelMethod · 0.95
acceptMethod · 0.95
getLabelMethod · 0.95
gotoLabelMethod · 0.80
appendMethod · 0.80
getHandlerMethod · 0.80
getMethod · 0.80
getExceptionTypesMethod · 0.80
getClassNameMethod · 0.80
isEmptyMethod · 0.80
addMethod · 0.45
visitTryCatchMethod · 0.45

Tested by

no test coverage detected