KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > transform > inlining > weaver > LabelToLineNumberVisitor


1 /**************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package org.codehaus.aspectwerkz.transform.inlining.weaver;
9
10 import org.objectweb.asm.ClassAdapter;
11 import org.objectweb.asm.ClassVisitor;
12 import org.objectweb.asm.CodeVisitor;
13 import org.objectweb.asm.Attribute;
14 import org.objectweb.asm.CodeAdapter;
15 import org.objectweb.asm.Label;
16 import org.codehaus.aspectwerkz.transform.inlining.ContextImpl;
17 import org.codehaus.aspectwerkz.transform.Context;
18
19 /**
20  * @author <a HREF="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
21  */

22 public class LabelToLineNumberVisitor extends ClassAdapter {
23
24     private ContextImpl m_ctx;
25
26     public LabelToLineNumberVisitor(ClassVisitor cv, Context ctx) {
27         super(cv);
28         m_ctx = (ContextImpl)ctx;
29     }
30
31     public CodeVisitor visitMethod(int i, String JavaDoc s, String JavaDoc s1, String JavaDoc[] strings, Attribute attribute) {
32         return new CodeAdapter(super.visitMethod(i, s, s1, strings, attribute)) {
33             public void visitLineNumber(int i, Label label) {
34                 super.visitLineNumber(i, label);
35                 m_ctx.addLineNumberInfo(label, i);
36             }
37         };
38     }
39 }
40
Popular Tags