/* ******************************************************************* | /* ******************************************************************* | ||||
* Copyright (c) 2002-2010 Contributors | * Copyright (c) 2002-2010 Contributors | ||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* PARC, Andy Clement (SpringSource) | * PARC, Andy Clement (SpringSource) | ||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.ajdt.internal.compiler.ast; | package org.aspectj.ajdt.internal.compiler.ast; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.LinkedHashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
/** | /** | ||||
* Represents an aspect declaration. | * Represents an aspect declaration. | ||||
* | |||||
* | |||||
* @author PARC | * @author PARC | ||||
* @author Andy Clement | * @author Andy Clement | ||||
*/ | */ | ||||
public ResolvedMember aspectOfMethod; | public ResolvedMember aspectOfMethod; | ||||
public ResolvedMember ptwGetWithinTypeNameMethod; | public ResolvedMember ptwGetWithinTypeNameMethod; | ||||
public ResolvedMember hasAspectMethod; | public ResolvedMember hasAspectMethod; | ||||
public Map<ResolvedMember, Binding> accessForInline = new HashMap<ResolvedMember, Binding>(); | |||||
public Map<ResolvedMember, Binding> accessForInline = new LinkedHashMap<ResolvedMember, Binding>(); | |||||
public Map<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair> superAccessForInline = new HashMap<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair>(); | public Map<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair> superAccessForInline = new HashMap<ResolvedMember, AccessForInlineVisitor.SuperAccessMethodPair>(); | ||||
public boolean isPrivileged; | public boolean isPrivileged; | ||||
public EclipseSourceType concreteName; | public EclipseSourceType concreteName; | ||||
} | } | ||||
if ((binding.tagBits & TagBits.AnnotationResolved) != 0) { | if ((binding.tagBits & TagBits.AnnotationResolved) != 0) { | ||||
// possibly resolution occurred during hasUnsatisfiedDependency()... | // possibly resolution occurred during hasUnsatisfiedDependency()... | ||||
binding.tagBits = (binding.tagBits & ~TagBits.AnnotationResolved); | |||||
binding.tagBits = (binding.tagBits & ~TagBits.AnnotationResolved); | |||||
} | } | ||||
Annotation atAspectAnnotation = AtAspectJAnnotationFactory.createAspectAnnotation(perClause.toDeclarationString(), | Annotation atAspectAnnotation = AtAspectJAnnotationFactory.createAspectAnnotation(perClause.toDeclarationString(), | ||||
declarationSourceStart); | declarationSourceStart); |
/* ******************************************************************* | /* ******************************************************************* | ||||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | ||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* PARC initial implementation | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* PARC initial implementation | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver; | package org.aspectj.weaver; | ||||
/** | /** | ||||
* The five kinds of advice in AspectJ. | * The five kinds of advice in AspectJ. | ||||
* | |||||
* | |||||
* @author Erik Hilsdale | * @author Erik Hilsdale | ||||
* @author Jim Hugunin | * @author Jim Hugunin | ||||
*/ | */ | ||||
return this == PerThisEntry || this == PerTargetEntry; | return this == PerThisEntry || this == PerTargetEntry; | ||||
} | } | ||||
@Override | |||||
public int hashCode() { | |||||
return ((super.hashCode()*37 + precedence)*37+(isAfter?0:1))*37 + (isCflow?0:1); | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (!(o instanceof AdviceKind)) { | |||||
return false; | |||||
} | |||||
AdviceKind ak = (AdviceKind)o; | |||||
return super.equals(ak) && | |||||
ak.precedence == precedence && | |||||
ak.isAfter == isAfter && | |||||
ak.isCflow == isCflow; | |||||
} | |||||
} | } |
/* ******************************************************************* | /* ******************************************************************* | ||||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | ||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* PARC initial implementation | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* PARC initial implementation | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver; | package org.aspectj.weaver; | ||||
protected final Shadow enclosingShadow; | protected final Shadow enclosingShadow; | ||||
protected List<ShadowMunger> mungers = Collections.emptyList(); | protected List<ShadowMunger> mungers = Collections.emptyList(); | ||||
protected boolean needAroundClosureStacking = false; | protected boolean needAroundClosureStacking = false; | ||||
public int shadowId = nextShadowID++; // every time we build a shadow, it gets a new id | public int shadowId = nextShadowID++; // every time we build a shadow, it gets a new id | ||||
// ---- | // ---- | ||||
/** | /** | ||||
* the type of the this object here | * the type of the this object here | ||||
* | |||||
* | |||||
* @throws IllegalStateException if there is no this here | * @throws IllegalStateException if there is no this here | ||||
*/ | */ | ||||
public final UnresolvedType getThisType() { | public final UnresolvedType getThisType() { | ||||
/** | /** | ||||
* a var referencing this | * a var referencing this | ||||
* | |||||
* | |||||
* @throws IllegalStateException if there is no target here | * @throws IllegalStateException if there is no target here | ||||
*/ | */ | ||||
public abstract Var getThisVar(); | public abstract Var getThisVar(); | ||||
/** | /** | ||||
* the type of the target object here | * the type of the target object here | ||||
* | |||||
* | |||||
* @throws IllegalStateException if there is no target here | * @throws IllegalStateException if there is no target here | ||||
*/ | */ | ||||
public final UnresolvedType getTargetType() { | public final UnresolvedType getTargetType() { | ||||
/** | /** | ||||
* a var referencing the target | * a var referencing the target | ||||
* | |||||
* | |||||
* @throws IllegalStateException if there is no target here | * @throws IllegalStateException if there is no target here | ||||
*/ | */ | ||||
public abstract Var getTargetVar(); | public abstract Var getTargetVar(); | ||||
/** | /** | ||||
* returns the resolved signature of the thing under this shadow | * returns the resolved signature of the thing under this shadow | ||||
* | |||||
* | |||||
*/ | */ | ||||
public ResolvedMember getResolvedSignature() { | public ResolvedMember getResolvedSignature() { | ||||
if (resolvedSignature == null) { | if (resolvedSignature == null) { | ||||
/** | /** | ||||
* These shadow kinds have return values that can be bound in after returning(Dooberry doo) advice. | * These shadow kinds have return values that can be bound in after returning(Dooberry doo) advice. | ||||
* | |||||
* | |||||
* @return | * @return | ||||
*/ | */ | ||||
public boolean hasReturnValue() { | public boolean hasReturnValue() { | ||||
/** | /** | ||||
* Only does the check if the munger requires it (@AJ aspects don't) | * Only does the check if the munger requires it (@AJ aspects don't) | ||||
* | |||||
* | |||||
* @param munger | * @param munger | ||||
* @return | * @return | ||||
*/ | */ | ||||
/** Actually implement the (non-empty) mungers associated with this shadow */ | /** Actually implement the (non-empty) mungers associated with this shadow */ | ||||
private void implementMungers() { | private void implementMungers() { | ||||
World world = getIWorld(); | |||||
World world = getIWorld(); | |||||
needAroundClosureStacking = false; | needAroundClosureStacking = false; | ||||
int annotationStyleWithAroundAndProceedCount = 0; | int annotationStyleWithAroundAndProceedCount = 0; | ||||
for (ShadowMunger munger: mungers) { | for (ShadowMunger munger: mungers) { | ||||
if (munger.getDeclaringType()!= null && | |||||
if (munger.getDeclaringType()!= null && | |||||
munger.getDeclaringType().isAnnotationStyleAspect() && | munger.getDeclaringType().isAnnotationStyleAspect() && | ||||
munger.isAroundAdvice() && | munger.isAroundAdvice() && | ||||
munger.bindsProceedingJoinPoint()) { | munger.bindsProceedingJoinPoint()) { |
/* ******************************************************************* | /* ******************************************************************* | ||||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | ||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* Xerox/PARC initial implementation | |||||
* All rights reserved. | |||||
* This program and the accompanying materials are made available | |||||
* under the terms of the Eclipse Public License v1.0 | |||||
* which accompanies this distribution and is available at | |||||
* http://www.eclipse.org/legal/epl-v10.html | |||||
* | |||||
* Contributors: | |||||
* Xerox/PARC initial implementation | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.util; | package org.aspectj.util; | ||||
import java.io.*; | |||||
import java.io.DataOutputStream; | |||||
import java.io.IOException; | |||||
public class TypeSafeEnum { | public class TypeSafeEnum { | ||||
private byte key; | private byte key; | ||||
public void write(DataOutputStream s) throws IOException { | public void write(DataOutputStream s) throws IOException { | ||||
s.writeByte(key); | s.writeByte(key); | ||||
} | } | ||||
@Override | |||||
public int hashCode() { | |||||
return name.hashCode()*37+key; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
return (o instanceof TypeSafeEnum) && | |||||
((TypeSafeEnum)o).key == key && | |||||
((TypeSafeEnum)o).name.equals(name); | |||||
} | |||||
} | } |