Package org.aspectj.weaver

Examples of org.aspectj.weaver.IntMap


      // System.err.println("start: " + searchStart);
      // ResolvedType[] parameterTypes = searchStart.getWorld().resolve(pointcutDec.getParameterTypes());

      TypePatternList arguments = this.arguments.resolveReferences(bindings);

      IntMap newBindings = new IntMap();
      for (int i = 0, len = arguments.size(); i < len; i++) {
        TypePattern p = arguments.get(i);
        if (p == TypePattern.NO) {
          continue;
        }
        // we are allowed to bind to pointcuts which use subtypes as this is type safe
        // this will be checked in ReferencePointcut.resolveBindings(). Can't check it here
        // as we don't know about any new parents added via decp.
        if (p instanceof BindingTypePattern) {
          newBindings.put(i, ((BindingTypePattern) p).getFormalIndex());
        }
      }

      if (searchStart.isParameterizedType()) {
        // build a type map mapping type variable names in the generic type to
        // the type parameters presented
        typeVariableMap = new HashMap();
        ResolvedType underlyingGenericType = searchStart.getGenericType();
        TypeVariable[] tVars = underlyingGenericType.getTypeVariables();
        ResolvedType[] typeParams = searchStart.getResolvedTypeParameters();
        for (int i = 0; i < tVars.length; i++) {
          typeVariableMap.put(tVars[i].getName(), typeParams[i]);
        }
      }

      newBindings.copyContext(bindings);
      newBindings.pushEnclosingDefinition(pointcutDec);
      try {
        Pointcut ret = pointcutDec.getPointcut();
        if (typeVariableMap != null && !hasBeenParameterized) {
          ret = ret.parameterizeWith(typeVariableMap, searchStart.getWorld());
          ret.hasBeenParameterized = true;
        }
        return ret.concretize(searchStart, declaringType, newBindings);
      } finally {
        newBindings.popEnclosingDefinitition();
      }

    } finally {
      concretizing = false;
    }
View Full Code Here


          bindings.getEnclosingAdvice().getSourceLocation(), null);
      return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
    }

    // make this remap from formal positions to arrayIndices
    IntMap entryBindings = new IntMap();
    if (freeVars != null) {
      for (int i = 0, len = freeVars.length; i < len; i++) {
        int freeVar = freeVars[i];
        // int formalIndex = bindings.get(freeVar);
        entryBindings.put(freeVar, i);
      }
    }
    entryBindings.copyContext(bindings);
    // System.out.println(this + " bindings: " + entryBindings);

    World world = inAspect.getWorld();

    Pointcut concreteEntry;

    ResolvedType concreteAspect = bindings.getConcreteAspect();

    CrosscuttingMembers xcut = concreteAspect.crosscuttingMembers;
    Collection previousCflowEntries = xcut.getCflowEntries();

    entryBindings.pushEnclosingDefinition(CFLOW_MARKER);
    // This block concretizes the pointcut within the cflow pointcut
    try {
      concreteEntry = entry.concretize(inAspect, declaringType, entryBindings);
    } finally {
      entryBindings.popEnclosingDefinitition();
    }

    List innerCflowEntries = new ArrayList(xcut.getCflowEntries());
    innerCflowEntries.removeAll(previousCflowEntries);
View Full Code Here

     * Allocate a new var for each formal param of the inlined. Fill with stack contents. Then copy the inlined instructions in
     * with the appropriate remap table. Any framelocs used by locals in inlined are reallocated to top of frame,
     */
    final InstructionFactory fact = recipient.getEnclosingClass().getFactory();

    IntMap frameEnv = new IntMap();

    // this also sets up the initial environment
    InstructionList argumentStores = genArgumentStores(donor, recipient, frameEnv, fact);

    InstructionList inlineInstructions = genInlineInstructions(donor, recipient, frameEnv, fact, false);
View Full Code Here

     * table.  Any framelocs used by locals in inlined are reallocated to top of
     * frame,
     */
    final InstructionFactory fact = recipient.getEnclosingClass().getFactory();

    IntMap frameEnv = new IntMap();

    // this also sets up the initial environment
    InstructionList argumentStores =
      genArgumentStores(donor, recipient, frameEnv, fact);

View Full Code Here

          bindings.getEnclosingAdvice().getSourceLocation(), null);
      return Pointcut.makeMatchesNothing(Pointcut.CONCRETE);
    }
   
    //make this remap from formal positions to arrayIndices
    IntMap entryBindings = new IntMap();
    if (freeVars!=null) {
      for (int i=0, len=freeVars.length; i < len; i++) {
      int freeVar = freeVars[i];
      //int formalIndex = bindings.get(freeVar);
      entryBindings.put(freeVar, i);
      }
    }
    entryBindings.copyContext(bindings);
    //System.out.println(this + " bindings: " + entryBindings);
   
    World world = inAspect.getWorld();
   
    Pointcut concreteEntry;
   
    ResolvedType concreteAspect = bindings.getConcreteAspect();
   
    CrosscuttingMembers xcut = concreteAspect.crosscuttingMembers;   
    Collection previousCflowEntries = xcut.getCflowEntries();
   
   
    entryBindings.pushEnclosingDefinition(CFLOW_MARKER);
    // This block concretizes the pointcut within the cflow pointcut
    try {
      concreteEntry = entry.concretize(inAspect, declaringType, entryBindings);
    } finally {
      entryBindings.popEnclosingDefinitition();
    }

    List innerCflowEntries = new ArrayList(xcut.getCflowEntries());
    innerCflowEntries.removeAll(previousCflowEntries);
View Full Code Here

             if (inScope != null) {
               declaringTypeForResolution = getWorld().resolve(inScope.getName());
             } else {
               declaringTypeForResolution = ResolvedType.OBJECT.resolve(getWorld());
             }
             IntMap arity = new IntMap(formalParameters.length);
             for (int i = 0; i < formalParameters.length; i++) {
               arity.put(i, i);
             }            
             pc = pc.concretize(declaringTypeForResolution, declaringTypeForResolution, arity);
             validateAgainstSupportedPrimitives(pc,expression); // again, because we have now followed any ref'd pcuts
             pcExpr = new PointcutExpressionImpl(pc,expression,formalParameters,getWorld());
         } catch (ParserException pEx) {
View Full Code Here

 
 
  //XXX this is the signature we're moving to
  public final Pointcut concretize(ResolvedType inAspect, ResolvedType declaringType, int arity, ShadowMunger advice) {
    //if (state == CONCRETE) return this; //???
    IntMap map = IntMap.idMap(arity);
    map.setEnclosingAdvice(advice);
    map.setConcreteAspect(inAspect);
    return concretize(inAspect, declaringType, map);
  }
View Full Code Here

      //System.err.println("start: " + searchStart);
      ResolvedType[] parameterTypes = searchStart.getWorld().resolve(pointcutDec.getParameterTypes());
     
      TypePatternList arguments = this.arguments.resolveReferences(bindings);
     
      IntMap newBindings = new IntMap();
      for (int i=0,len=arguments.size(); i < len; i++) {
        TypePattern p = arguments.get(i);
        if (p == TypePattern.NO) continue;
        // we are allowed to bind to pointcuts which use subtypes as this is type safe
        // this will be checked in ReferencePointcut.resolveBindings().  Can't check it here
        // as we don't know about any new parents added via decp.
          if (p instanceof BindingTypePattern) {
            newBindings.put(i, ((BindingTypePattern)p).getFormalIndex());
          }
      }

      if (searchStart.isParameterizedType()) {
        // build a type map mapping type variable names in the generic type to
        // the type parameters presented
        typeVariableMap = new HashMap();
        ResolvedType underlyingGenericType = searchStart.getGenericType();
        TypeVariable[] tVars = underlyingGenericType.getTypeVariables();
        ResolvedType[] typeParams = searchStart.getResolvedTypeParameters();
        for (int i = 0; i < tVars.length; i++) {
          typeVariableMap.put(tVars[i].getName(),typeParams[i]);
        }
      }
     
      newBindings.copyContext(bindings);
      newBindings.pushEnclosingDefinition(pointcutDec);
      try {
        Pointcut ret = pointcutDec.getPointcut();
        if (typeVariableMap != null && !hasBeenParameterized) {         
          ret = ret.parameterizeWith(typeVariableMap);
          ret.hasBeenParameterized=true;
        }
        return ret.concretize(searchStart, declaringType, newBindings);
      } finally {
        newBindings.popEnclosingDefinitition();
      }
     
    } finally {
      concretizing = false;
    }
View Full Code Here

                        ret.baseArgsCount++;
                    }
                }
            }

      IntMap newBindings = IntMap.idMap(ret.baseArgsCount);
      newBindings.copyContext(bindings);
      ret.residueSource = def.getPointcut().concretize(inAspect, declaringType, newBindings);
    }
   
    return ret;
  }
View Full Code Here

   
    // create a map that will move all slots in advice method forward by extraParamOffset
    // in order to make room for the new proceed-required arguments that are added at
    // the beginning of the parameter list
    int nVars = adviceMethod.getMaxLocals() + extraParamOffset;
    IntMap varMap = IntMap.idMap(nVars);
    for (int i=extraParamOffset; i < nVars; i++) {
      varMap.put(i-extraParamOffset, i);
    }

    localAdviceMethod.getBody().insert(
      BcelClassWeaver.genInlineInstructions(adviceMethod,
          localAdviceMethod, varMap, fact, true));
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.IntMap

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.