Package org.aspectj.weaver.ast

Examples of org.aspectj.weaver.ast.Var


          // in the call to residueSource.findResidue) to not be set (be null)
          // in an Or pointcut with if expressions in both branches, and where
          // one branch is known statically to not match. In this situation we
          // simply return Test.
          for (int i = 0; i < baseArgsCount; i++) {
            Var v = myState.get(i);
            if (v == null) {
              continue; // pr118149
            }
            args.add(v);
            ret = Test.makeAnd(ret, Test.makeInstanceof(v, pTypes[i].resolve(shadow.getIWorld())));
          }
        }

        // handle thisJoinPoint parameters
        if ((extraParameterFlags & Advice.ThisJoinPoint) != 0) {
          args.add(shadow.getThisJoinPointVar());
        }

        if ((extraParameterFlags & Advice.ThisJoinPointStaticPart) != 0) {
          args.add(shadow.getThisJoinPointStaticPartVar());
        }

        if ((extraParameterFlags & Advice.ThisEnclosingJoinPointStaticPart) != 0) {
          args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
        }
      } else {
        // @style is slightly different
        int currentStateIndex = 0;
        // FIXME AV - "args(jp)" test(jp, thejp) will fail here
        for (int i = 0; i < testMethod.getParameterTypes().length; i++) {
          String argSignature = testMethod.getParameterTypes()[i].getSignature();
          if (AjcMemberMaker.TYPEX_JOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisJoinPointVar());
          } else if (AjcMemberMaker.TYPEX_PROCEEDINGJOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisJoinPointVar());
          } else if (AjcMemberMaker.TYPEX_STATICJOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisJoinPointStaticPartVar());
          } else if (AjcMemberMaker.TYPEX_ENCLOSINGSTATICJOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
          } else {
            if (state.size() == 0 || currentStateIndex > state.size()) {
              String[] paramNames = testMethod.getParameterNames();
              StringBuffer errorParameter = new StringBuffer();
              if (paramNames != null) {
                errorParameter.append(testMethod.getParameterTypes()[i].getName()).append(" ");
                errorParameter.append(paramNames[i]);
                shadow.getIWorld().getMessageHandler().handleMessage(
                    MessageUtil.error("Missing binding for if() pointcut method.  Parameter " + (i + 1) + "("
                        + errorParameter.toString()
                        + ") must be bound - even in reference pointcuts  (compiler limitation)",
                        testMethod.getSourceLocation()));
              } else {
                shadow.getIWorld().getMessageHandler().handleMessage(
                    MessageUtil.error("Missing binding for if() pointcut method.  Parameter " + (i + 1)
                        + " must be bound - even in reference pointcuts (compiler limitation)", testMethod
                        .getSourceLocation()));
              }
              return Literal.TRUE; // exit quickly
            }
            // we don't use i as JoinPoint.* can be anywhere in the signature in @style
            Var v = state.get(currentStateIndex++);

            while (v == null && currentStateIndex < state.size()) { // pr162135
              v = state.get(currentStateIndex++);
            }
            args.add(v);
View Full Code Here


  protected Test findResidueInternal(Shadow shadow, ExposedState state) {

    if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
      BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern;
      UnresolvedType annotationType = btp.annotationType;
      Var var = shadow.getWithinCodeAnnotationVar(annotationType);

      // This should not happen, we shouldn't have gotten this far
      // if we weren't going to find the annotation
      if (var == null) {
        throw new BCException("Impossible! annotation=[" + annotationType + "]  shadow=[" + shadow + " at "
View Full Code Here

  @Override
  protected Test findResidueInternal(Shadow shadow, ExposedState state) {
    if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
      BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern;
      UnresolvedType annotationType = btp.annotationType;
      Var var = shadow.getWithinAnnotationVar(annotationType);

      // This should not happen, we shouldn't have gotten this far
      // if we weren't going to find the annotation
      if (var == null) {
        throw new BCException("Impossible! annotation=[" + annotationType + "]  shadow=[" + shadow + " at "
View Full Code Here

    // if no preference is specified, just say TRUE which means no residue
    if (typePattern == TypePattern.ANY) {
      return Literal.TRUE;
    }

    Var var = isThis ? shadow.getThisVar() : shadow.getTargetVar();

    return exposeStateForVar(var, typePattern, state, shadow.getIWorld());
  }
View Full Code Here

        }

        ResolvedType rAnnType = ap.getAnnotationType().resolve(shadow.getIWorld());
        if (ap instanceof BindingAnnotationTypePattern) {
          BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) ap;
          Var annvar = shadow.getArgAnnotationVar(argsIndex, rAnnType);
          state.set(btp.getFormalIndex(), annvar);
        }
        if (!ap.matches(rArgType).alwaysTrue()) {
          // we need a test...
          ret = Test.makeAnd(ret, Test.makeHasAnnotation(shadow.getArgVar(argsIndex), rAnnType));
View Full Code Here

      BindingAnnotationFieldTypePattern btp = (BindingAnnotationFieldTypePattern) annotationTypePattern;
      ResolvedType formalType = btp.getFormalType().resolve(shadow.getIWorld());
      UnresolvedType annoType = btp.getAnnotationType();
      // TODO 2 need to sort out appropriate creation of the AnnotationAccessFieldVar - what happens for
      // reflective (ReflectionShadow) access to types?
      Var var = shadow.getKindedAnnotationVar(annoType);
      if (var == null) {
        throw new BCException("Unexpected problem locating annotation at join point '" + shadow + "'");
      }
      state.set(btp.getFormalIndex(), var.getAccessorForValue(formalType, btp.formalName));
    } else if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
      BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern;
      UnresolvedType annotationType = btp.getAnnotationType();
      Var var = shadow.getKindedAnnotationVar(annotationType);

      // At this point, var *could* be null. The only reason this could happen (if we aren't failing...)
      // is if another binding annotation designator elsewhere in the pointcut is going to expose the annotation
      // eg. (execution(* a*(..)) && @annotation(foo)) || (execution(* b*(..)) && @this(foo))
      // where sometimes @annotation will be providing the value, and sometimes
View Full Code Here

  protected Test findResidueInternal(Shadow shadow, ExposedState state) {
    if (!couldMatch(shadow)) {
      return Literal.FALSE;
    }
    boolean alwaysMatches = match(shadow).alwaysTrue();
    Var var = isThis ? shadow.getThisVar() : shadow.getTargetVar();
    Var annVar = null;

    // Are annotations being bound?
    UnresolvedType annotationType = annotationTypePattern.annotationType;
    if (annotationTypePattern instanceof BindingAnnotationTypePattern) {
      BindingAnnotationTypePattern btp = (BindingAnnotationTypePattern) annotationTypePattern;
View Full Code Here

          // in the call to residueSource.findResidue) to not be set (be null)
          // in an Or pointcut with if expressions in both branches, and where
          // one branch is known statically to not match. In this situation we
          // simply return Test.
          for (int i = 0; i < baseArgsCount; i++) {
            Var v = myState.get(i);
            if (v == null) {
              continue; // pr118149
            }
            args.add(v);
            ret = Test.makeAnd(ret, Test.makeInstanceof(v, pTypes[i].resolve(shadow.getIWorld())));
          }
        }

        // handle thisJoinPoint parameters
        if ((extraParameterFlags & Advice.ThisJoinPoint) != 0) {
          args.add(shadow.getThisJoinPointVar());
        }

        if ((extraParameterFlags & Advice.ThisJoinPointStaticPart) != 0) {
          args.add(shadow.getThisJoinPointStaticPartVar());
        }

        if ((extraParameterFlags & Advice.ThisEnclosingJoinPointStaticPart) != 0) {
          args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
        }

        if ((extraParameterFlags & Advice.ThisAspectInstance) != 0) {
          args.add(shadow.getThisAspectInstanceVar(state.getConcreteAspect()));
        }
      } else {
        // @style is slightly different
        int currentStateIndex = 0;
        // FIXME AV - "args(jp)" test(jp, thejp) will fail here
        for (int i = 0; i < testMethod.getParameterTypes().length; i++) {
          String argSignature = testMethod.getParameterTypes()[i].getSignature();
          if (AjcMemberMaker.TYPEX_JOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisJoinPointVar());
          } else if (AjcMemberMaker.TYPEX_PROCEEDINGJOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisJoinPointVar());
          } else if (AjcMemberMaker.TYPEX_STATICJOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisJoinPointStaticPartVar());
          } else if (AjcMemberMaker.TYPEX_ENCLOSINGSTATICJOINPOINT.getSignature().equals(argSignature)) {
            args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
          } else {
            if (state.size() == 0 || currentStateIndex > state.size()) {
              String[] paramNames = testMethod.getParameterNames();
              StringBuffer errorParameter = new StringBuffer();
              if (paramNames != null) {
                errorParameter.append(testMethod.getParameterTypes()[i].getName()).append(" ");
                errorParameter.append(paramNames[i]);
                shadow.getIWorld()
                    .getMessageHandler()
                    .handleMessage(
                        MessageUtil.error("Missing binding for if() pointcut method.  Parameter " + (i + 1)
                            + "(" + errorParameter.toString()
                            + ") must be bound - even in reference pointcuts  (compiler limitation)",
                            testMethod.getSourceLocation()));
              } else {
                shadow.getIWorld()
                    .getMessageHandler()
                    .handleMessage(
                        MessageUtil.error("Missing binding for if() pointcut method.  Parameter " + (i + 1)
                            + " must be bound - even in reference pointcuts (compiler limitation)",
                            testMethod.getSourceLocation()));
              }
              return Literal.TRUE; // exit quickly
            }
            // we don't use i as JoinPoint.* can be anywhere in the signature in @style
            Var v = state.get(currentStateIndex++);

            while (v == null && currentStateIndex < state.size()) { // pr162135
              v = state.get(currentStateIndex++);
            }
            args.add(v);
View Full Code Here

  }

  public Var getKindedAnnotationVar(UnresolvedType forAnnotationType) {
    ResolvedType annType = forAnnotationType.resolve(world);
    if (annotationVar.get(annType) == null) {
      Var v = ReflectionVar.createAtAnnotationVar(annType, this.annotationFinder);
      annotationVar.put(annType, v);
    }
    return (Var) annotationVar.get(annType);
  }
View Full Code Here

   * @see org.aspectj.weaver.Shadow#getWithinAnnotationVar(org.aspectj.weaver.UnresolvedType)
   */
  public Var getWithinAnnotationVar(UnresolvedType forAnnotationType) {
    ResolvedType annType = forAnnotationType.resolve(world);
    if (withinAnnotationVar.get(annType) == null) {
      Var v = ReflectionVar.createWithinAnnotationVar(annType, this.annotationFinder);
      withinAnnotationVar.put(annType, v);
    }
    return (Var) withinAnnotationVar.get(annType);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.ast.Var

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.