You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by gaurav shankar <sh...@hotmail.com> on 2003/04/22 11:28:27 UTC
adding invoke to a static method at begining of loop
Hi
I want to add call to a static method as the first line of the loop, but
whenever I try that loop index also get adjusted likewise.That is rather
than pointing to invoke of this method it points to same statement as
earlier. This makes call to my method on when it enters the loop.Please
suggest me way to make it get invoked each time loop iterates.
Thanks
Gaurav Shankar
MS,Rutgers University
USA
_________________________________________________________________
Gizmo freak? See what's the hottest. http://www.msn.co.in/Computing/Gizmos/
Read product reviews.
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: adding invoke to a static method at begining of loop
Posted by David Hovemeyer <da...@cs.umd.edu>.
On Tue, Apr 22, 2003 at 02:58:27PM +0530, gaurav shankar wrote:
> Hi
> I want to add call to a static method as the first line of the loop, but
> whenever I try that loop index also get adjusted likewise.That is rather
> than pointing to invoke of this method it points to same statement as
> earlier. This makes call to my method on when it enters the loop.Please
> suggest me way to make it get invoked each time loop iterates.
You need to update targeters of the original loop head instruction
so they refer to your new instruction instead. E.g.:
InstructionHandle oldTarget, newTarget;
// ...
if( oldTarget.hasTargeters() ){
InstructionTargeter[] targeters = oldTarget.getTargeters();
for(int i=0;i < targeters.length; i++){
targeters[i].updateTarget(oldTarget, newTarget);
newTarget.addTargeter(targeters[i]);
oldTarget.removeTargeter(targeters[i]);
}
}
-Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org