Package org.aspectj.apache.bcel.classfile

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


            // 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


      // Fix up the local variables: find any that have a startPC of 0 and ensure they target the new start of the method
      LocalVariableTable lvt = shadow.getEnclosingMethod().getMemberView().getMethod().getLocalVariableTable();
      if (lvt != null) {
        LocalVariable[] lvTable = lvt.getLocalVariableTable();
        for (int i = 0; i < lvTable.length; i++) {
          LocalVariable lv = lvTable[i];
          if (lv.getStartPC() == 0) {
            start.addTargeter(new LocalVariableTag(lv.getSignature(), lv.getName(), lv.getIndex(), 0));
          }
        }
      }
    }
View Full Code Here

    final List<MethodArgument> arguments = new ArrayList<MethodArgument>();
    LocalVariableTable lt = method.getLocalVariableTable();
    if (lt != null) {
      LocalVariable[] lvt = lt.getLocalVariableTable();
      for (int j = 0; j < lvt.length; j++) {
        LocalVariable localVariable = lvt[j];
        if (localVariable.getStartPC() == 0) {
          if (localVariable.getIndex() >= startAtStackIndex) {
            arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
          }
        }
      }
      if (arguments.size() == 0) {
        // could be cobertura code where some extra bytecode has been stuffed in at the start of the method
        // but the local variable table hasn't been repaired - for example:
        // LocalVariable(start_pc = 6, length = 40, index = 0:com.example.ExampleAspect this)
        // LocalVariable(start_pc = 6, length = 40, index = 1:org.aspectj.lang.ProceedingJoinPoint pjp)
        // LocalVariable(start_pc = 6, length = 40, index = 2:int __cobertura__line__number__)
        // LocalVariable(start_pc = 6, length = 40, index = 3:int __cobertura__branch__number__)
        LocalVariable localVariable = lvt[0];
        if (localVariable.getStartPC() != 0) {
          // looks suspicious so let's use this information
          for (int j = 0; j < lvt.length && arguments.size() < method.getArgumentTypes().length; j++) {
            localVariable = lvt[j];
            if (localVariable.getIndex() >= startAtStackIndex) {
              arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
            }
          }
        }
      }
    } else {
View Full Code Here

    } else {
      UnresolvedType[] paramTypes = getParameterTypes();
      String[] paramNames = new String[len];
      int index = Modifier.isStatic(modifiers) ? 0 : 1;
      for (int i = 0; i < len; i++) {
        LocalVariable lv = varTable.getLocalVariable(index);
        if (lv == null) {
          paramNames[i] = "arg" + i;
        } else {
          paramNames[i] = lv.getName();
        }
        index += paramTypes[i].getSize();
      }
      setParameterNames(paramNames);
    }
View Full Code Here

      // Fix up the local variables: find any that have a startPC of 0 and ensure they target the new start of the method
      LocalVariableTable lvt = shadow.getEnclosingMethod().getMemberView().getMethod().getLocalVariableTable();
      if (lvt != null) {
        LocalVariable[] lvTable = lvt.getLocalVariableTable();
        for (int i = 0; i < lvTable.length; i++) {
          LocalVariable lv = lvTable[i];
          if (lv.getStartPC() == 0) {
            start.addTargeter(new LocalVariableTag(lv.getSignature(), lv.getName(), lv.getIndex(), 0));
          }
        }
      }
    }
View Full Code Here

            // 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

    }

    int name_index = cp.addUtf8(name);
    int signature_index = cp.addUtf8(type.getSignature());

    return new LocalVariable(start_pc, length, name_index, signature_index, index, cp);
  }
View Full Code Here

    final List<MethodArgument> arguments = new ArrayList<MethodArgument>();
    LocalVariableTable lt = method.getLocalVariableTable();
    if (lt != null) {
      LocalVariable[] lvt = lt.getLocalVariableTable();
      for (int j = 0; j < lvt.length; j++) {
        LocalVariable localVariable = lvt[j];
        if (localVariable != null) { // pr348488
          if (localVariable.getStartPC() == 0) {
            if (localVariable.getIndex() >= startAtStackIndex) {
              arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
            }
          }
        } else {
          String typename = (methodStruct.enclosingType != null ? methodStruct.enclosingType.getName() : "");
          System.err.println("AspectJ: 348488 debug: unusual local variable table for method " + typename + "."
              + method.getName());
        }
      }
      if (arguments.size() == 0) {
        // could be cobertura code where some extra bytecode has been stuffed in at the start of the method
        // but the local variable table hasn't been repaired - for example:
        // LocalVariable(start_pc = 6, length = 40, index = 0:com.example.ExampleAspect this)
        // LocalVariable(start_pc = 6, length = 40, index = 1:org.aspectj.lang.ProceedingJoinPoint pjp)
        // LocalVariable(start_pc = 6, length = 40, index = 2:int __cobertura__line__number__)
        // LocalVariable(start_pc = 6, length = 40, index = 3:int __cobertura__branch__number__)
        LocalVariable localVariable = lvt[0];
        if (localVariable != null) { // pr348488
          if (localVariable.getStartPC() != 0) {
            // looks suspicious so let's use this information
            for (int j = 0; j < lvt.length && arguments.size() < method.getArgumentTypes().length; j++) {
              localVariable = lvt[j];
              if (localVariable.getIndex() >= startAtStackIndex) {
                arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
              }
            }
          }
        }
      }
View Full Code Here

    final List<MethodArgument> arguments = new ArrayList<MethodArgument>();
    LocalVariableTable lt = method.getLocalVariableTable();
    if (lt != null) {
      LocalVariable[] lvt = lt.getLocalVariableTable();
      for (int j = 0; j < lvt.length; j++) {
        LocalVariable localVariable = lvt[j];
        if (localVariable.getStartPC() == 0) {
          if (localVariable.getIndex() >= startAtStackIndex) {
            arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
          }
        }
      }
      if (arguments.size() == 0) {
        // could be cobertura code where some extra bytecode has been stuffed in at the start of the method
        // but the local variable table hasn't been repaired - for example:
        // LocalVariable(start_pc = 6, length = 40, index = 0:com.example.ExampleAspect this)
        // LocalVariable(start_pc = 6, length = 40, index = 1:org.aspectj.lang.ProceedingJoinPoint pjp)
        // LocalVariable(start_pc = 6, length = 40, index = 2:int __cobertura__line__number__)
        // LocalVariable(start_pc = 6, length = 40, index = 3:int __cobertura__branch__number__)
        LocalVariable localVariable = lvt[0];
        if (localVariable.getStartPC() != 0) {
          // looks suspicious so let's use this information
          for (int j = 0; j < lvt.length && arguments.size() < method.getArgumentTypes().length; j++) {
            localVariable = lvt[j];
            if (localVariable.getIndex() >= startAtStackIndex) {
              arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex()));
            }
          }
        }
      }
    } else {
View Full Code Here

    } else {
      UnresolvedType[] paramTypes = getParameterTypes();
      String[] paramNames = new String[len];
      int index = Modifier.isStatic(modifiers) ? 0 : 1;
      for (int i = 0; i < len; i++) {
        LocalVariable lv = varTable.getLocalVariable(index);
        if (lv == null) {
          paramNames[i] = "arg" + i;
        } else {
          paramNames[i] = lv.getName();
        }
        index += paramTypes[i].getSize();
      }
      setParameterNames(paramNames);
    }
View Full Code Here

TOP

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

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.