stream.writeShort(ca.getStackFrames().size());
int lastPos = -1;
for (Entry<Integer, StackFrame> entry : method.getCodeAttribute().getStackFrames().entrySet()) {
int offset = entry.getKey() - lastPos - 1;
lastPos = entry.getKey();
StackFrame frame = entry.getValue();
if (frame.getType() == StackFrameType.SAME_FRAME || frame.getType() == StackFrameType.SAME_FRAME_EXTENDED) {
writeSameFrame(stream, offset, lastPos, frame);
} else if (frame.getType() == StackFrameType.SAME_LOCALS_1_STACK && offset < (127 - 64)) {
writeSameLocals1Stack(stream, offset, lastPos, frame);
} else {
writeFullFrame(stream, offset, lastPos, entry.getValue());
}
}