/** * Emits an unsigned LEB128 value. * * @param n {@code >= 0;} value to emit. Note that, although this can * represent integers larger than Integer.MAX_VALUE, we currently don't * allow that. * @throws IOException */ private void emitUnsignedLeb128(int n) throws IOException { // We'll never need the top end of the unsigned range anyway. if (n < 0) { throw new RuntimeException( "Signed value where unsigned required: " + n); } output.writeUnsignedLeb128(n); }
/** * Emits a type index as an unsigned LEB128. The actual value written * is shifted by 1, so that the '0' value is reserved for "null". * * @param type {@code null-ok;} type to emit * @throws IOException */ private void emitTypeIndex(CstType type) throws IOException { if ((type == null) || (file == null)) { output.writeUnsignedLeb128(0); } else { output.writeUnsignedLeb128( 1 + file.getTypeIds().indexOf(type)); } if (DEBUG) { System.err.printf("Emit type %s\n", type == null ? "<null>" : type.toHuman()); } }
/** * Emits a string index as an unsigned LEB128. The actual value written * is shifted by 1, so that the '0' value is reserved for "null". The * null symbol is used in some cases by the parameter name list * at the beginning of the sequence. * * @param string {@code null-ok;} string to emit * @throws IOException */ private void emitStringIndex(CstUtf8 string) throws IOException { if ((string == null) || (file == null)) { output.writeUnsignedLeb128(0); } else { output.writeUnsignedLeb128( 1 + file.getStringIds().indexOf(string)); } if (DEBUG) { System.err.printf("Emit string %s\n", string == null ? "<null>" : string.toQuoted()); } }
/** * Emits an {@link DebugInfoConstants#DBG_ADVANCE_PC DBG_ADVANCE_PC} * sequence. * * @param deltaAddress {@code >= 0;} amount to change program counter by * @throws IOException */ private void emitAdvancePc(int deltaAddress) throws IOException { int mark = output.getCursor(); output.writeByte(DBG_ADVANCE_PC); output.writeUnsignedLeb128(deltaAddress); address += deltaAddress; if (annotateTo != null || debugPrint != null) { annotate(output.getCursor() - mark, String.format("%04x: advance pc", address)); } if (DEBUG) { System.err.printf("Emitting advance_pc for %d\n", deltaAddress); } }
/** * Emits a {@link DebugInfoConstants#DBG_END_LOCAL DBG_END_LOCAL} sequence. * * @param entry {@code entry non-null;} entry associated with end. * @throws IOException */ private void emitLocalEnd(LocalList.Entry entry) throws IOException { int mark = output.getCursor(); output.writeByte(DBG_END_LOCAL); output.writeUnsignedLeb128(entry.getRegister()); if (annotateTo != null || debugPrint != null) { annotate(output.getCursor() - mark, String.format("%04x: -local %s", address, entryAnnotationString(entry))); } if (DEBUG) { System.err.println("emit local end"); } }
out.writeUnsignedLeb128(handlerOffsets.size()); out.writeUnsignedLeb128( typeIds.indexOf(entry.getExceptionType())); out.writeUnsignedLeb128(entry.getHandler()); out.writeUnsignedLeb128(list.get(listSize).getHandler());
line = entry.getPosition().getLine(); output.writeUnsignedLeb128(line); output.writeUnsignedLeb128(szParamTypes);