aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/apache/bcel/generic/LocalVariableGen.java')
-rw-r--r--src/main/java/org/apache/bcel/generic/LocalVariableGen.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/org/apache/bcel/generic/LocalVariableGen.java b/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
index 0698e15e..d5ee8fcd 100644
--- a/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
+++ b/src/main/java/org/apache/bcel/generic/LocalVariableGen.java
@@ -37,6 +37,7 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo
private Type type;
private InstructionHandle start;
private InstructionHandle end;
+ private int orig_index; // never changes; used to match up with LocalVariableTypeTable entries
/**
@@ -59,6 +60,25 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo
this.index = index;
setStart(start);
setEnd(end);
+ this.orig_index = index;
+ }
+
+
+ /**
+ * Generate a local variable that with index `index'. Note that double and long
+ * variables need two indexs. Index indices have to be provided by the user.
+ *
+ * @param index index of local variable
+ * @param name its name
+ * @param type its type
+ * @param start from where the instruction is valid (null means from the start)
+ * @param end until where the instruction is valid (null means to the end)
+ * @param orig_index index of local variable prior to any changes to index
+ */
+ public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start,
+ final InstructionHandle end, final int orig_index) {
+ this(index, name, type, start, end);
+ this.orig_index = orig_index;
}
@@ -89,7 +109,7 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo
final int name_index = cp.addUtf8(name);
final int signature_index = cp.addUtf8(type.getSignature());
return new LocalVariable(start_pc, length, name_index, signature_index, index, cp
- .getConstantPool());
+ .getConstantPool(), orig_index);
}
@@ -103,6 +123,11 @@ public class LocalVariableGen implements InstructionTargeter, NamedAndTyped, Clo
}
+ public int getOrigIndex() {
+ return orig_index;
+ }
+
+
@Override
public void setName( final String name ) {
this.name = name;