org.objectweb.asm.Label.addForwardReference()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.objectweb.asm.Label.addForwardReference()方法的一些代码示例,展示了Label.addForwardReference()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Label.addForwardReference()方法的具体详情如下:
包路径:org.objectweb.asm.Label
类名称:Label
方法名:addForwardReference

Label.addForwardReference介绍

[英]Adds a forward reference to this label. This method must be called only for a true forward reference, i.e. only if this label is not resolved yet. For backward references, the relative bytecode offset of the reference can be, and must be, computed and stored directly.
[中]添加对此标签的正向引用。必须仅为真正的正向引用调用此方法,即仅当尚未解析此标签时才调用此方法。对于向后引用,可以并且必须直接计算和存储引用的相对字节码偏移量。

代码示例

代码示例来源:origin: org.ow2.asm/asm

/**
 * Puts a reference to this label in the bytecode of a method. If the bytecode offset of the label
 * is known, the relative bytecode offset between the label and the instruction referencing it is
 * computed and written directly. Otherwise, a null relative offset is written and a new forward
 * reference is declared for this label.
 *
 * @param code the bytecode of the method. This is where the reference is appended.
 * @param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the
 *     reference to be appended.
 * @param wideReference whether the reference must be stored in 4 bytes (instead of 2 bytes).
 */
final void put(
  final ByteVector code, final int sourceInsnBytecodeOffset, final boolean wideReference) {
 if ((flags & FLAG_RESOLVED) == 0) {
  if (wideReference) {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_WIDE, code.length);
   code.putInt(-1);
  } else {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_SHORT, code.length);
   code.putShort(-1);
  }
 } else {
  if (wideReference) {
   code.putInt(bytecodeOffset - sourceInsnBytecodeOffset);
  } else {
   code.putShort(bytecodeOffset - sourceInsnBytecodeOffset);
  }
 }
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.framework.extension

/**
 * Puts a reference to this label in the bytecode of a method. If the bytecode offset of the label
 * is known, the relative bytecode offset between the label and the instruction referencing it is
 * computed and written directly. Otherwise, a null relative offset is written and a new forward
 * reference is declared for this label.
 *
 * @param code the bytecode of the method. This is where the reference is appended.
 * @param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the
 *     reference to be appended.
 * @param wideReference whether the reference must be stored in 4 bytes (instead of 2 bytes).
 */
final void put(
  final ByteVector code, final int sourceInsnBytecodeOffset, final boolean wideReference) {
 if ((flags & FLAG_RESOLVED) == 0) {
  if (wideReference) {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_WIDE, code.length);
   code.putInt(-1);
  } else {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_SHORT, code.length);
   code.putShort(-1);
  }
 } else {
  if (wideReference) {
   code.putInt(bytecodeOffset - sourceInsnBytecodeOffset);
  } else {
   code.putShort(bytecodeOffset - sourceInsnBytecodeOffset);
  }
 }
}

代码示例来源:origin: org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle

/**
 * Puts a reference to this label in the bytecode of a method. If the bytecode offset of the label
 * is known, the relative bytecode offset between the label and the instruction referencing it is
 * computed and written directly. Otherwise, a null relative offset is written and a new forward
 * reference is declared for this label.
 *
 * @param code the bytecode of the method. This is where the reference is appended.
 * @param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the
 *     reference to be appended.
 * @param wideReference whether the reference must be stored in 4 bytes (instead of 2 bytes).
 */
final void put(
  final ByteVector code, final int sourceInsnBytecodeOffset, final boolean wideReference) {
 if ((flags & FLAG_RESOLVED) == 0) {
  if (wideReference) {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_WIDE, code.length);
   code.putInt(-1);
  } else {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_SHORT, code.length);
   code.putShort(-1);
  }
 } else {
  if (wideReference) {
   code.putInt(bytecodeOffset - sourceInsnBytecodeOffset);
  } else {
   code.putShort(bytecodeOffset - sourceInsnBytecodeOffset);
  }
 }
}

代码示例来源:origin: com.bladejava/blade-asm

/**
 * Puts a reference to this label in the bytecode of a method. If the bytecode offset of the label
 * is known, the relative bytecode offset between the label and the instruction referencing it is
 * computed and written directly. Otherwise, a null relative offset is written and a new forward
 * reference is declared for this label.
 *
 * @param code the bytecode of the method. This is where the reference is appended.
 * @param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the
 *     reference to be appended.
 * @param wideReference whether the reference must be stored in 4 bytes (instead of 2 bytes).
 */
final void put(
  final ByteVector code, final int sourceInsnBytecodeOffset, final boolean wideReference) {
 if ((flags & FLAG_RESOLVED) == 0) {
  if (wideReference) {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_WIDE, code.length);
   code.putInt(-1);
  } else {
   addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_SHORT, code.length);
   code.putShort(-1);
  }
 } else {
  if (wideReference) {
   code.putInt(bytecodeOffset - sourceInsnBytecodeOffset);
  } else {
   code.putShort(bytecodeOffset - sourceInsnBytecodeOffset);
  }
 }
}

相关文章