Re: Re: Re: Re: Two MethodVisitor with the same instances of Labels

Grzegorz Głąb <[email protected]> Thu, 20 Mar 2014 13:31:31 +0100
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Dnia 2014-03-20, o godz. 12:09:49
John Bergin <[email protected]> napisał(a):

> Grzesiek - if you want to stick with the Core API
> then for each pass labels will be visited in the
> same order and you could use your own mapping
> for label names that is consistent across each
> pass. You could add the following to your
> MethodVisitor.
> 
> // LabelData is whatever you want to store about the labels.
> static Map<Integer, LabelData> labels;
> 
> Integer currentLabel;
> 
> // This is visited before visitLabel.
> visitTryCatchBlock(Label start, Label end, Label handler, String
> type) { addLabel(start);
>      // And do the same for the remaining Label parameters.
> }
> 
> visitLabel(Label label) {
>      addLabel(label);
>      currentLabel = getLabel(label);
> }
> 
> // Took this from somewhere in the ASM code base I
> // think I might have taken it from the Textifier class.
> void addLabel(Label label) {
>      LabelData ld = labels.get(label);
>      if( ld == null ) {
>          labels.put(Integer.valueOf(labels.size()), new LabelData());
>      }
> }
> 
> LabelData getLabel(Label label) {
>      return labels.get( label );
> }
> 
> Hope this helps.
> 


Hi,

thank for answer, to clarify : I need two two separate
reader.accept(**) calls, right?

reader.accept(VisitorWithMethodCollector);
reader.accept(VisitorBasingOfPreviousCollectedData);

AFAIK it is not possible to do it in core API in chained ClassVisitor
with one reader.accept() call, or maybe there is some trick to do it ?

Regards,

Grzesiek
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws