Package org.aspectj.apache.bcel.generic

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


   * @param extraArgVar The var that will hold the return value or thrown exception for afterX advice
   * @param ifNoAdvice The instructionHandle to jump to if the dynamic tests for this munger fails.
   */
  InstructionList getAdviceInstructions(BcelShadow s, BcelVar extraArgVar, InstructionHandle ifNoAdvice) {
    BcelShadow shadow = s;
    InstructionFactory fact = shadow.getFactory();
    BcelWorld world = shadow.getWorld();

    InstructionList il = new InstructionList();

    // we test to see if we have the right kind of thing...
View Full Code Here


    return il;
  }

  public InstructionList getAdviceArgSetup(BcelShadow shadow, BcelVar extraVar, InstructionList closureInstantiation) {
    InstructionFactory fact = shadow.getFactory();
    BcelWorld world = shadow.getWorld();
    InstructionList il = new InstructionList();

    // if (targetAspectField != null) {
    // il.append(fact.createFieldAccess(
View Full Code Here

        cflowStackField.getName(), gen.getConstantPool());
    gen.addField(f, getSourceLocation());

    LazyMethodGen clinit = gen.getAjcPreClinit(); // StaticInitializer();
    InstructionList setup = new InstructionList();
    InstructionFactory fact = gen.getFactory();

    setup.append(fact.createNew(NameMangler.CFLOW_STACK_TYPE));
    setup.append(InstructionFactory.createDup(1));
    setup.append(fact.createInvoke(NameMangler.CFLOW_STACK_TYPE, "<init>", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));

    setup.append(Utility.createSet(fact, cflowStackField));
    clinit.getBody().insert(setup);

    return true;
View Full Code Here

    // 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()) {
            if (deletedNewAndDup) { // if didnt delete them, dont insert any!
              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

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.