Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.LocalVariableTag


          Tag fresh = tagMap.get(oldTag);
          if (fresh == null) {
            fresh = oldTag.copy();
            if (old instanceof LocalVariableTag) {
              // LocalVariable
              LocalVariableTag lvTag = (LocalVariableTag) old;
              LocalVariableTag lvTagFresh = (LocalVariableTag) fresh;
              if (lvTag.getSlot() == 0) {
                fresh = new LocalVariableTag(lvTag.getRealType().getSignature(), "ajc$aspectInstance",
                    frameEnv.get(lvTag.getSlot()), 0);
              } else {
                // // Do not move it - when copying the code from the aspect to the affected target, 'this' is
                // // going to change from aspect to affected type. So just fix the type
                // System.out.println("For local variable tag at instruction " + src + " changing slot from "
                // + lvTag.getSlot() + " > " + frameEnv.get(lvTag.getSlot()));
                lvTagFresh.updateSlot(frameEnv.get(lvTag.getSlot()));
              }
            }
            tagMap.put(oldTag, fresh);
          }
          dest.addTargeter(fresh);
View Full Code Here


      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

        if (source instanceof LocalVariableTag) {
          Shadow.Kind kind = getKind();
          if (kind == Shadow.AdviceExecution || kind == Shadow.ConstructorExecution || kind == Shadow.MethodExecution
              || kind == Shadow.PreInitialization || kind == Shadow.Initialization
              || kind == Shadow.StaticInitialization) {
            LocalVariableTag sourceLocalVariableTag = (LocalVariableTag) source;
            if (sourceLocalVariableTag.getSlot() == 0) {
              // might be 'this' so should be renamed if being dumped in a static method 277616
              if (sourceLocalVariableTag.getName().equals("this")) {
                sourceLocalVariableTag.setName("ajc$this");
              }
            }
            // if we're extracting a whole block we can do this...
            source.updateTarget(oldIh, freshIh);
          } else {
            // XXX destroying local variable info
            // but only for a call or get join point, so no big deal
            source.updateTarget(oldIh, null);
          }
        } else if (source instanceof Range) {
          // exceptions and shadows are just moved
          ((Range) source).updateTarget(oldIh, freshIh, freshBody);
        } else {
          // line numbers can be shared,
          // branches will be copied along with us.
          source.updateTarget(oldIh, freshIh);
        }
      }
      // we're now done with the old instruction entirely, and will ignore them through
      // the rest of this loop. The only time we'll see them again is a second pass to
      // delete them.

      // now deal with local variable instructions. If this points to a remapped
      // frame location, update the instruction's index. If this doesn't,
      // do compaction/expansion: allocate a new local variable, and modify the remap
      // to handle it. XXX We're doing the safe thing and allocating ALL these local variables
      // as double-wides, in case the location is found to hold a double-wide later.
      if (freshI.isLocalVariableInstruction() || freshI instanceof RET) {
        // IndexedInstruction indexedI = (IndexedInstruction) freshI;
        int oldIndex = freshI.getIndex();
        int freshIndex;
        if (!remap.hasKey(oldIndex)) {
          freshIndex = freshMethod.allocateLocal(2);
          remap.put(oldIndex, freshIndex);
        } else {
          freshIndex = remap.get(oldIndex);
        }
        if (freshI instanceof RET) {
          freshI.setIndex(freshIndex);
        } else {
          freshI = ((InstructionLV) freshI).setIndexAndCopyIfNecessary(freshIndex);
          freshIh.setInstruction(freshI);
        }
      }
      // System.err.println("JUST COPIED: " +
      // oldIh.getInstruction().toString(freshMethod.getEnclosingClass().getConstantPoolGen().getConstantPool())
      // + " INTO " +
      // freshIh.getInstruction().toString(freshMethod.getEnclosingClass().getConstantPoolGen().getConstantPool()));
    }

    // now go through again and update variable slots that have been altered as a result
    // of remapping...
    for (InstructionHandle newIh = freshBody.getStart(); newIh != freshBody.getEnd(); newIh = newIh.getNext()) {
      Iterator<InstructionTargeter> tIter = newIh.getTargeters().iterator();
      while (tIter.hasNext()) {
        InstructionTargeter source = tIter.next();
        if (source instanceof LocalVariableTag) {
          LocalVariableTag lvt = (LocalVariableTag) source;
          if (!lvt.isRemapped() && remap.hasKey(lvt.getSlot())) {
            lvt.updateSlot(remap.get(lvt.getSlot()));
          }
        }
      }
    }
View Full Code Here

      // System.out.println("got store: " + startOfHandler.getInstruction() + ", " + index);
      Iterator<InstructionTargeter> tIter = startOfHandler.getNext().getTargeters().iterator();
      while (tIter.hasNext()) {
        InstructionTargeter targeter = tIter.next();
        if (targeter instanceof LocalVariableTag) {
          LocalVariableTag t = (LocalVariableTag) targeter;
          if (t.getSlot() == slot) {
            return t.getName();
          }
        }
      }
    }
View Full Code Here

        searchPtr = searchPtr.getPrev();
      }

      // A load instruction may tell us the real type of what the clone() call is on
      if (searchPtr.getInstruction().isLoadInstruction()) {
        LocalVariableTag lvt = LazyMethodGen.getLocalVariableTag(searchPtr, searchPtr.getInstruction().getIndex());
        if (lvt != null) {
          return UnresolvedType.forSignature(lvt.getType());
        }
      }
      // A field access instruction may tell us the real type of what the clone() call is on
      if (searchPtr.getInstruction() instanceof FieldInstruction) {
        FieldInstruction si = (FieldInstruction) searchPtr.getInstruction();
View Full Code Here

        argumentName = new StringBuffer("unknown").append(argNumber).toString();
      } else {
        argumentName = parameterNames.get(argNumber);
      }
      String argumentSignature = args[argNumber].getSignature();
      LocalVariableTag lvt = new LocalVariableTag(argumentSignature, argumentName, slot, 0);
      start.addTargeter(lvt);
      end.addTargeter(lvt);
      slot += args[argNumber].getSize();
    }
  }
View Full Code Here

  }

  static LocalVariableTag getLocalVariableTag(InstructionHandle ih, int index) {
    for (InstructionTargeter t : ih.getTargeters()) {
      if (t instanceof LocalVariableTag) {
        LocalVariableTag lvt = (LocalVariableTag) t;
        if (lvt.getSlot() == index) {
          return lvt;
        }
      }
    }
    return null;
View Full Code Here

            if (line != currLine) {
              gen.addLineNumber(newInstructionHandle, line + lineNumberOffset);
              currLine = line;
            }
          } else if (targeter instanceof LocalVariableTag) {
            LocalVariableTag lvt = (LocalVariableTag) targeter;
            LVPosition p = localVariables.get(lvt);
            // If we don't know about it, create a new position and
            // store
            // If we do know about it - update its end position
            if (p == null) {
View Full Code Here

            if (line != currLine) {
              gen.addLineNumber(iHandle, line + lineNumberOffset);
              currLine = line;
            }
          } else if (targeter instanceof LocalVariableTag) {
            LocalVariableTag lvt = (LocalVariableTag) targeter;
            LVPosition p = localVariables.get(lvt);
            // If we don't know about it, create a new position
            // and store
            // If we do know about it - update its end position
            if (p == null) {
View Full Code Here

      } else if (inst.isLocalVariableInstruction()) {
        // LocalVariableInstruction lvinst = (LocalVariableInstruction)
        // inst;
        out.print(inst.toString(false).toUpperCase());
        int index = inst.getIndex();
        LocalVariableTag tag = getLocalVariableTag(h, index);
        if (tag != null) {
          out.print("     // ");
          out.print(tag.getType());
          out.print(" ");
          out.print(tag.getName());
        }
      } else {
        out.print(inst.toString(false).toUpperCase());
      }
    }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.LocalVariableTag

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.