Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.LineNumber


          if (a instanceof LineNumberTable) {
            LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
            if (useTags) {
              // abracadabra, lets create tags rather than linenumbergens.
              for (int k = 0; k < ln.length; k++) {
                LineNumber l = ln[k];
                int lnum = l.getLineNumber();
                if (lnum > highestLineNumber) {
                  highestLineNumber = lnum;
                }
                LineNumberTag lt = new LineNumberTag(lnum);
                il.findHandle(l.getStartPC(), arrayOfInstructions, true).addTargeter(lt);
              }
            } else {
              for (int k = 0; k < ln.length; k++) {
                LineNumber l = ln[k];
                addLineNumber(il.findHandle(l.getStartPC(), arrayOfInstructions, true), l.getLineNumber());
              }
            }
          } else if (a instanceof LocalVariableTable) {

            // Lets have a go at creating Tags directly
            if (useTags) {
              LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();

              for (int k = 0; k < lv.length; k++) {
                LocalVariable l = lv[k];
                Type t = Type.getType(l.getSignature());
                LocalVariableTag lvt = new LocalVariableTag(t, l.getSignature(), l.getName(), l.getIndex(), l
                    .getStartPC());
                InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions, true);
                byte b = t.getType();
                if (b != Constants.T_ADDRESS) {
                  int increment = t.getSize();
                  if (l.getIndex() + increment > maxLocals) {
                    maxLocals = l.getIndex() + increment;
                  }
                }
                int end = l.getStartPC() + l.getLength();
                do {
                  start.addTargeter(lvt);
                  start = start.getNext();
                } while (start != null && start.getPosition() < end);
              }
            } else {

              LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();

              removeLocalVariables();

              for (int k = 0; k < lv.length; k++) {
                LocalVariable l = lv[k];
                InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions);
                InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength(), arrayOfInstructions);
                // AMC, this actually gives us the first instruction AFTER the range,
                // so move back one... (findHandle can't cope with mid-instruction indices)
                if (end != null) {
                  end = end.getPrev();
                }
                // Repair malformed handles
                if (null == start) {
                  start = il.getStart();
                }
                if (null == end) {
                  end = il.getEnd();
                }

                addLocalVariable(l.getName(), Type.getType(l.getSignature()), l.getIndex(), start, end);
              }
            }
          } else {
            addCodeAttribute(a);
          }
View Full Code Here


   *
   * This relies on that the instruction list has already been dumped to byte code or
   * or that the `setPositions' methods has been called for the instruction list.
   */
  public LineNumber getLineNumber() {
    return new LineNumber(ih.getPosition(), src_line);
  }
View Full Code Here

          if (a instanceof LineNumberTable) {
            LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
            if (useTags) {
              // abracadabra, lets create tags rather than linenumbergens.
              for (int k = 0; k < ln.length; k++) {
                LineNumber l = ln[k];
                int lnum = l.getLineNumber();
                if (lnum > highestLineNumber) {
                  highestLineNumber = lnum;
                }
                LineNumberTag lt = new LineNumberTag(lnum);
                il.findHandle(l.getStartPC(), arrayOfInstructions, true).addTargeter(lt);
              }
            } else {
              for (int k = 0; k < ln.length; k++) {
                LineNumber l = ln[k];
                addLineNumber(il.findHandle(l.getStartPC(), arrayOfInstructions, true), l.getLineNumber());
              }
            }
          } else if (a instanceof LocalVariableTable) {

            // Lets have a go at creating Tags directly
            if (useTags) {
              LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();

              for (int k = 0; k < lv.length; k++) {
                LocalVariable l = lv[k];
                Type t = Type.getType(l.getSignature());
                LocalVariableTag lvt = new LocalVariableTag(t, l.getSignature(), l.getName(), l.getIndex(), l
                    .getStartPC());
                InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions, true);
                byte b = t.getType();
                if (b != Constants.T_ADDRESS) {
                  int increment = t.getSize();
                  if (l.getIndex() + increment > maxLocals) {
                    maxLocals = l.getIndex() + increment;
                  }
                }
                int end = l.getStartPC() + l.getLength();
                do {
                  start.addTargeter(lvt);
                  start = start.getNext();
                } while (start != null && start.getPosition() < end);
              }
            } else {

              LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();

              removeLocalVariables();

              for (int k = 0; k < lv.length; k++) {
                LocalVariable l = lv[k];
                InstructionHandle start = il.findHandle(l.getStartPC(), arrayOfInstructions);
                InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength(), arrayOfInstructions);
                // AMC, this actually gives us the first instruction AFTER the range,
                // so move back one... (findHandle can't cope with mid-instruction indices)
                if (end != null) {
                  end = end.getPrev();
                }
                // Repair malformed handles
                if (null == start) {
                  start = il.getStart();
                }
                if (null == end) {
                  end = il.getEnd();
                }

                addLocalVariable(l.getName(), Type.getType(l.getSignature()), l.getIndex(), start, end);
              }
            }
          } else {
            addCodeAttribute(a);
          }
View Full Code Here

   *
   * This relies on that the instruction list has already been dumped to byte code or
   * or that the `setPositions' methods has been called for the instruction list.
   */
  public LineNumber getLineNumber() {
    return new LineNumber(ih.getPosition(), src_line);
  }
View Full Code Here

    if(a instanceof LineNumberTable) {
      LineNumber[] ln = ((LineNumberTable)a).getLineNumberTable();

      for(int k=0; k < ln.length; k++) {
        LineNumber l = ln[k];
        addLineNumber(il.findHandle(l.getStartPC()), l.getLineNumber());
      }
    } else if(a instanceof LocalVariableTable) {
      LocalVariable[] lv = ((LocalVariableTable)a).getLocalVariableTable();

      removeLocalVariables();

      for(int k=0; k < lv.length; k++) {
        LocalVariable     l     = lv[k];
        InstructionHandle start = il.findHandle(l.getStartPC());
        InstructionHandle end   = il.findHandle(l.getStartPC() + l.getLength());
        // AMC, this actually gives us the first instruction AFTER the range,
        // so move back one... (findHandle can't cope with mid-instruction indices)
        if (end != null) end = end.getPrev();

        // Repair malformed handles
        if(null == start) {
    start = il.getStart();
        }

        if(null == end) {
    end = il.getEnd();
        }

        addLocalVariable(l.getName(), Type.getType(l.getSignature()),
             l.getIndex(), start, end);
      }
    } else
      addCodeAttribute(a);
  }
      } else if(a instanceof ExceptionTable) {
  String[] names = ((ExceptionTable)a).getExceptionNames();
  for(int j=0; j < names.length; j++)
    addException(names[j]);
      } else if (a instanceof RuntimeAnnotations) {
    RuntimeAnnotations runtimeAnnotations = (RuntimeAnnotations)a;
    List l = runtimeAnnotations.getAnnotations();
    for (Iterator it = l.iterator(); it.hasNext();) {
      Annotation element = (Annotation) it.next();
      addAnnotation(new AnnotationGen(element,cp,false));
    }
      } else {
        addAttribute(a);
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.LineNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.