Bug 32077 - [PATCH] LocalVariableTable.getLocalVariable isn't good enough
[PATCH] LocalVariableTable.getLocalVariable isn't good enough
Status: RESOLVED FIXED
Product: BCEL - Now in Jira
Classification: Unclassified
Component: Main
5.1
PC All
: P3 enhancement
: ---
Assigned To: issues@commons.apache.org
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2004-11-05 05:45 UTC by Dave Brosius
Modified: 2005-02-09 22:13 UTC (History)
0 users



Attachments
Patch to add getLocalVariable(int index, int pc) to LocalVariableTable (1.19 KB, patch)
2004-11-05 05:49 UTC, Dave Brosius
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Brosius 2004-11-05 05:45:04 UTC
This patch, adds another method to LocalVariableTable that looks up a 
LocalVariable by index AND PC.

-----------------

Index: src/java/org/apache/bcel/classfile/LocalVariableTable.java
===================================================================
RCS file: /home/cvspublic/jakarta-
bcel/src/java/org/apache/bcel/classfile/LocalVariableTable.java,v
retrieving revision 1.3
diff -u -r1.3 LocalVariableTable.java
--- src/java/org/apache/bcel/classfile/LocalVariableTable.java	23 May 2003 
07:55:12 -0000	1.3
+++ src/java/org/apache/bcel/classfile/LocalVariableTable.java	5 Nov 2004 
05:39:25 -0000
@@ -155,6 +155,19 @@
     return null;
   }
 
+  /** @return matching variable using index when variable is used at supplied 
pc
+   */
+  public final LocalVariable getLocalVariable(int index, int pc) {
+    for(int i=0; i < local_variable_table_length; i++)
+      if(local_variable_table[i].getIndex() == index) {
+        int start_pc = local_variable_table[i].getStartPC();
+        int end_pc = start_pc + local_variable_table[i].getLength();
+	      return local_variable_table[i];
+	  }
+
+    return null;
+  }
+  
   public final void setLocalVariableTable(LocalVariable[] 
local_variable_table)
   {
     this.local_variable_table = local_variable_table;
Comment 1 Dave Brosius 2004-11-05 05:49:47 UTC
Created attachment 13335 [details]
Patch to add getLocalVariable(int index, int pc) to LocalVariableTable
Comment 2 Dave Brosius 2004-11-05 05:50:18 UTC
ACK! ignore the message body. Use the attachment. Sorry.
Comment 3 Dave Brosius 2005-02-10 07:13:26 UTC
Applied to SVN, thanks!