From 33894b1cae728946d3363b5ad27fcbfcf33c86d1 Mon Sep 17 00:00:00 2001 From: chiba Date: Wed, 31 Dec 2003 05:56:29 +0000 Subject: CtBehavior#insertAt() and support methods have been implemented. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@63 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/bytecode/LocalVariableAttribute.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/javassist/bytecode/LocalVariableAttribute.java') diff --git a/src/main/javassist/bytecode/LocalVariableAttribute.java b/src/main/javassist/bytecode/LocalVariableAttribute.java index 74262b67..0bc273d5 100644 --- a/src/main/javassist/bytecode/LocalVariableAttribute.java +++ b/src/main/javassist/bytecode/LocalVariableAttribute.java @@ -68,6 +68,22 @@ public class LocalVariableAttribute extends AttributeInfo { return ByteArray.readU16bit(info, i * 10 + 4); } + /** + * Adjusts start_pc and length if bytecode is inserted in a method body. + */ + void shiftPc(int where, int gapLength, boolean exclusive) { + int n = tableLength(); + for (int i = 0; i < n; ++i) { + int pos = i * 10 + 2; + int pc = ByteArray.readU16bit(info, pos); + int len = ByteArray.readU16bit(info, pos + 2); + if (pc > where || (exclusive && pc == where)) + ByteArray.write16bit(pc + gapLength, info, pos); + else if (pc + len > where) + ByteArray.write16bit(len + gapLength, info, pos + 2); + } + } + /** * Returns local_variable_table[i].name_index. * This represents the name of the local variable. -- cgit v1.2.3