]> source.dussan.org Git - aspectj.git/commitdiff
changed EclipseFactory.makeResolvedMember from static to non-static member and fully...
authoracolyer <acolyer>
Mon, 11 Jul 2005 13:48:13 +0000 (13:48 +0000)
committeracolyer <acolyer>
Mon, 11 Jul 2005 13:48:13 +0000 (13:48 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeConstructorDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/SuperFixerVisitor.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedFieldBinding.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java

index 06e7381c04603dc0ba9f92b29f83817d44663023..779dc9ee43804f4f5fddf30adc2a777c59bf6a99 100644 (file)
@@ -153,7 +153,7 @@ public class AccessForInlineVisitor extends ASTVisitor {
                        binding.modifiers = AstUtil.makePackageVisible(binding.modifiers);
                }
                
-               ResolvedMember m = EclipseFactory.makeResolvedMember(binding, receiverType);
+               ResolvedMember m = world.makeResolvedMember(binding, receiverType);
                if (inAspect.accessForInline.containsKey(m)) return (FieldBinding)inAspect.accessForInline.get(m);
                FieldBinding ret = new InlineAccessFieldBinding(inAspect, binding, m);
                
@@ -176,14 +176,14 @@ public class AccessForInlineVisitor extends ASTVisitor {
                        // declaring class?  After all, the field is private but we can see it from 
                        // where we are.
                        binding.modifiers = AstUtil.makePackageVisible(binding.modifiers);
-                       m = EclipseFactory.makeResolvedMember(binding);
+                       m = world.makeResolvedMember(binding);
                } else {
                        // Sometimes receiverType and binding.declaringClass are *not* the same.
                        
                        // Sometimes receiverType is a subclass of binding.declaringClass.  In these situations
                        // we want the generated inline accessor to call the method on the subclass (at
                        // runtime this will be satisfied by the super).
-                       m = EclipseFactory.makeResolvedMember(binding, receiverType);
+                       m = world.makeResolvedMember(binding, receiverType);
                }
                if (inAspect.accessForInline.containsKey(m)) return (MethodBinding)inAspect.accessForInline.get(m);
                MethodBinding ret = world.makeMethodBinding(
@@ -202,7 +202,7 @@ public class AccessForInlineVisitor extends ASTVisitor {
        }
        
        private MethodBinding getSuperAccessMethod(MethodBinding binding) {
-               ResolvedMember m = EclipseFactory.makeResolvedMember(binding);
+               ResolvedMember m = world.makeResolvedMember(binding);
                ResolvedMember superAccessMember = AjcMemberMaker.superAccessMethod(inAspect.typeX, m);
                if (inAspect.superAccessForInline.containsKey(superAccessMember)) {
                        return ((SuperAccessMethodPair)inAspect.superAccessForInline.get(superAccessMember)).accessMethod;
index 7b09a4d076c22d564c950738536371547539e7f5..d28960b4a4880cabceb581cfeebe696fb9183d94 100644 (file)
@@ -218,7 +218,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
                ResolvedTypeX declaringTypeX = world.fromEclipse(onTypeBinding);
                ResolvedTypeX aspectType = world.fromEclipse(classScope.referenceContext.binding);
                
-               ResolvedMember bindingAsMember = EclipseFactory.makeResolvedMember(binding);
+               ResolvedMember bindingAsMember = world.makeResolvedMember(binding);
                
                ResolvedMember signature =
                        new ResolvedMember(Member.CONSTRUCTOR, declaringTypeX, declaredModifiers, 
@@ -250,7 +250,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
                        
                        
                        ((NewConstructorTypeMunger)munger).setExplicitConstructor(
-                               EclipseFactory.makeResolvedMember(explicitConstructor));
+                               world.makeResolvedMember(explicitConstructor));
                } else {
                        ((NewConstructorTypeMunger)munger).setExplicitConstructor(
                                new ResolvedMember(Member.CONSTRUCTOR, 
index 0a539cfd7413c756907235d29e9c11ade8dd5075..9bb02707fa0d8ed877995484a3a51cc3efccc89e 100644 (file)
@@ -16,6 +16,7 @@ package org.aspectj.ajdt.internal.compiler.ast;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment;
 import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
 import org.aspectj.ajdt.internal.compiler.lookup.InterTypeMethodBinding;
 import org.aspectj.weaver.NameMangler;
@@ -95,8 +96,9 @@ public class SuperFixerVisitor extends ASTVisitor {
                        targetClass);
                        
                AstUtil.replaceMethodBinding(call, superAccessBinding);
-               
-               ResolvedMember targetMember = EclipseFactory.makeResolvedMember(superBinding);
+       
+       EclipseFactory factory = ((AjLookupEnvironment)method.scope.environment()).factory;
+               ResolvedMember targetMember = factory.makeResolvedMember(superBinding);
                superMethodsCalled.add(targetMember);
        }
 }
index 65aa041edf471cadc18ad57dc5e0e846dca4b570..6ef49eabcdd01bf6da8d274f1d8de1b185d6c058 100644 (file)
@@ -37,6 +37,7 @@ import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.TypeVariable;
 import org.aspectj.weaver.TypeVariableReferenceType;
 import org.aspectj.weaver.TypeX;
+import org.aspectj.weaver.UnresolvedTypeVariableReferenceType;
 import org.aspectj.weaver.World;
 import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
@@ -239,23 +240,24 @@ public class EclipseFactory {
                return TypeX.forName(getName(binding));
        }
 
+       private static Map typeVariableBindingsInProgress = new HashMap();
        private static TypeX fromTypeVariableBinding(TypeVariableBinding aTypeVariableBinding) {
+               if (typeVariableBindingsInProgress.containsKey(aTypeVariableBinding)) {
+                       return (TypeX) typeVariableBindingsInProgress.get(aTypeVariableBinding);
+               }
+               UnresolvedTypeVariableReferenceType ret = new UnresolvedTypeVariableReferenceType();
+               typeVariableBindingsInProgress.put(aTypeVariableBinding,ret);
                // TODO -- what about lower bounds??
-//             String name = new String(aTypeVariableBinding.sourceName());
-//             TypeX superclassType = fromBinding(aTypeVariableBinding.superclass());
-//             TypeX[] superinterfaces = new TypeX[aTypeVariableBinding.superInterfaces.length];
-//             for (int i = 0; i < superinterfaces.length; i++) {
-//                     superinterfaces[i] = fromBinding(aTypeVariableBinding.superInterfaces[i]);
-//             }
-//             TypeVariable tv = new TypeVariable(name,superclassType,superinterfaces);
-//             TypeVariableReferenceType ret = null; /// how do we get a world???
-//             return ret;
-               // old code...
-               if (aTypeVariableBinding.firstBound!=null) {
-                 return TypeX.forName(getName(aTypeVariableBinding.firstBound)); // XXX needs more investigation as to whether this is correct in all cases
-               } else {
-                 return TypeX.forName(getName(aTypeVariableBinding.superclass));
+               String name = new String(aTypeVariableBinding.sourceName());
+               TypeX superclassType = fromBinding(aTypeVariableBinding.superclass());
+               TypeX[] superinterfaces = new TypeX[aTypeVariableBinding.superInterfaces.length];
+               for (int i = 0; i < superinterfaces.length; i++) {
+                       superinterfaces[i] = fromBinding(aTypeVariableBinding.superInterfaces[i]);
                }
+               TypeVariable tv = new TypeVariable(name,superclassType,superinterfaces);
+               ret.setTypeVariable(tv);
+               typeVariableBindingsInProgress.remove(aTypeVariableBinding);
+               return ret;
        }
        
        public static TypeX[] fromBindings(TypeBinding[] bindings) {
@@ -336,33 +338,33 @@ public class EclipseFactory {
                return finishedTypeMungers;
        }
        
-       public static ResolvedMember makeResolvedMember(MethodBinding binding) {
+       public ResolvedMember makeResolvedMember(MethodBinding binding) {
                return makeResolvedMember(binding, binding.declaringClass);
        }
 
-       public static ResolvedMember makeResolvedMember(MethodBinding binding, TypeBinding declaringType) {
+       public ResolvedMember makeResolvedMember(MethodBinding binding, TypeBinding declaringType) {
                //System.err.println("member for: " + binding + ", " + new String(binding.declaringClass.sourceName));
                ResolvedMember ret =  new ResolvedMember(
                        binding.isConstructor() ? Member.CONSTRUCTOR : Member.METHOD,
-                       fromBinding(declaringType),
+                       world.resolve(fromBinding(declaringType)),
                        binding.modifiers,
-                       fromBinding(binding.returnType),
+                       world.resolve(fromBinding(binding.returnType)),
                        new String(binding.selector),
-                       fromBindings(binding.parameters),
-                       fromBindings(binding.thrownExceptions));
+                       world.resolve(fromBindings(binding.parameters)),
+                       world.resolve(fromBindings(binding.thrownExceptions)));
                return ret;
        }
 
-       public static ResolvedMember makeResolvedMember(FieldBinding binding) {
+       public ResolvedMember makeResolvedMember(FieldBinding binding) {
                return makeResolvedMember(binding, binding.declaringClass);
        }
        
-       public static ResolvedMember makeResolvedMember(FieldBinding binding, TypeBinding receiverType) {
+       public ResolvedMember makeResolvedMember(FieldBinding binding, TypeBinding receiverType) {
                return new ResolvedMember(
                        Member.FIELD,
-                       fromBinding(receiverType),
+                       world.resolve(fromBinding(receiverType)),
                        binding.modifiers,
-                       fromBinding(binding.type),
+                       world.resolve(fromBinding(binding.type)),
                        new String(binding.name),
                        TypeX.NONE);
        }
index 3ba294132d432b374670ced22976845dfa940ff0..6a27e4bf603e5efe551de9b5bc17e21e0d073576 100644 (file)
@@ -68,7 +68,7 @@ public class EclipseShadow extends Shadow {
                        return new Member(Member.STATIC_INITIALIZATION, getEnclosingType(), 0, 
                                                ResolvedTypeX.VOID, "<clinit>", TypeX.NONE);
                } else if (context instanceof AbstractMethodDeclaration) {
-                       return EclipseFactory.makeResolvedMember(((AbstractMethodDeclaration)context).binding);
+                       return world.makeResolvedMember(((AbstractMethodDeclaration)context).binding);
                } else {
                        return null;
                }
@@ -134,12 +134,12 @@ public class EclipseShadow extends Shadow {
                if (astNode instanceof AllocationExpression) {
                        AllocationExpression e = (AllocationExpression)astNode;
                        return new EclipseShadow(world, Shadow.ConstructorCall,
-                                       EclipseFactory.makeResolvedMember(e.binding), astNode, context);
+                                       world.makeResolvedMember(e.binding), astNode, context);
                } else if (astNode instanceof MessageSend) {
                        MessageSend e = (MessageSend)astNode;
                        if (e.isSuperAccess()) return null;  // super calls don't have shadows
                        return new EclipseShadow(world, Shadow.MethodCall,
-                                       EclipseFactory.makeResolvedMember(e.binding), astNode, context);
+                                       world.makeResolvedMember(e.binding), astNode, context);
                } else if (astNode instanceof ExplicitConstructorCall) {
                        //??? these should be ignored, they don't have shadows
                        return null;                            
@@ -167,7 +167,7 @@ public class EclipseShadow extends Shadow {
                                //throw new RuntimeException("unimplemented: " + e);
                        }
                        return new EclipseShadow(world, kind,
-                                       EclipseFactory.makeResolvedMember(e.binding), astNode, context);
+                                       world.makeResolvedMember(e.binding), astNode, context);
                } else if (astNode instanceof TypeDeclaration) {
                        return new EclipseShadow(world, Shadow.StaticInitialization,
                                                        new Member(Member.STATIC_INITIALIZATION, 
index d6ce0b6daf64f6538ca88b897e03e735ee1ca207..72175f599ac0217055aca1b35607af57481bc2b0 100644 (file)
@@ -151,7 +151,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                                        declaredPointcuts.add(df);
                                } else {
                                        if (amd.binding == null || !amd.binding.isValidBinding()) continue;
-                                       declaredMethods.add(EclipseFactory.makeResolvedMember(amd.binding));
+                                       declaredMethods.add(factory.makeResolvedMember(amd.binding));
                                }
                        }
                }
@@ -159,7 +159,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate {
                FieldBinding[] fields = binding.fields();
                for (int i=0, len=fields.length; i < len; i++) {
                        FieldBinding f = fields[i];
-                       declaredFields.add(EclipseFactory.makeResolvedMember(f));
+                       declaredFields.add(factory.makeResolvedMember(f));
                }
                        
                this.declaredPointcuts = (ResolvedPointcutDefinition[])
index 670e6c7212f42ca31c5b84cf7ad073d473717d57..0807c3d6162638f9d4fb1bdcf839c11fcf170254 100644 (file)
@@ -35,11 +35,11 @@ public class PrivilegedFieldBinding extends FieldBinding {
                this.reader = new SimpleSyntheticAccessMethodBinding(
                        inAspect.factory.makeMethodBinding(
                                AjcMemberMaker.privilegedAccessMethodForFieldGet(
-                                       inAspect.typeX, EclipseFactory.makeResolvedMember(baseField)
+                                       inAspect.typeX, inAspect.factory.makeResolvedMember(baseField)
                        )));
                this.writer = new SimpleSyntheticAccessMethodBinding(inAspect.factory.makeMethodBinding(
                                AjcMemberMaker.privilegedAccessMethodForFieldSet(
-                                       inAspect.typeX, EclipseFactory.makeResolvedMember(baseField)
+                                       inAspect.typeX, inAspect.factory.makeResolvedMember(baseField)
                        )));
                        
                this.constant = ASTNode.NotAConstant;
index 6ef97d471e8ea64b959fd6fdf6529d88730ae171..8306a499df8f15a506ff4e14bf58edf33248612d 100644 (file)
@@ -45,7 +45,7 @@ public class PrivilegedHandler implements IPrivilegedHandler {
        }
 
        public FieldBinding getPrivilegedAccessField(FieldBinding baseField, ASTNode location) {                
-               ResolvedMember key = EclipseFactory.makeResolvedMember(baseField);
+               ResolvedMember key = inAspect.factory.makeResolvedMember(baseField);
                if (accessors.containsKey(key)) return (FieldBinding)accessors.get(key);
                FieldBinding ret = new PrivilegedFieldBinding(inAspect, baseField);
                checkWeaveAccess(key.getDeclaringType(), location);
@@ -56,7 +56,7 @@ public class PrivilegedHandler implements IPrivilegedHandler {
        public MethodBinding getPrivilegedAccessMethod(MethodBinding baseMethod, ASTNode location) {
                if (baseMethod.alwaysNeedsAccessMethod()) return baseMethod;
                
-               ResolvedMember key = EclipseFactory.makeResolvedMember(baseMethod);
+               ResolvedMember key = inAspect.factory.makeResolvedMember(baseMethod);
                if (accessors.containsKey(key)) return (MethodBinding)accessors.get(key);
                
                MethodBinding ret;
index 0e9f8f2e7984f34a7b461dc4baab69412f13584c..ce41e48090c33a9ae364268995c5071a919c4895 100644 (file)
@@ -163,7 +163,7 @@ public class AjProblemReporter extends ProblemReporter {
                                                        m.getAspectType(),
                                                        sig.getDeclaringType().isInterface(
                                                                factory.getWorld())),
-                                               EclipseFactory.makeResolvedMember(concreteMethod))) {
+                                               factory.makeResolvedMember(concreteMethod))) {
                                        return;
                                }
                        }
@@ -210,7 +210,7 @@ public class AjProblemReporter extends ProblemReporter {
                                                        m.getAspectType(),
                                                        sig.getDeclaringType().isInterface(
                                                                factory.getWorld())),
-                                               EclipseFactory.makeResolvedMember(abstractMethod))) {
+                                               factory.makeResolvedMember(abstractMethod))) {
                                        return;
                                }
                        }
index 8f5cc266df78cc41d83474165488f4654e6449cf..9ff31370cd9b549d32cb21aa09f26e8edad7492a 100644 (file)
@@ -413,11 +413,12 @@ public class AsmHierarchyBuilder extends ASTVisitor {
     }
     
     private ResolvedMember getPointcutDeclaration(ReferencePointcut rp, MethodDeclaration declaration) {
-               World world = ((AjLookupEnvironment)declaration.scope.environment()).factory.getWorld();
+       EclipseFactory factory = ((AjLookupEnvironment)declaration.scope.environment()).factory;
+               World world = factory.getWorld();
                TypeX onType = rp.onType;
                if (onType == null) {
                        if (declaration.binding != null) {
-                           Member member = EclipseFactory.makeResolvedMember(declaration.binding);
+                           Member member = factory.makeResolvedMember(declaration.binding);
                                onType = member.getDeclaringType();
                        } else {
                                return null;
@@ -496,7 +497,8 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                        String memberName = "";
                        String memberBytecodeSignature = "";
                        try { 
-                               Member member = EclipseFactory.makeResolvedMember(methodDeclaration.binding);
+                       EclipseFactory factory = ((AjLookupEnvironment)methodDeclaration.scope.environment()).factory;
+                               Member member = factory.makeResolvedMember(methodDeclaration.binding);
                                memberName = member.getName();
                                memberBytecodeSignature = member.getSignature();
                        } catch (BCException bce) {  // bad type name 
@@ -684,7 +686,8 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                        String memberName = "";
                        String memberBytecodeSignature = "";
                        try {
-                               Member member = EclipseFactory.makeResolvedMember(constructorDeclaration.binding);
+                       EclipseFactory factory = ((AjLookupEnvironment)constructorDeclaration.scope.environment()).factory;
+                               Member member = factory.makeResolvedMember(constructorDeclaration.binding);
                                memberName = member.getName();
                                memberBytecodeSignature = member.getSignature();
                        } catch (BCException bce) {  // bad type name