Examples of InstructionFactory


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

    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

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

  // }
  // }
  // }

  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

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

    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

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

  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

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

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

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

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

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

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

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

        // high priority if our args are on the stack
        getKind().hasHighPriorityExceptions());
  }

  public void weavePerObjectEntry(final BcelAdvice munger, final BcelVar onVar) {
    final InstructionFactory fact = getFactory();

    InstructionList entryInstructions = new InstructionList();
    InstructionList entrySuccessInstructions = new InstructionList();
    onVar.appendLoad(entrySuccessInstructions, fact);
View Full Code Here

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

  public void weavePerTypeWithinAspectInitialization(final BcelAdvice munger, UnresolvedType t) {

    if (t.resolve(world).isInterface()) {
      return; // Don't initialize statics in
    }
    final InstructionFactory fact = getFactory();

    InstructionList entryInstructions = new InstructionList();
    InstructionList entrySuccessInstructions = new InstructionList();

    BcelWorld.getBcelObjectType(munger.getConcreteAspect());
    String aspectname = munger.getConcreteAspect().getName();

    String ptwField = NameMangler.perTypeWithinFieldForTarget(munger.getConcreteAspect());
    entrySuccessInstructions.append(InstructionFactory.PUSH(fact.getConstantPool(), t.getName()));

    entrySuccessInstructions.append(fact.createInvoke(aspectname, "ajc$createAspectInstance", new ObjectType(aspectname),
        new Type[] { new ObjectType("java.lang.String") }, Constants.INVOKESTATIC));
    entrySuccessInstructions.append(fact.createPutStatic(t.getName(), ptwField, new ObjectType(aspectname)));

    entryInstructions.append(entrySuccessInstructions);

    range.insert(entryInstructions, Range.InsideBefore);
  }
View Full Code Here

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

  public void weaveCflowEntry(final BcelAdvice munger, final Member cflowField) {
    final boolean isPer = munger.getKind() == AdviceKind.PerCflowBelowEntry || munger.getKind() == AdviceKind.PerCflowEntry;

    final Type objectArrayType = new ArrayType(Type.OBJECT, 1);
    final InstructionFactory fact = getFactory();

    final BcelVar testResult = genTempVar(ResolvedType.BOOLEAN);

    InstructionList entryInstructions = new InstructionList();
    {
      InstructionList entrySuccessInstructions = new InstructionList();

      if (munger.hasDynamicTests()) {
        entryInstructions.append(Utility.createConstant(fact, 0));
        testResult.appendStore(entryInstructions, fact);

        entrySuccessInstructions.append(Utility.createConstant(fact, 1));
        testResult.appendStore(entrySuccessInstructions, fact);
      }

      if (isPer) {
        entrySuccessInstructions.append(fact.createInvoke(munger.getConcreteAspect().getName(),
            NameMangler.PERCFLOW_PUSH_METHOD, Type.VOID, new Type[] {}, Constants.INVOKESTATIC));
      } else {
        BcelVar[] cflowStateVars = munger.getExposedStateAsBcelVars(false);

        if (cflowStateVars.length == 0) {
          // This should be getting managed by a counter - lets make sure.
          if (!cflowField.getType().getName().endsWith("CFlowCounter")) {
            throw new RuntimeException("Incorrectly attempting counter operation on stacked cflow");
          }
          entrySuccessInstructions.append(Utility.createGet(fact, cflowField));
          // arrayVar.appendLoad(entrySuccessInstructions, fact);
          entrySuccessInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "inc", Type.VOID,
              new Type[] {}, Constants.INVOKEVIRTUAL));
        } else {
          BcelVar arrayVar = genTempVar(UnresolvedType.OBJECTARRAY);

          int alen = cflowStateVars.length;
          entrySuccessInstructions.append(Utility.createConstant(fact, alen));
          entrySuccessInstructions.append(fact.createNewArray(Type.OBJECT, (short) 1));
          arrayVar.appendStore(entrySuccessInstructions, fact);

          for (int i = 0; i < alen; i++) {
            arrayVar.appendConvertableArrayStore(entrySuccessInstructions, fact, i, cflowStateVars[i]);
          }

          entrySuccessInstructions.append(Utility.createGet(fact, cflowField));
          arrayVar.appendLoad(entrySuccessInstructions, fact);

          entrySuccessInstructions.append(fact.createInvoke(NameMangler.CFLOW_STACK_TYPE, "push", Type.VOID,
              new Type[] { objectArrayType }, Constants.INVOKEVIRTUAL));
        }
      }

      InstructionList testInstructions = munger.getTestInstructions(this, entrySuccessInstructions.getStart(), range
          .getRealStart(), entrySuccessInstructions.getStart());
      entryInstructions.append(testInstructions);
      entryInstructions.append(entrySuccessInstructions);
    }

    // this is the same for both per and non-per
    weaveAfter(new BcelAdvice(null, null, null, 0, 0, 0, null, munger.getConcreteAspect()) {
      @Override
      public InstructionList getAdviceInstructions(BcelShadow s, BcelVar extraArgVar, InstructionHandle ifNoAdvice) {
        InstructionList exitInstructions = new InstructionList();
        if (munger.hasDynamicTests()) {
          testResult.appendLoad(exitInstructions, fact);
          exitInstructions.append(InstructionFactory.createBranchInstruction(Constants.IFEQ, ifNoAdvice));
        }
        exitInstructions.append(Utility.createGet(fact, cflowField));
        if (munger.getKind() != AdviceKind.PerCflowEntry && munger.getKind() != AdviceKind.PerCflowBelowEntry
            && munger.getExposedStateAsBcelVars(false).length == 0) {
          exitInstructions.append(fact.createInvoke(NameMangler.CFLOW_COUNTER_TYPE, "dec", Type.VOID, new Type[] {},
              Constants.INVOKEVIRTUAL));
        } else {
          exitInstructions.append(fact.createInvoke(NameMangler.CFLOW_STACK_TYPE, "pop", Type.VOID, new Type[] {},
              Constants.INVOKEVIRTUAL));
        }
        return exitInstructions;
      }
    });
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.