Package org.aspectj.ajdt.internal.compiler.lookup

Examples of org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory


    // annotations on the ITD declaration get put on this method
    generateDispatchMethod(classScope, classFile);
  }
 
  public void generateDispatchMethod(ClassScope classScope, ClassFile classFile) {
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope);
   
    UnresolvedType aspectType = world.fromBinding(classScope.referenceContext.binding);
    ResolvedMember signature = munger.getSignature();
   
    ResolvedMember dispatchMember =
      AjcMemberMaker.interMethodDispatcher(signature, aspectType);
    MethodBinding dispatchBinding = world.makeMethodBinding(dispatchMember,munger.getTypeVariableAliases(),munger.getSignature().getDeclaringType());
    MethodBinding introducedMethod =
      world.makeMethodBinding(AjcMemberMaker.interMethod(signature, aspectType, onTypeBinding.isInterface()),munger.getTypeVariableAliases());
   
    classFile.generateMethodInfoHeader(dispatchBinding);
    int methodAttributeOffset = classFile.contentsOffset;
   
   
View Full Code Here


    try {
      ISourceContext context = new EclipseSourceContext(unit.compilationResult,pcLocation[0]);
      Pointcut pc = new PatternParser(pointcutExpression,context).parsePointcut();
      FormalBinding[] bindings = buildFormalAdviceBindingsFrom(methodDeclaration);
      pc.resolve(new EclipseScope(bindings,methodDeclaration.scope));
      EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(methodDeclaration.scope);
      // now create a ResolvedPointcutDefinition,make an attribute out of it, and add it to the method
      UnresolvedType[] paramTypes = new UnresolvedType[bindings.length];
      for (int i = 0; i < paramTypes.length; i++) paramTypes[i] = bindings[i].getType();
      ResolvedPointcutDefinition resPcutDef =
        new ResolvedPointcutDefinition(
            factory.fromBinding(((TypeDeclaration)typeStack.peek()).binding),
            methodDeclaration.modifiers,
            "anonymous",
            paramTypes,
            pc
        );
View Full Code Here

    }
  }
 
  private FormalBinding[] buildFormalAdviceBindingsFrom(MethodDeclaration mDecl) {
    if (mDecl.arguments == null) return new FormalBinding[0];
    EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(mDecl.scope);
    String extraArgName = maybeGetExtraArgName();
    if (extraArgName == null) extraArgName = "";
    FormalBinding[] ret = new FormalBinding[mDecl.arguments.length];
    for (int i = 0; i < mDecl.arguments.length; i++) {
            Argument arg = mDecl.arguments[i];
            String name = new String(arg.name);
      TypeBinding argTypeBinding = mDecl.binding.parameters[i];
            UnresolvedType type = factory.fromBinding(argTypeBinding);
      if  (CharOperation.equals(joinPoint,argTypeBinding.signature()) ||
         CharOperation.equals(joinPointStaticPart,argTypeBinding.signature()) ||
         CharOperation.equals(joinPointEnclosingStaticPart,argTypeBinding.signature()) ||
         CharOperation.equals(proceedingJoinPoint,argTypeBinding.signature()) ||
         name.equals(extraArgName)) {
View Full Code Here

 
  public void resolve(ClassScope upperScope) {
    if (munger == null) ignoreFurtherInvestigation = true;
    if (ignoreFurtherInvestigation) return;
   
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(upperScope);
    ResolvedMember sig = munger.getSignature();
    UnresolvedType aspectType = world.fromBinding(upperScope.referenceContext.binding);
   
    if (sig.getReturnType() == ResolvedType.VOID ||
        (sig.getReturnType().isArray() && (sig.getReturnType().getComponentType() == ResolvedType.VOID)))
    {
      upperScope.problemReporter().signalError(sourceStart, sourceEnd,
        "field type can not be void");
    }
   
//
//    System.err.println("sig: " + sig);
//    System.err.println("field: " + world.makeFieldBinding(
//        AjcMemberMaker.interFieldClassField(sig, aspectType)));
   

    if (initialization != null && initialization instanceof ArrayInitializer) {
      //System.err.println("got initializer: " + initialization);
      ArrayAllocationExpression aae = new ArrayAllocationExpression();
      aae.initializer = (ArrayInitializer)initialization;
      ArrayBinding arrayType = (ArrayBinding)world.makeTypeBinding(sig.getReturnType());
      aae.type = AstUtil.makeTypeReference(arrayType.leafComponentType());
      aae.sourceStart = initialization.sourceStart;
      aae.sourceEnd = initialization.sourceEnd;
      aae.dimensions = new Expression[arrayType.dimensions];
      initialization = aae;
    } /*else if (initialization!=null) {
      MethodScope initializationScope = this.scope;
      TypeBinding fieldType = realFieldType;
      TypeBinding initializationType;
      this.initialization.setExpectedType(fieldType); // needed in case of generic method invocation
      if (this.initialization instanceof ArrayInitializer) {
   
        if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) {
          ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType;
          this.initialization.computeConversion(initializationScope, fieldType, initializationType);
        }
      }
//      System.err.println("i=>"+initialization);
//      System.err.println("sasuages=>"+initialization.resolvedType);
//      //initializationType = initialization.resolveType(initializationScope);
//      System.err.println("scope=>"+initializationScope);

      else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) {
   
        if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError()
          initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType);
        if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType)
            || (fieldType.isBaseType() && BaseTypeBinding.isWidening(fieldType.id, initializationType.id))
            || initializationType.isCompatibleWith(fieldType)) {
          initialization.computeConversion(initializationScope, fieldType, initializationType);
          if (initializationType.needsUncheckedConversion(fieldType)) {
                initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType);
          }                 
        } else if (initializationScope.isBoxingCompatibleWith(initializationType, fieldType)
                  || (initializationType.isBaseType()  // narrowing then boxing ?
                      && initializationScope.compilerOptions().sourceLevel >= JDK1_5 // autoboxing
                      && !fieldType.isBaseType()
                      && initialization.isConstantValueOfTypeAssignableToType(initializationType, initializationScope.environment().computeBoxingType(fieldType)))) {
          this.initialization.computeConversion(initializationScope, fieldType, initializationType);
        } else {
          initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this);
        }
    //      if (this.binding.isFinal()){ // cast from constant actual type to variable type
    //        this.binding.setConstant(this.initialization.constant.castTo((this.binding.returnType.id << 4) + this.initialization.constant.typeID()));
    //      }
    //    } else {
    //      this.binding.setConstant(NotAConstant);
      }
    //   
    }
   
    */
   
   
   
   
    //////////////////////

   
    if (initialization == null) {
      this.statements = new Statement[] {
        new ReturnStatement(null, 0, 0),
      };
    } else if (!onTypeBinding.isInterface()) {
      MethodBinding writeMethod = world.makeMethodBinding(
          AjcMemberMaker.interFieldSetDispatcher(sig,aspectType),munger.getTypeVariableAliases());
      // For the body of an intertype field initalizer, generate a call to the inter field set dispatcher
      // method as that casts the shadow of a field set join point.
      if (Modifier.isStatic(declaredModifiers)) {
          this.statements = new Statement[] {
            new KnownMessageSend(writeMethod,
                AstUtil.makeNameReference(writeMethod.declaringClass),
                new Expression[] {initialization}),
          };
      } else {
        this.statements = new Statement[] {
            new KnownMessageSend(writeMethod,
                AstUtil.makeNameReference(writeMethod.declaringClass),
                new Expression[] {AstUtil.makeLocalVariableReference(arguments[0].binding),initialization}),
          };
      }
    } else {
      //XXX something is broken about this logic.  Can we write to static interface fields?
      MethodBinding writeMethod = world.makeMethodBinding(
        AjcMemberMaker.interFieldInterfaceSetter(sig, sig.getDeclaringType().resolve(world.getWorld()), aspectType),munger.getTypeVariableAliases());
      if (Modifier.isStatic(declaredModifiers)) {
        this.statements = new Statement[] {
          new KnownMessageSend(writeMethod,
              AstUtil.makeNameReference(writeMethod.declaringClass),
              new Expression[] {initialization}),
View Full Code Here

//  //      this.binding.setConstant(NotAConstant);
//    }}
   
  }*/
  public EclipseTypeMunger build(ClassScope classScope) {
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope);
    resolveOnType(classScope);
   
    if (ignoreFurtherInvestigation) return null;
   
    binding = classScope.referenceContext.binding.resolveTypesFor(binding);
    if (ignoreFurtherInvestigation) return null;
   
    if (isTargetAnnotation(classScope,"field")) return null; // Error message output in isTargetAnnotation
    if (isTargetEnum(classScope,"field")) return null; // Error message output in isTargetEnum
   
    if (!Modifier.isStatic(declaredModifiers)) {
      super.binding.parameters = new TypeBinding[] {
        onTypeBinding,
      };
      this.arguments = new Argument[] {
        AstUtil.makeFinalArgument("ajc$this_".toCharArray(), onTypeBinding),
      };
    }
   
    //System.err.println("type: " + binding.returnType + ", " + returnType);
    ResolvedType declaringType = world.fromBinding(onTypeBinding).resolve(world.getWorld());
    if (declaringType.isRawType() || declaringType.isParameterizedType()) {
      declaringType = declaringType.getGenericType();
    }
   
    if (interTypeScope==null) return null; // We encountered a problem building the scope, don't continue - error already reported

   
    // Build a half correct resolvedmember (makeResolvedMember understands tvars) then build a fully correct sig from it
    ResolvedMember sigtemp = world.makeResolvedMemberForITD(binding,onTypeBinding,interTypeScope.getRecoveryAliases());
    ResolvedMember sig = new ResolvedMemberImpl(Member.FIELD,declaringType,declaredModifiers,
                          sigtemp.getReturnType(),new String(declaredSelector),UnresolvedType.NONE);
    sig.setTypeVariables(sigtemp.getTypeVariables());
   
    NewFieldTypeMunger myMunger = new NewFieldTypeMunger(sig, null,typeVariableAliases);
    setMunger(myMunger);
    ResolvedType aspectType = world.fromEclipse(classScope.referenceContext.binding);
    ResolvedMember me =
      myMunger.getInitMethod(aspectType);
    this.selector = binding.selector = me.getName().toCharArray();
    this.realFieldType = this.binding.returnType;
    this.binding.returnType = TypeBinding.VoidBinding;
View Full Code Here

//    interBinding.reader.generateMethod(this, classScope, classFile);
//    interBinding.writer.generateMethod(this, classScope, classFile);
  }

  private void generateDispatchMethods(ClassScope classScope, ClassFile classFile) {
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope);
    ResolvedMember sig = munger.getSignature();
    UnresolvedType aspectType = world.fromBinding(classScope.referenceContext.binding);
    generateDispatchMethod(world, sig, aspectType, classScope, classFile, true);
    generateDispatchMethod(world, sig, aspectType, classScope, classFile, false);
  }
View Full Code Here

    if (binding != null) {
      ThisJoinPointVisitor tjp = new ThisJoinPointVisitor(this);
      ifPointcut.extraParameterFlags |= tjp.removeUnusedExtraArguments();
     
      //XXX this is where we should remove unavailable args if we're in a cflow
      EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(scope);
      ifPointcut.testMethod = new ResolvedMemberImpl(
        Member.METHOD,
        factory.fromBinding(binding.declaringClass),
        this.modifiers, ResolvedType.BOOLEAN, 
        new String(this.selector),
        factory.fromBindings(this.binding.parameters));
   
  }
View Full Code Here

          return;
      }
    }
   
   
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(scope);
    ResolvedType myType = typeX;
    //if (myType == null) System.err.println("bad myType for: " + this);
    ResolvedType superType = myType.getSuperclass();   
   
    // can't be Serializable/Cloneable unless -XserializableAspects
    if (!world.isXSerializableAspects()) {
      if (world.getWorld().getCoreType(UnresolvedType.SERIALIZABLE).isAssignableFrom(myType)) {
        scope.problemReporter().signalError(sourceStart, sourceEnd,
                "aspects may not implement Serializable");
        ignoreFurtherInvestigation = true;
          return;
      }
      if (world.getWorld().getCoreType(UnresolvedType.CLONEABLE).isAssignableFrom(myType)) {
        scope.problemReporter().signalError(sourceStart, sourceEnd,
                "aspects may not implement Cloneable");
        ignoreFurtherInvestigation = true;
          return;
      }
View Full Code Here

    if (perClause == null) {
      System.err.println("has null perClause: " + this);
      return;
    }
   
    EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
   
    if (perClause.getKind() == PerClause.SINGLETON) {
      generatePerSingletonAspectOfMethod(classFile);
      generatePerSingletonHasAspectMethod(classFile);
      generatePerSingletonAjcClinitMethod(classFile);
    } else if (perClause.getKind() == PerClause.PERCFLOW) {
      generatePerCflowAspectOfMethod(classFile);
      generatePerCflowHasAspectMethod(classFile);
      generatePerCflowPushMethod(classFile);
      generatePerCflowAjcClinitMethod(classFile);
    } else if (perClause.getKind() == PerClause.PEROBJECT) {
      TypeBinding interfaceType =
        generatePerObjectInterface(classFile);
      world.addTypeBinding(interfaceType);
      generatePerObjectAspectOfMethod(classFile, interfaceType);
      generatePerObjectHasAspectMethod(classFile, interfaceType);
      generatePerObjectBindMethod(classFile, interfaceType);
    } else if (perClause.getKind() == PerClause.PERTYPEWITHIN) {
        //PTWIMPL Generate the methods required *in the aspect*
 
View Full Code Here

    public void generate(CodeStream codeStream);
  }
 
 
  private void generateMethod(ClassFile classFile, ResolvedMember member, BodyGenerator gen) {
    final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
    generateMethod(classFile, world.makeMethodBinding(member), gen);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory

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.