Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.InstructionFactory$MethodObject


    // If we are nonExpressionKind, we don't expect arguments on the stack
    // so this is moot. If our argVars happen to be null, then we know that
    // no ShadowMunger has squirrelled away our arguments, so they're still
    // on the stack.
    InstructionFactory fact = getFactory();
    if (getKind().argsOnStack() && argVars != null) {

      // Special case first (pr46298). If we are an exception handler and the instruction
      // just after the shadow is a POP then we should remove the pop. The code
      // above which generated the store instruction has already cleared the stack.
      // We also don't generate any code for the arguments in this case as it would be
      // an incorrect aload.
      if (getKind() == ExceptionHandler && range.getEnd().getNext().getInstruction().equals(InstructionConstants.POP)) {
        // easier than deleting it ...
        range.getEnd().getNext().setInstruction(InstructionConstants.NOP);
      } else {
        range.insert(BcelRenderer.renderExprs(fact, world, argVars), Range.InsideBefore);
        if (targetVar != null) {
          range.insert(BcelRenderer.renderExpr(fact, world, targetVar), Range.InsideBefore);
        }
        if (getKind() == ConstructorCall) {
          if (!world.isJoinpointArrayConstructionEnabled() || !this.getSignature().getDeclaringType().isArray()) {
            range.insert(InstructionFactory.createDup(1), Range.InsideBefore);
            range.insert(fact.createNew((ObjectType) BcelWorld.makeBcelType(getSignature().getDeclaringType())),
                Range.InsideBefore);
          }
        }
      }
    }
View Full Code Here


      if (lazyTjpConsumers == 1) {
        return; // special case only one lazyTjpUser
      }

      InstructionFactory fact = getFactory();
      InstructionList il = new InstructionList();
      il.append(InstructionConstants.ACONST_NULL);
      il.append(thisJoinPointVar.createStore(fact));
      range.insert(il, Range.OutsideBefore);
    } else {
      appliedLazyTjpOptimization = false;
      InstructionFactory fact = getFactory();
      InstructionList il = createThisJoinPoint();
      il.append(thisJoinPointVar.createStore(fact));
      range.insert(il, Range.OutsideBefore);
    }
  }
View Full Code Here

    return true;
  }

  InstructionList loadThisJoinPoint() {
    InstructionFactory fact = getFactory();
    InstructionList il = new InstructionList();

    if (isThisJoinPointLazy) {
      // If we're lazy, build the join point right here.
      il.append(createThisJoinPoint());
View Full Code Here

    return il;
  }

  InstructionList createThisJoinPoint() {
    InstructionFactory fact = getFactory();
    InstructionList il = new InstructionList();

    BcelVar staticPart = getThisJoinPointStaticPartBcelVar();
    staticPart.appendLoad(il, fact);
    if (hasThis()) {
      ((BcelVar) getThisVar()).appendLoad(il, fact);
    } else {
      il.append(InstructionConstants.ACONST_NULL);
    }
    if (hasTarget()) {
      ((BcelVar) getTargetVar()).appendLoad(il, fact);
    } else {
      il.append(InstructionConstants.ACONST_NULL);
    }

    switch (getArgCount()) {
    case 0:
      il.append(fact.createInvoke("org.aspectj.runtime.reflect.Factory", "makeJP", LazyClassGen.tjpType, new Type[] {
          LazyClassGen.staticTjpType, Type.OBJECT, Type.OBJECT }, Constants.INVOKESTATIC));
      break;
    case 1:
      ((BcelVar) getArgVar(0)).appendLoadAndConvert(il, fact, world.getCoreType(ResolvedType.OBJECT));
      il.append(fact.createInvoke("org.aspectj.runtime.reflect.Factory", "makeJP", LazyClassGen.tjpType, new Type[] {
          LazyClassGen.staticTjpType, Type.OBJECT, Type.OBJECT, Type.OBJECT }, Constants.INVOKESTATIC));
      break;
    case 2:
      ((BcelVar) getArgVar(0)).appendLoadAndConvert(il, fact, world.getCoreType(ResolvedType.OBJECT));
      ((BcelVar) getArgVar(1)).appendLoadAndConvert(il, fact, world.getCoreType(ResolvedType.OBJECT));
      il.append(fact.createInvoke("org.aspectj.runtime.reflect.Factory", "makeJP", LazyClassGen.tjpType, new Type[] {
          LazyClassGen.staticTjpType, Type.OBJECT, Type.OBJECT, Type.OBJECT, Type.OBJECT }, Constants.INVOKESTATIC));
      break;
    default:
      il.append(makeArgsObjectArray());
      il.append(fact.createInvoke("org.aspectj.runtime.reflect.Factory", "makeJP", LazyClassGen.tjpType, new Type[] {
          LazyClassGen.staticTjpType, Type.OBJECT, Type.OBJECT, new ArrayType(Type.OBJECT, 1) }, Constants.INVOKESTATIC));
      break;
    }

    return il;
View Full Code Here

  // }
  // }
  // }

  private InstructionList makeArgsObjectArray() {
    InstructionFactory fact = getFactory();
    BcelVar arrayVar = genTempVar(UnresolvedType.OBJECTARRAY);
    final InstructionList il = new InstructionList();
    int alen = getArgCount();
    il.append(Utility.createConstant(fact, alen));
    il.append(fact.createNewArray(Type.OBJECT, (short) 1));
    arrayVar.appendStore(il, fact);

    int stateIndex = 0;
    for (int i = 0, len = getArgCount(); i < len; i++) {
      arrayVar.appendConvertableArrayStore(il, fact, stateIndex, (BcelVar) getArgVar(i));
View Full Code Here

    thisVar = new BcelVar(getThisType().resolve(world), 0);
    thisVar.setPositionInAroundState(0);
  }

  public void initializeTargetVar() {
    InstructionFactory fact = getFactory();
    if (targetVar != null) {
      return;
    }
    if (getKind().isTargetSameAsThis()) {
      if (hasThis()) {
View Full Code Here

  public void ensureInitializedArgVar(int argNumber) {
    if (allArgVarsInitialized || (argVars != null && argVars[argNumber] != null)) {
      return;
    }
    InstructionFactory fact = getFactory();
    int len = getArgCount();
    if (argVars == null) {
      argVars = new BcelVar[len];
    }
View Full Code Here

   */
  public void initializeArgVars() {
    if (allArgVarsInitialized) {
      return;
    }
    InstructionFactory fact = getFactory();
    int len = getArgCount();
    if (argVars == null) {
      argVars = new BcelVar[len];
    }
    int positionOffset = (hasTarget() ? 1 : 0) + ((hasThis() && !getKind().isTargetSameAsThis()) ? 1 : 0);
View Full Code Here

    // if the shadow is GUARANTEED empty (i.e., there's NOTHING, not even
    // a shadow, inside me).
    if (getRange().getStart().getNext() == getRange().getEnd()) {
      return;
    }
    InstructionFactory fact = getFactory();
    InstructionList handler = new InstructionList();
    BcelVar exceptionVar = genTempVar(catchType);
    exceptionVar.appendStore(handler, fact);

    // pr62642
    // I will now jump through some firey BCEL hoops to generate a trivial bit of code:
    // if (exc instanceof ExceptionInInitializerError)
    // throw (ExceptionInInitializerError)exc;
    if (this.getEnclosingMethod().getName().equals("<clinit>")) {
      ResolvedType eiieType = world.resolve("java.lang.ExceptionInInitializerError");
      ObjectType eiieBcelType = (ObjectType) BcelWorld.makeBcelType(eiieType);
      InstructionList ih = new InstructionList(InstructionConstants.NOP);
      handler.append(exceptionVar.createLoad(fact));
      handler.append(fact.createInstanceOf(eiieBcelType));
      InstructionBranch bi = InstructionFactory.createBranchInstruction(Constants.IFEQ, ih.getStart());
      handler.append(bi);
      handler.append(exceptionVar.createLoad(fact));
      handler.append(fact.createCheckCast(eiieBcelType));
      handler.append(InstructionConstants.ATHROW);
      handler.append(ih);
    }

    InstructionList endHandler = new InstructionList(exceptionVar.createLoad(fact));
View Full Code Here

    // a shadow, inside me).
    if (getRange().getStart().getNext() == getRange().getEnd()) {
      return;
    }

    InstructionFactory fact = getFactory();
    InstructionList handler = new InstructionList();
    InstructionList rtExHandler = new InstructionList();
    BcelVar exceptionVar = genTempVar(catchType);

    handler.append(fact.createNew(NameMangler.SOFT_EXCEPTION_TYPE));
    handler.append(InstructionFactory.createDup(1));
    handler.append(exceptionVar.createLoad(fact));
    handler.append(fact.createInvoke(NameMangler.SOFT_EXCEPTION_TYPE, "<init>", Type.VOID, new Type[] { Type.THROWABLE },
        Constants.INVOKESPECIAL)); // ??? special
    handler.append(InstructionConstants.ATHROW);

    // ENH 42737
    exceptionVar.appendStore(rtExHandler, fact);
    // aload_1
    rtExHandler.append(exceptionVar.createLoad(fact));
    // instanceof class java/lang/RuntimeException
    rtExHandler.append(fact.createInstanceOf(new ObjectType("java.lang.RuntimeException")));
    // ifeq go to new SOFT_EXCEPTION_TYPE instruction
    rtExHandler.append(InstructionFactory.createBranchInstruction(Constants.IFEQ, handler.getStart()));
    // aload_1
    rtExHandler.append(exceptionVar.createLoad(fact));
    // athrow
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.InstructionFactory$MethodObject

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.