[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bcel-user
Subject:    Re: adding invoke to a static method at begining of loop
From:       David Hovemeyer <daveho () cs ! umd ! edu>
Date:       2003-04-22 15:10:33
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic