Examples of InstructionHandle


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

  }

  // ---- test visitors

  public void visit(And e) {
    InstructionHandle savedFk = fk;
    recur(e.getRight(), sk, fk, next);
    InstructionHandle ning = instructions.getStart();
    recur(e.getLeft(), ning, savedFk, ning);
  }
View Full Code Here

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

    InstructionHandle ning = instructions.getStart();
    recur(e.getLeft(), ning, savedFk, ning);
  }

  public void visit(Or e) {
    InstructionHandle savedSk = sk;
    recur(e.getRight(), sk, fk, next);
    recur(e.getLeft(), savedSk, instructions.getStart(), instructions.getStart());
  }
View Full Code Here

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

      range.insert(InstructionConstants.NOP, Range.InsideAfter);
    } else if (getKind() == ExceptionHandler) {

      ShadowRange range = getRange();
      InstructionList body = range.getBody();
      InstructionHandle start = range.getStart();

      // Create a store instruction to put the value from the top of the
      // stack into a local variable slot. This is a trimmed version of
      // what is in initializeArgVars() (since there is only one argument
      // at a handler jp and only before advice is supported) (pr46298)
      argVars = new BcelVar[1];
      // int positionOffset = (hasTarget() ? 1 : 0) + ((hasThis() && !getKind().isTargetSameAsThis()) ? 1 : 0);
      UnresolvedType tx = getArgType(0);
      argVars[0] = genTempVar(tx, "ajc$arg0");
      InstructionHandle insertedInstruction = range.insert(argVars[0].createStore(getFactory()), Range.OutsideBefore);

      // Now the exception range starts just after our new instruction.
      // The next bit of code changes the exception range to point at
      // the store instruction
      for (InstructionTargeter t : start.getTargetersCopy()) {
View Full Code Here

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

  }

  public static BcelShadow makeStaticInitialization(BcelWorld world, LazyMethodGen enclosingMethod) {
    InstructionList body = enclosingMethod.getBody();
    // move the start past ajc$preClinit
    InstructionHandle clinitStart = body.getStart();
    if (clinitStart.getInstruction() instanceof InvokeInstruction) {
      InvokeInstruction ii = (InvokeInstruction) clinitStart.getInstruction();
      if (ii.getName(enclosingMethod.getEnclosingClass().getConstantPool()).equals(NameMangler.AJC_PRE_CLINIT_NAME)) {
        clinitStart = clinitStart.getNext();
      }
    }

    InstructionHandle clinitEnd = body.getEnd();

    // XXX should move the end before the postClinit, but the return is then tricky...
    // if (clinitEnd.getInstruction() instanceof InvokeInstruction) {
    // InvokeInstruction ii = (InvokeInstruction)clinitEnd.getInstruction();
    // if (ii.getName(enclosingMethod.getEnclosingClass().getConstantPool()).equals(NameMangler.AJC_POST_CLINIT_NAME)) {
View Full Code Here

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

    sig.setParameterNames(new String[] { findHandlerParamName(startOfHandler) });

    BcelShadow s = new BcelShadow(world, ExceptionHandler, sig, enclosingMethod, enclosingShadow);
    ShadowRange r = new ShadowRange(body);
    r.associateWithShadow(s);
    InstructionHandle start = Range.genStart(body, startOfHandler);
    InstructionHandle end = Range.genEnd(body, start);

    r.associateWithTargets(start, end);
    exceptionRange.updateTarget(startOfHandler, start, body);
    return s;
  }
View Full Code Here

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

  public void initIfaceInitializer(InstructionHandle end) {
    final InstructionList body = enclosingMethod.getBody();
    ShadowRange r = new ShadowRange(body);
    r.associateWithShadow(this);
    InstructionHandle nop = body.insert(end, InstructionConstants.NOP);

    r.associateWithTargets(Range.genStart(body, nop), Range.genEnd(body, nop));
  }
View Full Code Here

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

      // Does someone else need it? If so, store it for later retrieval
      if (lazyTjpConsumers > 1) {
        il.append(thisJoinPointVar.createStore(fact));

        InstructionHandle end = il.append(thisJoinPointVar.createLoad(fact));

        il.insert(InstructionFactory.createBranchInstruction(Constants.IFNONNULL, end));
        il.insert(thisJoinPointVar.createLoad(fact));
      }
    } else {
View Full Code Here

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

    Member msig = getSignature();
    if (msig.getArity() == 0 && getKind() == MethodCall && msig.getName().charAt(0) == 'c' && tx.equals(ResolvedType.OBJECT)
        && msig.getReturnType().equals(ResolvedType.OBJECT) && msig.getName().equals("clone")) {

      // Lets go back through the code from the start of the shadow
      InstructionHandle searchPtr = range.getStart().getPrev();
      while (Range.isRangeHandle(searchPtr) || searchPtr.getInstruction().isStoreInstruction()) { // ignore this instruction -
        // it doesnt give us the
        // info we want
        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();
        Type t = si.getFieldType(getEnclosingClass().getConstantPool());
        return BcelWorld.fromBcel(t);
      }
      // A new array instruction obviously tells us it is an array type !
      if (searchPtr.getInstruction().opcode == Constants.ANEWARRAY) {
        // ANEWARRAY ana = (ANEWARRAY)searchPoint.getInstruction();
        // Type t = ana.getType(getEnclosingClass().getConstantPool());
        // Just use a standard java.lang.object array - that will work fine
        return BcelWorld.fromBcel(new ArrayType(Type.OBJECT, 1));
      }
      // A multi new array instruction obviously tells us it is an array type !
      if (searchPtr.getInstruction() instanceof MULTIANEWARRAY) {
        MULTIANEWARRAY ana = (MULTIANEWARRAY) searchPtr.getInstruction();
        // Type t = ana.getType(getEnclosingClass().getConstantPool());
        // t = new ArrayType(t,ana.getDimensions());
        // Just use a standard java.lang.object array - that will work fine
        return BcelWorld.fromBcel(new ArrayType(Type.OBJECT, ana.getDimensions()));
      }
      throw new BCException("Can't determine real target of clone() when processing instruction "
          + searchPtr.getInstruction() + ".  Perhaps avoid selecting clone with your pointcut?");
    }
    return tx;
  }
View Full Code Here

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

    // list of instructions for dispatching to the advice itself
    InstructionList advice = getAfterReturningAdviceDispatchInstructions(munger, retList.getStart());

    if (hasReturnInstructions) {
      InstructionHandle gotoTarget = advice.getStart();
      for (Iterator<InstructionHandle> i = returns.iterator(); i.hasNext();) {
        InstructionHandle ih = i.next();
        retargetReturnInstruction(munger.hasExtraParameter(), returnValueVar, gotoTarget, ih);
      }
    }

    range.append(advice);
View Full Code Here

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

      // Find the last *correct* return - this is a method with a non-void return type
      // so ignore RETURN
      Instruction newReturnInstruction = null;
      int i = returns.size() - 1;
      while (newReturnInstruction == null && i >= 0) {
        InstructionHandle ih = returns.get(i);
        if (ih.getInstruction().opcode != Constants.RETURN) {
          newReturnInstruction = Utility.copyInstruction(ih.getInstruction());
        }
        i--;
      }
      returnValueVar = genTempVar(this.getReturnType());
      returnValueVar.appendLoad(returnInstructions, getFactory());
      returnInstructions.append(newReturnInstruction);
    } else {
      InstructionHandle lastReturnHandle = returns.get(returns.size() - 1);
      Instruction newReturnInstruction = Utility.copyInstruction(lastReturnHandle.getInstruction());
      returnInstructions.append(newReturnInstruction);
    }
    return returnValueVar;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.