]> source.dussan.org Git - aspectj.git/commitdiff
239649 and primitives no longer all resolved by default
authoraclement <aclement>
Fri, 12 Aug 2011 17:51:10 +0000 (17:51 +0000)
committeraclement <aclement>
Fri, 12 Aug 2011 17:51:10 +0000 (17:51 +0000)
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfMethodDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IfPseudoToken.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/InterTypeFieldDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ThisJoinPointVisitor.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/PrivilegedHandler.java

index 3bbd8ddf03fac3abdf665adf1ddbd14c255ca08c..cfbf9d8efbb6b31cef24c3a4523301b378020085 100644 (file)
@@ -27,6 +27,8 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
 import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference;
 import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -370,17 +372,27 @@ public class AdviceDeclaration extends AjMethodDeclaration {
        }
 
        // called by IfPseudoToken
-       public static Argument[] addTjpArguments(Argument[] arguments) {
+       public static Argument[] addTjpArguments(Argument[] arguments, TypeDeclaration containingTypeDec) {
                int index = arguments.length;
-               arguments = extendArgumentsLength(arguments, 3);
+               arguments = extendArgumentsLength(arguments, 4);
 
                arguments[index++] = makeFinalArgument("thisJoinPointStaticPart", AjTypeConstants.getJoinPointStaticPartType());
                arguments[index++] = makeFinalArgument("thisJoinPoint", AjTypeConstants.getJoinPointType());
                arguments[index++] = makeFinalArgument("thisEnclosingJoinPointStaticPart", AjTypeConstants.getJoinPointStaticPartType());
+               arguments[index++] = makeFinalArgument("thisAspectInstance", toReference(containingTypeDec.name));
 
                return arguments;
        }
 
+       private static TypeReference toReference(char[] typename) {
+               if (CharOperation.contains('.', typename)) {
+                       char[][] compoundName = CharOperation.splitOn('.', typename);
+                       return new QualifiedTypeReference(compoundName, new long[compoundName.length]);
+               } else {
+                       return new SingleTypeReference(typename, 0);
+               }
+       }
+
        private static Argument makeFinalArgument(String name, TypeReference typeRef) {
                long pos = 0; // XXX encode start and end location
                return new Argument(name.toCharArray(), pos, typeRef, Modifier.FINAL);
@@ -415,13 +427,13 @@ public class AdviceDeclaration extends AjMethodDeclaration {
        // };
        // };
        //              s += ")"; //$NON-NLS-1$
-       //              
+       //
        // if (extraArgument != null) {
        // s += "(" + extraArgument.toString(0) + ")";
        // }
-       //              
-       //              
-       //              
+       //
+       //
+       //
        // if (thrownExceptions != null) {
        //                      s += " throws "; //$NON-NLS-1$
        // for (int i = 0; i < thrownExceptions.length; i++) {
@@ -430,7 +442,7 @@ public class AdviceDeclaration extends AjMethodDeclaration {
        //                                      s = s + ", "; //$NON-NLS-1$
        // };
        // };
-       //              
+       //
        // s += ": ";
        // if (pointcutDesignator != null) {
        // s += pointcutDesignator.toString(0);
index 4f14734637ad97f32c663856caef9dc9db26e357..65115429cbf4e8a128f8fbe2e101ce42cafd76c0 100644 (file)
@@ -17,11 +17,13 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
 import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
 import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser;
 import org.aspectj.weaver.Member;
 import org.aspectj.weaver.ResolvedMemberImpl;
-import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.patterns.IfPointcut;
+import org.aspectj.weaver.patterns.PerClause;
 
 public class IfMethodDeclaration extends AjMethodDeclaration {
        IfPointcut ifPointcut;
@@ -39,7 +41,6 @@ public class IfMethodDeclaration extends AjMethodDeclaration {
                return classFile.generateMethodInfoAttribute(binding, false, AstUtil.getAjSyntheticAttribute());
        }
 
-       // private static class TrueFalseVisitor extends astvi
        public void resolveStatements() {
                super.resolveStatements();
                if (binding != null) {
@@ -61,7 +62,21 @@ public class IfMethodDeclaration extends AjMethodDeclaration {
                        // 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));
+                                       this.modifiers, UnresolvedType.BOOLEAN, new String(this.selector),
+                                       factory.fromBindings(this.binding.parameters));
+                       if (tjp.needsThisAspectInstance && scope.parent instanceof ClassScope) { // really should be
+                               ClassScope o = (ClassScope) scope.parent;
+                               if (o.referenceContext instanceof AspectDeclaration) { // really should be
+                                       AspectDeclaration aspectDecl = (AspectDeclaration) o.referenceContext;
+                                       if (aspectDecl.perClause != null && aspectDecl.perClause.getKind() != PerClause.SINGLETON) {
+                                               scope.problemReporter()
+                                                               .signalError(sourceStart, sourceEnd,
+                                                                               "thisAspectInstance can only be used inside an if() clause for singleton aspects (compiler limitation)");
+                                               ignoreFurtherInvestigation = true;
+                                               return;
+                                       }
+                               }
+                       }
                }
        }
 }
index 314884636be40f9f37d90ab630758ed134faa11b..9bf2f3171fe172be89e91daa6da9c519fbe334fd 100644 (file)
@@ -77,12 +77,13 @@ public class IfPseudoToken extends PseudoToken {
                if (pointcut == null)
                        return;
 
-               testMethod = makeMethod(enclosingDec.compilationResult, enclosingDec);
+               testMethod = makeIfMethod(enclosingDec.compilationResult, enclosingDec, typeDec);
                AstUtil.addMethodDeclaration(typeDec, testMethod);
        }
 
        // XXX todo: make sure that errors in Arguments only get displayed once
-       private MethodDeclaration makeMethod(CompilationResult result, MethodDeclaration enclosingDec) {
+       private MethodDeclaration makeIfMethod(CompilationResult result, MethodDeclaration enclosingDec,
+                       TypeDeclaration containingTypeDec) {
                MethodDeclaration ret = new IfMethodDeclaration(result, pointcut);
                ret.modifiers = ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccPublic;
                ret.returnType = AstUtil.makeTypeReference(TypeBinding.BOOLEAN);
@@ -107,12 +108,12 @@ public class IfPseudoToken extends PseudoToken {
                // }
                // hashcode of expression
                ret.selector = ifSelector.toString().toCharArray();
-               ret.arguments = makeArguments(enclosingDec);
+               ret.arguments = makeArguments(enclosingDec, containingTypeDec);
                ret.statements = new Statement[] { new ReturnStatement(expr, expr.sourceStart, expr.sourceEnd) };
                return ret;
        }
 
-       private Argument[] makeArguments(MethodDeclaration enclosingDec) {
+       private Argument[] makeArguments(MethodDeclaration enclosingDec, TypeDeclaration containingTypeDec) {
                Argument[] baseArguments = enclosingDec.arguments;
                int len = baseArguments.length;
                if (enclosingDec instanceof AdviceDeclaration) {
@@ -124,7 +125,7 @@ public class IfPseudoToken extends PseudoToken {
                        Argument a = baseArguments[i];
                        ret[i] = new Argument(a.name, AstUtil.makeLongPos(a.sourceStart, a.sourceEnd), a.type, Modifier.FINAL);
                }
-               ret = AdviceDeclaration.addTjpArguments(ret);
+               ret = AdviceDeclaration.addTjpArguments(ret, containingTypeDec);
 
                return ret;
        }
index cc569c1c4dbdd9c929c39149e4cb35637e148992..fddcc3b903e85aa2c8b7e90aae020ea43233b10e 100644 (file)
@@ -324,7 +324,7 @@ public class InterTypeConstructorDeclaration extends InterTypeDeclaration {
                        ((NewConstructorTypeMunger) munger).setExplicitConstructor(world.makeResolvedMember(explicitConstructor));
                } else {
                        ((NewConstructorTypeMunger) munger).setExplicitConstructor(new ResolvedMemberImpl(Member.CONSTRUCTOR, world
-                                       .fromBinding(onTypeBinding.superclass()), 0, ResolvedType.VOID, "<init>", UnresolvedType.NONE));
+                                       .fromBinding(onTypeBinding.superclass()), 0, UnresolvedType.VOID, "<init>", UnresolvedType.NONE));
                }
                return new AjAttribute.TypeMunger(munger);
        }
index 9e87c57930debbb927de0985ba5e1a6562583d96..aa67fc2efcc791075eb052fb4708bbd34c37d6ab 100644 (file)
@@ -109,8 +109,8 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
                ResolvedMember sig = munger.getSignature();
                UnresolvedType aspectType = world.fromBinding(upperScope.referenceContext.binding);
 
-               if (sig.getReturnType() == ResolvedType.VOID
-                               || (sig.getReturnType().isArray() && (sig.getReturnType().getComponentType() == ResolvedType.VOID))) {
+               if (sig.getReturnType().equals(UnresolvedType.VOID)
+                               || (sig.getReturnType().isArray() && (sig.getReturnType().getComponentType().equals(UnresolvedType.VOID)))) {
                        upperScope.problemReporter().signalError(sourceStart, sourceEnd, "field type can not be void");
                }
 
@@ -166,28 +166,29 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
                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());
+                       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 }), };
+                               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 }), };
+                               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());
+                       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 }), };
+                               this.statements = new Statement[] { new KnownMessageSend(writeMethod,
+                                               AstUtil.makeNameReference(writeMethod.declaringClass), new Expression[] { initialization }), };
                        } else {
-                               this.statements = new Statement[] { new KnownMessageSend(writeMethod, AstUtil
-                                               .makeLocalVariableReference(arguments[0].binding), new Expression[] { initialization }), };
+                               this.statements = new Statement[] { new KnownMessageSend(writeMethod,
+                                               AstUtil.makeLocalVariableReference(arguments[0].binding), new Expression[] { initialization }), };
                        }
                }
 
@@ -314,16 +315,16 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
                        ClassFile classFile, boolean isGetter) {
                MethodBinding binding;
                if (isGetter) {
-                       binding = world.makeMethodBinding(AjcMemberMaker.interFieldGetDispatcher(sig, aspectType), munger
-                                       .getTypeVariableAliases(), munger.getSignature().getDeclaringType());
+                       binding = world.makeMethodBinding(AjcMemberMaker.interFieldGetDispatcher(sig, aspectType),
+                                       munger.getTypeVariableAliases(), munger.getSignature().getDeclaringType());
                } else {
-                       binding = world.makeMethodBinding(AjcMemberMaker.interFieldSetDispatcher(sig, aspectType), munger
-                                       .getTypeVariableAliases(), munger.getSignature().getDeclaringType());
+                       binding = world.makeMethodBinding(AjcMemberMaker.interFieldSetDispatcher(sig, aspectType),
+                                       munger.getTypeVariableAliases(), munger.getSignature().getDeclaringType());
                }
                classFile.generateMethodInfoHeader(binding);
                int methodAttributeOffset = classFile.contentsOffset;
-               int attributeNumber = classFile.generateMethodInfoAttribute(binding, false, makeEffectiveSignatureAttribute(sig,
-                               isGetter ? Shadow.FieldGet : Shadow.FieldSet, false));
+               int attributeNumber = classFile.generateMethodInfoAttribute(binding, false,
+                               makeEffectiveSignatureAttribute(sig, isGetter ? Shadow.FieldGet : Shadow.FieldSet, false));
                int codeAttributeOffset = classFile.contentsOffset;
                classFile.generateCodeAttributeHeader();
                CodeStream codeStream = classFile.codeStream;
@@ -331,7 +332,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
 
                NewFieldTypeMunger fieldMunger = (NewFieldTypeMunger) munger;
 
-        // Force use of version 1 if there is a field with that name on the type already
+               // Force use of version 1 if there is a field with that name on the type already
                if (world.getItdVersion() == 1) {
                        fieldMunger.version = NewFieldTypeMunger.VersionOne;
                } else {
@@ -346,24 +347,27 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration {
                        }
                }
 
-               FieldBinding classField = world.makeFieldBinding(AjcMemberMaker.interFieldClassField(sig, aspectType,
-                               fieldMunger.version == NewFieldTypeMunger.VersionTwo), munger.getTypeVariableAliases());
+               FieldBinding classField = world.makeFieldBinding(
+                               AjcMemberMaker.interFieldClassField(sig, aspectType, fieldMunger.version == NewFieldTypeMunger.VersionTwo),
+                               munger.getTypeVariableAliases());
 
                codeStream.initializeMaxLocals(binding);
                if (isGetter) {
                        if (onTypeBinding.isInterface()) {
                                UnresolvedType declaringTX = sig.getDeclaringType();
                                ResolvedType declaringRTX = world.getWorld().resolve(declaringTX, munger.getSourceLocation());
-                               MethodBinding readMethod = world.makeMethodBinding(AjcMemberMaker.interFieldInterfaceGetter(sig, declaringRTX,
-                                               aspectType), munger.getTypeVariableAliases());
+                               MethodBinding readMethod = world.makeMethodBinding(
+                                               AjcMemberMaker.interFieldInterfaceGetter(sig, declaringRTX, aspectType), munger.getTypeVariableAliases());
                                generateInterfaceReadBody(binding, readMethod, codeStream);
                        } else {
                                generateClassReadBody(binding, classField, codeStream);
                        }
                } else {
                        if (onTypeBinding.isInterface()) {
-                               MethodBinding writeMethod = world.makeMethodBinding(AjcMemberMaker.interFieldInterfaceSetter(sig, world.getWorld()
-                                               .resolve(sig.getDeclaringType(), munger.getSourceLocation()), aspectType), munger.getTypeVariableAliases());
+                               MethodBinding writeMethod = world.makeMethodBinding(
+                                               AjcMemberMaker.interFieldInterfaceSetter(sig,
+                                                               world.getWorld().resolve(sig.getDeclaringType(), munger.getSourceLocation()), aspectType),
+                                               munger.getTypeVariableAliases());
                                generateInterfaceWriteBody(binding, writeMethod, codeStream);
                        } else {
                                generateClassWriteBody(binding, classField, codeStream);
index 0cdc91b098e766861eb3fedb761aa5cc844ae161..9f4273fe336481e91ffe7493503d67dc75b095dc 100644 (file)
@@ -40,6 +40,7 @@ public class ThisJoinPointVisitor extends ASTVisitor {
        boolean needsDynamic = false;
        boolean needsStatic = false;
        boolean needsStaticEnclosing = false;
+       boolean needsThisAspectInstance = false;
        boolean hasEffectivelyStaticRef = false;
        boolean hasConstantReference = false;
        boolean constantReferenceValue = false; // only has valid value when hasConstantReference is true
@@ -47,18 +48,25 @@ public class ThisJoinPointVisitor extends ASTVisitor {
        LocalVariableBinding thisJoinPointDec;
        LocalVariableBinding thisJoinPointStaticPartDec;
        LocalVariableBinding thisEnclosingJoinPointStaticPartDec;
+       LocalVariableBinding thisAspectInstanceDec;
 
        LocalVariableBinding thisJoinPointDecLocal;
        LocalVariableBinding thisJoinPointStaticPartDecLocal;
        LocalVariableBinding thisEnclosingJoinPointStaticPartDecLocal;
+       LocalVariableBinding thisAspectInstanceDecLocal;
 
        boolean replaceEffectivelyStaticRefs = false;
 
+       boolean isIf = true;
+
        AbstractMethodDeclaration method;
 
        ThisJoinPointVisitor(AbstractMethodDeclaration method) {
                this.method = method;
-               int index = method.arguments.length - 3;
+               if (method instanceof AdviceDeclaration) {
+                       isIf = false;
+               }
+               int index = method.arguments.length - 3 - (isIf ? 1 : 0);
 
                thisJoinPointStaticPartDecLocal = method.scope.locals[index];
                thisJoinPointStaticPartDec = method.arguments[index++].binding;
@@ -66,6 +74,10 @@ public class ThisJoinPointVisitor extends ASTVisitor {
                thisJoinPointDec = method.arguments[index++].binding;
                thisEnclosingJoinPointStaticPartDecLocal = method.scope.locals[index];
                thisEnclosingJoinPointStaticPartDec = method.arguments[index++].binding;
+               if (isIf) {
+                       thisAspectInstanceDecLocal = method.scope.locals[index];
+                       thisAspectInstanceDec = method.arguments[index++].binding;
+               }
        }
 
        public void computeJoinPointParams() {
@@ -100,6 +112,8 @@ public class ThisJoinPointVisitor extends ASTVisitor {
                        needsStatic = true;
                } else if (isRef(ref, thisEnclosingJoinPointStaticPartDec)) {
                        needsStaticEnclosing = true;
+               } else if (isIf && isRef(ref, thisAspectInstanceDec)) {
+                       needsThisAspectInstance = true;
                } else if (ref.constant != null && ref.constant != Constant.NotAConstant) {
                        if (ref.constant instanceof BooleanConstant) {
                                hasConstantReference = true;
@@ -196,7 +210,16 @@ public class ThisJoinPointVisitor extends ASTVisitor {
                this.computeJoinPointParams();
                MethodBinding binding = method.binding;
 
-               int index = binding.parameters.length - 3;
+               int index = binding.parameters.length - 3 - (isIf ? 1 : 0);
+
+               if (isIf) {
+                       if (needsThisAspectInstance) {
+                               extraArgumentFlags |= Advice.ThisAspectInstance;
+                       } else {
+                               removeParameter(index + 3);
+                       }
+               }
+
                if (needsStaticEnclosing) {
                        extraArgumentFlags |= Advice.ThisEnclosingJoinPointStaticPart;
                } else {
@@ -218,6 +241,10 @@ public class ThisJoinPointVisitor extends ASTVisitor {
                return extraArgumentFlags;
        }
 
+       public boolean usedThisAspectInstance() {
+               return needsThisAspectInstance;
+       }
+
        private void removeParameter(int indexToRemove) {
                // TypeBinding[] parameters = method.binding.parameters;
                method.scope.locals = removeLocalBinding(indexToRemove, method.scope.locals);
index e5bb25ce5acd71a1a35d5cfe948ed992cb9b96e3..5afa9875cc86d65f48b98b0fc54083ea7ac1a013 100644 (file)
@@ -639,31 +639,31 @@ public class EclipseFactory {
 
        private TypeBinding makeTypeBinding1(UnresolvedType typeX) {
                if (typeX.isPrimitiveType()) {
-                       if (typeX == ResolvedType.BOOLEAN) {
+                       if (typeX.equals(UnresolvedType.BOOLEAN)) {
                                return TypeBinding.BOOLEAN;
                        }
-                       if (typeX == ResolvedType.BYTE) {
+                       if (typeX.equals(UnresolvedType.BYTE)) {
                                return TypeBinding.BYTE;
                        }
-                       if (typeX == ResolvedType.CHAR) {
+                       if (typeX.equals(UnresolvedType.CHAR)) {
                                return TypeBinding.CHAR;
                        }
-                       if (typeX == ResolvedType.DOUBLE) {
+                       if (typeX.equals(UnresolvedType.DOUBLE)) {
                                return TypeBinding.DOUBLE;
                        }
-                       if (typeX == ResolvedType.FLOAT) {
+                       if (typeX.equals(UnresolvedType.FLOAT)) {
                                return TypeBinding.FLOAT;
                        }
-                       if (typeX == ResolvedType.INT) {
+                       if (typeX.equals(UnresolvedType.INT)) {
                                return TypeBinding.INT;
                        }
-                       if (typeX == ResolvedType.LONG) {
+                       if (typeX.equals(UnresolvedType.LONG)) {
                                return TypeBinding.LONG;
                        }
-                       if (typeX == ResolvedType.SHORT) {
+                       if (typeX.equals(UnresolvedType.SHORT)) {
                                return TypeBinding.SHORT;
                        }
-                       if (typeX == ResolvedType.VOID) {
+                       if (typeX.equals(UnresolvedType.VOID)) {
                                return TypeBinding.VOID;
                        }
                        throw new RuntimeException("weird primitive type " + typeX);
index 90a7a8061125576bb5cdf264145d0c64601f75e3..e4de168e036103e1c6ba468b101887f3e7841751 100644 (file)
  *     PARC     initial implementation 
  * ******************************************************************/
 
-
 package org.aspectj.ajdt.internal.compiler.lookup;
 
-
-import org.aspectj.ajdt.internal.compiler.ast.*;
+import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeConstructorDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration;
+import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration;
 import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.weaver.*;
-import org.aspectj.weaver.ast.Var;
-import org.aspectj.org.eclipse.jdt.internal.compiler.ast.*;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Clinit;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.aspectj.weaver.Member;
+import org.aspectj.weaver.MemberImpl;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.Shadow;
+import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.ast.Var;
 
 /**
  * This is only used for declare soft right now.
  * 
- * It might be used for other compile-time matching, but in all such cases
- * this and target pcds can't be used.  We might not behave correctly in
- * such cases.
+ * It might be used for other compile-time matching, but in all such cases this and target pcds can't be used. We might not behave
+ * correctly in such cases.
  */
 public class EclipseShadow extends Shadow {
        EclipseFactory world;
        ASTNode astNode;
        ReferenceContext context;
-       //AbstractMethodDeclaration enclosingMethod;
 
-       public EclipseShadow(EclipseFactory world, Kind kind, Member signature, ASTNode astNode, 
-                                                       ReferenceContext context)
-       {
+       // AbstractMethodDeclaration enclosingMethod;
+
+       public EclipseShadow(EclipseFactory world, Kind kind, Member signature, ASTNode astNode, ReferenceContext context) {
                super(kind, signature, null);
                this.world = world;
                this.astNode = astNode;
@@ -47,28 +60,27 @@ public class EclipseShadow extends Shadow {
                return world.getWorld();
        }
 
-
        public UnresolvedType getEnclosingType() {
                if (context instanceof TypeDeclaration) {
-                       return world.fromBinding(((TypeDeclaration)context).binding);
+                       return world.fromBinding(((TypeDeclaration) context).binding);
                } else if (context instanceof AbstractMethodDeclaration) {
-                       return world.fromBinding(((AbstractMethodDeclaration)context).binding.declaringClass);
+                       return world.fromBinding(((AbstractMethodDeclaration) context).binding.declaringClass);
                } else {
                        return ResolvedType.MISSING;
                }
        }
-       
+
        public ISourceLocation getSourceLocation() {
-               //XXX need to fill this in ASAP
+               // XXX need to fill this in ASAP
                return null;
        }
 
        public Member getEnclosingCodeSignature() {
                if (context instanceof TypeDeclaration) {
-                       return new MemberImpl(Member.STATIC_INITIALIZATION, getEnclosingType(), 0, 
-                                               ResolvedType.VOID, "<clinit>", UnresolvedType.NONE);
+                       return new MemberImpl(Member.STATIC_INITIALIZATION, getEnclosingType(), 0, UnresolvedType.VOID, "<clinit>",
+                                       UnresolvedType.NONE);
                } else if (context instanceof AbstractMethodDeclaration) {
-                       return world.makeResolvedMember(((AbstractMethodDeclaration)context).binding);
+                       return world.makeResolvedMember(((AbstractMethodDeclaration) context).binding);
                } else {
                        return null;
                }
@@ -108,52 +120,52 @@ public class EclipseShadow extends Shadow {
        public Var getKindedAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
-       
+
        public Var getTargetAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
-       
+
        public Var getThisAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
-       
+
+       public Var getThisAspectInstanceVar(ResolvedType aspectType) {
+               throw new RuntimeException("unimplemented");
+       }
+
        public Var getWithinAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
-       
+
        public Var getWithinCodeAnnotationVar(UnresolvedType annotationType) {
                throw new RuntimeException("unimplemented");
        }
 
        // --- factory methods
-       
-       public static EclipseShadow makeShadow(EclipseFactory world, ASTNode astNode, 
-                                                       ReferenceContext context)
-       {
-               //XXX make sure we're getting the correct declaring type at call-site
+
+       public static EclipseShadow makeShadow(EclipseFactory world, ASTNode astNode, ReferenceContext context) {
+               // XXX make sure we're getting the correct declaring type at call-site
                if (astNode instanceof AllocationExpression) {
-                       AllocationExpression e = (AllocationExpression)astNode;
-                       return new EclipseShadow(world, Shadow.ConstructorCall,
-                                       world.makeResolvedMember(e.binding), astNode, context);
+                       AllocationExpression e = (AllocationExpression) astNode;
+                       return new EclipseShadow(world, Shadow.ConstructorCall, 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,
-                                       world.makeResolvedMember(e.binding), astNode, context);
+                       MessageSend e = (MessageSend) astNode;
+                       if (e.isSuperAccess())
+                               return null; // super calls don't have shadows
+                       return new EclipseShadow(world, Shadow.MethodCall, world.makeResolvedMember(e.binding), astNode, context);
                } else if (astNode instanceof ExplicitConstructorCall) {
-                       //??? these should be ignored, they don't have shadows
-                       return null;                            
+                       // ??? these should be ignored, they don't have shadows
+                       return null;
                } else if (astNode instanceof AbstractMethodDeclaration) {
-                       AbstractMethodDeclaration e = (AbstractMethodDeclaration)astNode;
+                       AbstractMethodDeclaration e = (AbstractMethodDeclaration) astNode;
                        Shadow.Kind kind;
                        if (e instanceof AdviceDeclaration) {
                                kind = Shadow.AdviceExecution;
                        } else if (e instanceof InterTypeMethodDeclaration) {
-                               return new EclipseShadow(world, Shadow.MethodExecution,
-                                       ((InterTypeDeclaration)e).getSignature(), astNode, context);
+                               return new EclipseShadow(world, Shadow.MethodExecution, ((InterTypeDeclaration) e).getSignature(), astNode, context);
                        } else if (e instanceof InterTypeConstructorDeclaration) {
-                               return new EclipseShadow(world, Shadow.ConstructorExecution,
-                                       ((InterTypeDeclaration)e).getSignature(), astNode, context);
+                               return new EclipseShadow(world, Shadow.ConstructorExecution, ((InterTypeDeclaration) e).getSignature(), astNode,
+                                               context);
                        } else if (e instanceof InterTypeFieldDeclaration) {
                                return null;
                        } else if (e instanceof MethodDeclaration) {
@@ -161,25 +173,20 @@ public class EclipseShadow extends Shadow {
                        } else if (e instanceof ConstructorDeclaration) {
                                kind = Shadow.ConstructorExecution;
                        } else if (e instanceof Clinit) {
-                               kind = Shadow.StaticInitialization; 
+                               kind = Shadow.StaticInitialization;
                        } else {
                                return null;
-                               //throw new RuntimeException("unimplemented: " + e);
+                               // throw new RuntimeException("unimplemented: " + e);
                        }
-                       return
-                               new EclipseShadow(world, kind,
-                                       world.makeResolvedMember(e.binding,kind), astNode, context);
+                       return new EclipseShadow(world, kind, world.makeResolvedMember(e.binding, kind), astNode, context);
                } else if (astNode instanceof TypeDeclaration) {
                        return new EclipseShadow(world, Shadow.StaticInitialization,
-                                                       new MemberImpl(Member.STATIC_INITIALIZATION, 
-                                                               world.fromBinding(((TypeDeclaration)astNode).binding), 0, 
-                                                               ResolvedType.VOID, "<clinit>", UnresolvedType.NONE),
-                                                       astNode, context);
+                                       new MemberImpl(Member.STATIC_INITIALIZATION, world.fromBinding(((TypeDeclaration) astNode).binding), 0,
+                                                       UnresolvedType.VOID, "<clinit>", UnresolvedType.NONE), astNode, context);
                } else {
                        return null;
-                       //throw new RuntimeException("unimplemented: " + astNode);
-               }               
+                       // throw new RuntimeException("unimplemented: " + astNode);
+               }
        }
 
-       
 }
index bf7aaed0fa1680f4153e7325b828eef95080e4af..9179e286df351430f9ba22ae82947191a520e10f 100644 (file)
@@ -115,7 +115,7 @@ public class PrivilegedHandler implements IPrivilegedHandler {
 
        public void notePrivilegedTypeAccess(ReferenceBinding type, ASTNode location) {
                ResolvedMember key = new ResolvedMemberImpl(Member.STATIC_INITIALIZATION, inAspect.factory.fromEclipse(type), 0,
-                               ResolvedType.VOID, "", UnresolvedType.NONE);
+                               UnresolvedType.VOID, "", UnresolvedType.NONE);
 
                checkWeaveAccess(key.getDeclaringType(), location);
                accessors.put(key, key);