private static boolean LOADED_BUNDLE = false; | private static boolean LOADED_BUNDLE = false; | ||||
static { | static { | ||||
Main.bundleName = BUNDLE_NAME; | |||||
// Main.bundleName = BUNDLE_NAME; | |||||
ResourceBundleFactory.getBundle(Locale.getDefault()); | ResourceBundleFactory.getBundle(Locale.getDefault()); | ||||
if (!LOADED_BUNDLE) { | if (!LOADED_BUNDLE) { | ||||
LOADED_BUNDLE = true; | LOADED_BUNDLE = true; | ||||
setDebugOptions(); | setDebugOptions(); | ||||
buildConfig.getOptions().set(options); | buildConfig.getOptions().set(options); | ||||
} catch (InvalidInputException iie) { | |||||
} catch (IllegalArgumentException iae) { | |||||
ISourceLocation location = null; | ISourceLocation location = null; | ||||
if (buildConfig.getConfigFile() != null) { | if (buildConfig.getConfigFile() != null) { | ||||
location = new SourceLocation(buildConfig.getConfigFile(), 0); | location = new SourceLocation(buildConfig.getConfigFile(), 0); | ||||
} | } | ||||
IMessage m = new Message(iie.getMessage(), IMessage.ERROR, null, location); | |||||
IMessage m = new Message(iae.getMessage(), IMessage.ERROR, null, location); | |||||
handler.handleMessage(m); | handler.handleMessage(m); | ||||
} | } | ||||
return buildConfig; | return buildConfig; |
} | } | ||||
public void endVisit(FieldReference ref, BlockScope scope) { | public void endVisit(FieldReference ref, BlockScope scope) { | ||||
ref.binding = getAccessibleField(ref.binding, ref.receiverType); | |||||
ref.binding = getAccessibleField(ref.binding, ref.actualReceiverType); | |||||
} | } | ||||
public void endVisit(MessageSend send, BlockScope scope) { | public void endVisit(MessageSend send, BlockScope scope) { |
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; | 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.ast.TypeReference; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; | ||||
l.add(new EclipseAttributeAdapter(makeAttribute())); | l.add(new EclipseAttributeAdapter(makeAttribute())); | ||||
addDeclarationStartLineAttribute(l, classFile); | addDeclarationStartLineAttribute(l, classFile); | ||||
return classFile.generateMethodInfoAttribute(binding, false, l); | |||||
return classFile.generateMethodInfoAttributes(binding, l); | |||||
} | } | ||||
private AjAttribute makeAttribute() { | private AjAttribute makeAttribute() { | ||||
TypeBinding argTb = extraArgument.binding.type; | TypeBinding argTb = extraArgument.binding.type; | ||||
TypeBinding expectedTb = upperScope.getJavaLangThrowable(); | TypeBinding expectedTb = upperScope.getJavaLangThrowable(); | ||||
if (!argTb.isCompatibleWith(expectedTb)) { | if (!argTb.isCompatibleWith(expectedTb)) { | ||||
scope.problemReporter().typeMismatchError(argTb, expectedTb, extraArgument); | |||||
scope.problemReporter().typeMismatchError(argTb, expectedTb, extraArgument,null); | |||||
ignoreFurtherInvestigation = true; | ignoreFurtherInvestigation = true; | ||||
return; | return; | ||||
} | } | ||||
classFile.generateMethodInfoHeader(binding); | classFile.generateMethodInfoHeader(binding); | ||||
int methodAttributeOffset = classFile.contentsOffset; | int methodAttributeOffset = classFile.contentsOffset; | ||||
int attributeNumber = classFile.generateMethodInfoAttribute(binding, false, AstUtil.getAjSyntheticAttribute()); | |||||
int attributeNumber = classFile.generateMethodInfoAttributes(binding, AstUtil.getAjSyntheticAttribute()); | |||||
int codeAttributeOffset = classFile.contentsOffset; | int codeAttributeOffset = classFile.contentsOffset; | ||||
classFile.generateCodeAttributeHeader(); | classFile.generateCodeAttributeHeader(); | ||||
CodeStream codeStream = classFile.codeStream; | CodeStream codeStream = classFile.codeStream; | ||||
codeStream.load(type, index); | codeStream.load(type, index); | ||||
index += AstUtil.slotsNeeded(type); | index += AstUtil.slotsNeeded(type); | ||||
if (type.isBaseType()) { | if (type.isBaseType()) { | ||||
codeStream.invokestatic(AjTypeConstants.getConversionMethodToObject(classScope, type)); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic, AjTypeConstants.getConversionMethodToObject(classScope, type), null); | |||||
} | } | ||||
codeStream.aastore(); | codeStream.aastore(); | ||||
// call run | // call run | ||||
ReferenceBinding closureType = (ReferenceBinding) binding.parameters[nargs - 1]; | ReferenceBinding closureType = (ReferenceBinding) binding.parameters[nargs - 1]; | ||||
MethodBinding runMethod = closureType.getMethods("run".toCharArray())[0]; | MethodBinding runMethod = closureType.getMethods("run".toCharArray())[0]; | ||||
codeStream.invokevirtual(runMethod); | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual, runMethod, null); | |||||
TypeBinding returnType = binding.returnType; | TypeBinding returnType = binding.returnType; | ||||
if (returnType.isBaseType()) { | if (returnType.isBaseType()) { | ||||
codeStream.invokestatic(AjTypeConstants.getConversionMethodFromObject(classScope, returnType)); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic, AjTypeConstants.getConversionMethodFromObject(classScope, returnType), null); | |||||
} else { | } else { | ||||
codeStream.checkcast(returnType); | codeStream.checkcast(returnType); | ||||
} | } | ||||
codeStream.recordPositionsFrom(0, 1); | codeStream.recordPositionsFrom(0, 1); | ||||
classFile.completeCodeAttribute(codeAttributeOffset); | classFile.completeCodeAttribute(codeAttributeOffset); | ||||
attributeNumber++; | attributeNumber++; | ||||
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); | |||||
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); | |||||
} | } | ||||
// override | // override |
// add extra attributes into list then call 2-arg version of generateInfoAttributes... | // add extra attributes into list then call 2-arg version of generateInfoAttributes... | ||||
List extras = new ArrayList(); | List extras = new ArrayList(); | ||||
addDeclarationStartLineAttribute(extras,classFile); | addDeclarationStartLineAttribute(extras,classFile); | ||||
return classFile.generateMethodInfoAttribute(binding,false,extras); | |||||
return classFile.generateMethodInfoAttributes(binding,extras); | |||||
} | } | ||||
protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) { | protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) { |
if (addAjSynthetic) { | if (addAjSynthetic) { | ||||
extras.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); | extras.add(new EclipseAttributeAdapter(new AjAttribute.AjSynthetic())); | ||||
} | } | ||||
return classFile.generateMethodInfoAttribute(binding,false,extras); | |||||
return classFile.generateMethodInfoAttributes(binding,extras); | |||||
} | } | ||||
protected int generateInfoAttributes(ClassFile classFile) { | protected int generateInfoAttributes(ClassFile classFile) { |
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.BranchLabel; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.BranchLabel; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; | ||||
if (hasPre) { | if (hasPre) { | ||||
final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); | final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); | ||||
codeStream.invokestatic(world.makeMethodBindingForCall( | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,world.makeMethodBindingForCall( | |||||
AjcMemberMaker.ajcPreClinitMethod( | AjcMemberMaker.ajcPreClinitMethod( | ||||
world.fromBinding(classScope.referenceContext.binding) | world.fromBinding(classScope.referenceContext.binding) | ||||
))); | |||||
)),null); | |||||
} | } | ||||
super.generateSyntheticCode(classScope, codeStream); | super.generateSyntheticCode(classScope, codeStream); | ||||
} | } | ||||
super.generatePostSyntheticCode(classScope, codeStream); | super.generatePostSyntheticCode(classScope, codeStream); | ||||
if (hasPost) { | if (hasPost) { | ||||
final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); | final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); | ||||
codeStream.invokestatic(world.makeMethodBindingForCall( | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,world.makeMethodBindingForCall( | |||||
AjcMemberMaker.ajcPostClinitMethod( | AjcMemberMaker.ajcPostClinitMethod( | ||||
world.fromBinding(classScope.referenceContext.binding) | world.fromBinding(classScope.referenceContext.binding) | ||||
))); | |||||
)),null); | |||||
} | } | ||||
if (initFailureField != null) { | if (initFailureField != null) { | ||||
// CHECK THIS... | // CHECK THIS... | ||||
codeStream.addVariable(new LocalVariableBinding("caughtException".toCharArray(),initFailureField.type,ClassFileConstants.AccPrivate,false)); | codeStream.addVariable(new LocalVariableBinding("caughtException".toCharArray(),initFailureField.type,ClassFileConstants.AccPrivate,false)); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.putstatic(initFailureField); | |||||
codeStream.fieldAccess(Opcodes.OPC_putstatic, initFailureField, null); | |||||
endLabel.place(); | endLabel.place(); | ||||
} | } | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.BranchLabel; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.BranchLabel; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | ||||
import org.aspectj.weaver.patterns.PerSingleton; | import org.aspectj.weaver.patterns.PerSingleton; | ||||
import org.aspectj.weaver.patterns.TypePattern; | import org.aspectj.weaver.patterns.TypePattern; | ||||
import com.sun.org.apache.xpath.internal.compiler.OpCodes; | |||||
/** | /** | ||||
* Represents an aspect declaration. | * Represents an aspect declaration. | ||||
* | * | ||||
List attrs = new ArrayList(); | List attrs = new ArrayList(); | ||||
attrs.addAll(AstUtil.getAjSyntheticAttribute()); | attrs.addAll(AstUtil.getAjSyntheticAttribute()); | ||||
attrs.addAll(additionalAttributes); | attrs.addAll(additionalAttributes); | ||||
attributeNumber = classFile.generateMethodInfoAttribute(methodBinding, false, attrs); | |||||
attributeNumber = classFile.generateMethodInfoAttributes(methodBinding, attrs); | |||||
} else { | } else { | ||||
attributeNumber = classFile.generateMethodInfoAttribute(methodBinding, false, AstUtil.getAjSyntheticAttribute()); | |||||
attributeNumber = classFile.generateMethodInfoAttributes(methodBinding, AstUtil.getAjSyntheticAttribute()); | |||||
} | } | ||||
int codeAttributeOffset = classFile.contentsOffset; | int codeAttributeOffset = classFile.contentsOffset; | ||||
} | } | ||||
attributeNumber++; | attributeNumber++; | ||||
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); | |||||
classFile.completeMethodInfo(methodBinding,methodAttributeOffset, attributeNumber); | |||||
} | } | ||||
private void generatePerCflowAspectOfMethod(ClassFile classFile) { | private void generatePerCflowAspectOfMethod(ClassFile classFile) { | ||||
generateMethod(classFile, aspectOfMethod, new BodyGenerator() { | generateMethod(classFile, aspectOfMethod, new BodyGenerator() { | ||||
public void generate(CodeStream codeStream) { | public void generate(CodeStream codeStream) { | ||||
// body starts here | // body starts here | ||||
codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX))); | |||||
codeStream.invokevirtual(world.makeMethodBindingForCall(AjcMemberMaker.cflowStackPeekInstance())); | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX)),null); | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual,world.makeMethodBindingForCall(AjcMemberMaker.cflowStackPeekInstance()),null); | |||||
codeStream.checkcast(binding); | codeStream.checkcast(binding); | ||||
codeStream.areturn(); | codeStream.areturn(); | ||||
// body ends here | // body ends here | ||||
generateMethod(classFile, hasAspectMethod, new BodyGenerator() { | generateMethod(classFile, hasAspectMethod, new BodyGenerator() { | ||||
public void generate(CodeStream codeStream) { | public void generate(CodeStream codeStream) { | ||||
// body starts here | // body starts here | ||||
codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX))); | |||||
codeStream.invokevirtual(world.makeMethodBindingForCall(AjcMemberMaker.cflowStackIsValid())); | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX)),null); | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual,world.makeMethodBindingForCall(AjcMemberMaker.cflowStackIsValid()),null); | |||||
codeStream.ireturn(); | codeStream.ireturn(); | ||||
// body ends here | // body ends here | ||||
} | } | ||||
new BodyGenerator() { | new BodyGenerator() { | ||||
public void generate(CodeStream codeStream) { | public void generate(CodeStream codeStream) { | ||||
// body starts here | // body starts here | ||||
codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX))); | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX)),null); | |||||
codeStream.new_(binding); | codeStream.new_(binding); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.invokespecial(new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding)); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding),null); | |||||
codeStream.invokevirtual(world.makeMethodBindingForCall(AjcMemberMaker.cflowStackPushInstance())); | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual, world.makeMethodBindingForCall(AjcMemberMaker.cflowStackPushInstance()), null); | |||||
codeStream.return_(); | codeStream.return_(); | ||||
// body ends here | // body ends here | ||||
} | } | ||||
// body starts here | // body starts here | ||||
codeStream.new_(world.makeTypeBinding(AjcMemberMaker.CFLOW_STACK_TYPE)); | codeStream.new_(world.makeTypeBinding(AjcMemberMaker.CFLOW_STACK_TYPE)); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.cflowStackInit())); | |||||
codeStream.putstatic(world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,world.makeMethodBindingForCall(AjcMemberMaker.cflowStackInit()),null); | |||||
codeStream.fieldAccess(Opcodes.OPC_putstatic,world.makeFieldBinding(AjcMemberMaker.perCflowField(typeX)),null); | |||||
codeStream.return_(); | codeStream.return_(); | ||||
// body ends here | // body ends here | ||||
} | } | ||||
.makeTypeBinding(UnresolvedType.JL_EXCEPTION)); | .makeTypeBinding(UnresolvedType.JL_EXCEPTION)); | ||||
anythingGoesWrong.placeStart(); | anythingGoesWrong.placeStart(); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.invokestatic(world.makeMethodBindingForCall(AjcMemberMaker.perTypeWithinGetInstance(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,world.makeMethodBindingForCall(AjcMemberMaker.perTypeWithinGetInstance(typeX)),null); | |||||
codeStream.astore_1(); | codeStream.astore_1(); | ||||
codeStream.aload_1(); | codeStream.aload_1(); | ||||
codeStream.ifnonnull(instanceFound); | codeStream.ifnonnull(instanceFound); | ||||
codeStream.ldc(typeX.getName()); | codeStream.ldc(typeX.getName()); | ||||
codeStream.aconst_null(); | codeStream.aconst_null(); | ||||
codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit2())); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit2()),null); | |||||
codeStream.athrow(); | codeStream.athrow(); | ||||
instanceFound.place(); | instanceFound.place(); | ||||
codeStream.aload_1(); | codeStream.aload_1(); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
// Run the simple ctor for NABE | // Run the simple ctor for NABE | ||||
codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit())); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit()),null); | |||||
codeStream.athrow(); | codeStream.athrow(); | ||||
} | } | ||||
}); | }); | ||||
codeStream.ifeq(wrongType); | codeStream.ifeq(wrongType); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.checkcast(interfaceType); | codeStream.checkcast(interfaceType); | ||||
codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface,world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX)),null); | |||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.ifnull(popWrongType); | codeStream.ifnull(popWrongType); | ||||
wrongType.place(); | wrongType.place(); | ||||
codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); | codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit())); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit()),null); | |||||
codeStream.athrow(); | codeStream.athrow(); | ||||
// body ends here | // body ends here | ||||
} | } | ||||
codeStream.ifeq(wrongType); | codeStream.ifeq(wrongType); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.checkcast(interfaceType); | codeStream.checkcast(interfaceType); | ||||
codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface,world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX)),null); | |||||
codeStream.ifnull(wrongType); | codeStream.ifnull(wrongType); | ||||
codeStream.iconst_1(); | codeStream.iconst_1(); | ||||
codeStream.ireturn(); | codeStream.ireturn(); | ||||
BranchLabel leave = new BranchLabel(codeStream); | BranchLabel leave = new BranchLabel(codeStream); | ||||
goneBang.placeStart(); | goneBang.placeStart(); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.invokestatic(world.makeMethodBinding(AjcMemberMaker.perTypeWithinGetInstance(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,world.makeMethodBinding(AjcMemberMaker.perTypeWithinGetInstance(typeX)),null); | |||||
codeStream.ifnull(noInstanceExists); | codeStream.ifnull(noInstanceExists); | ||||
codeStream.iconst_1(); | codeStream.iconst_1(); | ||||
codeStream.goto_(leave); | codeStream.goto_(leave); | ||||
codeStream.ifeq(wrongType); // XXX this case might call for screaming | codeStream.ifeq(wrongType); // XXX this case might call for screaming | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.checkcast(interfaceType); | codeStream.checkcast(interfaceType); | ||||
codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface,world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX)),null); | |||||
// XXX should do a check for null here and throw a NoAspectBound | // XXX should do a check for null here and throw a NoAspectBound | ||||
codeStream.ifnonnull(wrongType); | codeStream.ifnonnull(wrongType); | ||||
codeStream.checkcast(interfaceType); | codeStream.checkcast(interfaceType); | ||||
codeStream.new_(binding); | codeStream.new_(binding); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.invokespecial(new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding)); | |||||
codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceSet(typeX))); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding),null); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface,world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceSet(typeX)),null); | |||||
wrongType.place(); | wrongType.place(); | ||||
codeStream.return_(); | codeStream.return_(); | ||||
ExceptionLabel exc = new ExceptionLabel(codeStream, world.makeTypeBinding(UnresolvedType.JL_EXCEPTION)); | ExceptionLabel exc = new ExceptionLabel(codeStream, world.makeTypeBinding(UnresolvedType.JL_EXCEPTION)); | ||||
exc.placeStart(); | exc.placeStart(); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.getfield(world.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX, typeX))); | |||||
codeStream.fieldAccess(Opcodes.OPC_getfield,world.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX, typeX)),null); | |||||
codeStream.areturn(); | codeStream.areturn(); | ||||
} | } | ||||
}); | }); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.ldc(NameMangler.perTypeWithinLocalAspectOf(typeX)); | codeStream.ldc(NameMangler.perTypeWithinLocalAspectOf(typeX)); | ||||
codeStream.aconst_null(); | codeStream.aconst_null(); | ||||
codeStream.invokevirtual(new MethodBinding(0, "getDeclaredMethod".toCharArray(), | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual,new MethodBinding(0, "getDeclaredMethod".toCharArray(), | |||||
world.makeTypeBinding(UnresolvedType.forSignature("Ljava/lang/reflect/Method;")), // return type | world.makeTypeBinding(UnresolvedType.forSignature("Ljava/lang/reflect/Method;")), // return type | ||||
new TypeBinding[] { world.makeTypeBinding(UnresolvedType.forSignature("Ljava/lang/String;")), | new TypeBinding[] { world.makeTypeBinding(UnresolvedType.forSignature("Ljava/lang/String;")), | ||||
world.makeTypeBinding(UnresolvedType.forSignature("[Ljava/lang/Class;")) }, | world.makeTypeBinding(UnresolvedType.forSignature("[Ljava/lang/Class;")) }, | ||||
new ReferenceBinding[0], (ReferenceBinding) world.makeTypeBinding(UnresolvedType.JL_CLASS))); | |||||
new ReferenceBinding[0], (ReferenceBinding) world.makeTypeBinding(UnresolvedType.JL_CLASS)),null); | |||||
codeStream.astore_1(); | codeStream.astore_1(); | ||||
codeStream.aload_1(); | codeStream.aload_1(); | ||||
codeStream.aconst_null(); | codeStream.aconst_null(); | ||||
codeStream.aconst_null(); | codeStream.aconst_null(); | ||||
codeStream.invokevirtual(new MethodBinding(0, "invoke".toCharArray(), world.makeTypeBinding(UnresolvedType.OBJECT), | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual,new MethodBinding(0, "invoke".toCharArray(), world.makeTypeBinding(UnresolvedType.OBJECT), | |||||
new TypeBinding[] { world.makeTypeBinding(UnresolvedType.OBJECT), | new TypeBinding[] { world.makeTypeBinding(UnresolvedType.OBJECT), | ||||
world.makeTypeBinding(UnresolvedType.forSignature("[Ljava/lang/Object;")) }, | world.makeTypeBinding(UnresolvedType.forSignature("[Ljava/lang/Object;")) }, | ||||
new ReferenceBinding[0], (ReferenceBinding) world.makeTypeBinding(UnresolvedType.JAVA_LANG_REFLECT_METHOD))); | |||||
new ReferenceBinding[0], (ReferenceBinding) world.makeTypeBinding(UnresolvedType.JAVA_LANG_REFLECT_METHOD)),null); | |||||
codeStream.checkcast(world.makeTypeBinding(typeX)); | codeStream.checkcast(world.makeTypeBinding(typeX)); | ||||
codeStream.astore_2(); | codeStream.astore_2(); | ||||
codeStream.aload_2(); | codeStream.aload_2(); | ||||
codeStream.new_(world.makeTypeBinding(typeX)); | codeStream.new_(world.makeTypeBinding(typeX)); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.invokespecial(new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding)); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding),null); | |||||
codeStream.astore_1(); | codeStream.astore_1(); | ||||
codeStream.aload_1(); | codeStream.aload_1(); | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.putfield(world.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX, typeX))); | |||||
codeStream.fieldAccess(Opcodes.OPC_putfield,world.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX, typeX)),null); | |||||
codeStream.aload_1(); | codeStream.aload_1(); | ||||
codeStream.areturn(); | codeStream.areturn(); | ||||
} | } | ||||
*/ | */ | ||||
// body starts here (see end of each line for what it is doing!) | // body starts here (see end of each line for what it is doing!) | ||||
FieldBinding fb = world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX)); | FieldBinding fb = world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX)); | ||||
codeStream.getstatic(fb); // GETSTATIC | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic, fb, null); | |||||
BranchLabel isNonNull = new BranchLabel(codeStream); | BranchLabel isNonNull = new BranchLabel(codeStream); | ||||
codeStream.ifnonnull(isNonNull); // IFNONNULL | codeStream.ifnonnull(isNonNull); // IFNONNULL | ||||
codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); // NEW | codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); // NEW | ||||
codeStream.dup(); // DUP | codeStream.dup(); // DUP | ||||
codeStream.ldc(typeX.getNameAsIdentifier()); // LDC | codeStream.ldc(typeX.getNameAsIdentifier()); // LDC | ||||
codeStream.getstatic(initFailureField); // GETSTATIC | |||||
codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInitWithCause())); // INVOKESPECIAL | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,initFailureField,null); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInitWithCause()),null); // INVOKESPECIAL | |||||
codeStream.athrow(); // ATHROW | codeStream.athrow(); // ATHROW | ||||
isNonNull.place(); | isNonNull.place(); | ||||
codeStream.getstatic(fb); // GETSTATIC | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,fb,null); | |||||
codeStream.areturn(); // ARETURN | codeStream.areturn(); // ARETURN | ||||
// body ends here | // body ends here | ||||
} | } | ||||
generateMethod(classFile, hasAspectMethod, new BodyGenerator() { | generateMethod(classFile, hasAspectMethod, new BodyGenerator() { | ||||
public void generate(CodeStream codeStream) { | public void generate(CodeStream codeStream) { | ||||
// body starts here | // body starts here | ||||
codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX))); | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX)),null); | |||||
BranchLabel isNull = new BranchLabel(codeStream); | BranchLabel isNull = new BranchLabel(codeStream); | ||||
codeStream.ifnull(isNull); | codeStream.ifnull(isNull); | ||||
codeStream.iconst_1(); | codeStream.iconst_1(); | ||||
// body starts here | // body starts here | ||||
codeStream.new_(binding); | codeStream.new_(binding); | ||||
codeStream.dup(); | codeStream.dup(); | ||||
codeStream.invokespecial(new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding)); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0], | |||||
new ReferenceBinding[0], binding),null); | |||||
codeStream.putstatic(world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX))); | |||||
codeStream.fieldAccess(Opcodes.OPC_putstatic, world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX)), null); | |||||
codeStream.return_(); | codeStream.return_(); | ||||
// body ends here | // body ends here | ||||
} | } | ||||
// body starts here | // body starts here | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
AstUtil.generateParameterLoads(accessMethod.parameters, codeStream, 1); | AstUtil.generateParameterLoads(accessMethod.parameters, codeStream, 1); | ||||
codeStream.invokespecial(factory.makeMethodBinding(method)); | |||||
codeStream.invoke(Opcodes.OPC_invokespecial,factory.makeMethodBinding(method),null); | |||||
AstUtil.generateReturn(accessMethod.returnType, codeStream); | AstUtil.generateReturn(accessMethod.returnType, codeStream); | ||||
// body ends here | // body ends here | ||||
} | } | ||||
public void generate(CodeStream codeStream) { | public void generate(CodeStream codeStream) { | ||||
// body starts here | // body starts here | ||||
if (Modifier.isStatic(field.getModifiers())) { | if (Modifier.isStatic(field.getModifiers())) { | ||||
codeStream.getstatic(fieldBinding); | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,fieldBinding,null); | |||||
} else { | } else { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.getfield(fieldBinding); | |||||
codeStream.fieldAccess(Opcodes.OPC_getfield,fieldBinding,null); | |||||
} | } | ||||
AstUtil.generateReturn(accessField.reader.returnType, codeStream); | AstUtil.generateReturn(accessField.reader.returnType, codeStream); | ||||
// body starts here | // body starts here | ||||
if (Modifier.isStatic(field.getModifiers())) { | if (Modifier.isStatic(field.getModifiers())) { | ||||
codeStream.load(fieldBinding.type, 0); | codeStream.load(fieldBinding.type, 0); | ||||
codeStream.putstatic(fieldBinding); | |||||
codeStream.fieldAccess(Opcodes.OPC_putstatic,fieldBinding,null); | |||||
} else { | } else { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.load(fieldBinding.type, 1); | codeStream.load(fieldBinding.type, 1); | ||||
codeStream.putfield(fieldBinding); | |||||
codeStream.fieldAccess(Opcodes.OPC_putfield,fieldBinding,null); | |||||
} | } | ||||
codeStream.return_(); | codeStream.return_(); | ||||
AstUtil.generateParameterLoads(accessMethod.parameters, codeStream); | AstUtil.generateParameterLoads(accessMethod.parameters, codeStream); | ||||
if (Modifier.isStatic(method.getModifiers())) { | if (Modifier.isStatic(method.getModifiers())) { | ||||
codeStream.invokestatic(factory.makeMethodBinding(method)); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,factory.makeMethodBinding(method),null); | |||||
} else { | } else { | ||||
codeStream.invokevirtual(factory.makeMethodBinding(method)); | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual,factory.makeMethodBinding(method),null); | |||||
} | } | ||||
AstUtil.generateReturn(accessMethod.returnType, codeStream); | AstUtil.generateReturn(accessMethod.returnType, codeStream); | ||||
} | } | ||||
// may be unresolved if the aspect type binding was a BinaryTypeBinding | // may be unresolved if the aspect type binding was a BinaryTypeBinding | ||||
if (innerTypeBinding instanceof UnresolvedReferenceBinding) { | if (innerTypeBinding instanceof UnresolvedReferenceBinding) { | ||||
innerTypeBinding = BinaryTypeBinding.resolveType(innerTypeBinding, world.getLookupEnvironment(), true); | |||||
innerTypeBinding = (ReferenceBinding)BinaryTypeBinding.resolveType(innerTypeBinding, world.getLookupEnvironment(), true); | |||||
} | } | ||||
if (innerTypeBinding == null) { | if (innerTypeBinding == null) { | ||||
throw new IllegalStateException("Could not find inner type binding for '" + munger.getMemberTypeName() + "'"); | throw new IllegalStateException("Could not find inner type binding for '" + munger.getMemberTypeName() + "'"); |
public static SingleNameReference makeLocalVariableReference(LocalVariableBinding binding) { | public static SingleNameReference makeLocalVariableReference(LocalVariableBinding binding) { | ||||
SingleNameReference ret = new SingleNameReference(binding.name, 0); | SingleNameReference ret = new SingleNameReference(binding.name, 0); | ||||
ret.binding = binding; | ret.binding = binding; | ||||
ret.codegenBinding = binding; | |||||
// ret.codegenBinding = binding; | |||||
ret.constant = Constant.NotAConstant; | ret.constant = Constant.NotAConstant; | ||||
ret.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits | ret.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits | ||||
ret.bits |= Binding.VARIABLE; | ret.bits |= Binding.VARIABLE; | ||||
public static SingleNameReference makeResolvedLocalVariableReference(LocalVariableBinding binding) { | public static SingleNameReference makeResolvedLocalVariableReference(LocalVariableBinding binding) { | ||||
SingleNameReference ret = new SingleNameReference(binding.name, 0); | SingleNameReference ret = new SingleNameReference(binding.name, 0); | ||||
ret.binding = binding; | ret.binding = binding; | ||||
ret.codegenBinding = binding; | |||||
// ret.codegenBinding = binding; | |||||
ret.constant = Constant.NotAConstant; | ret.constant = Constant.NotAConstant; | ||||
ret.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits | ret.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits | ||||
ret.bits |= Binding.LOCAL; | ret.bits |= Binding.LOCAL; | ||||
} | } | ||||
public static void replaceMethodBinding(MessageSend send, MethodBinding newBinding) { | public static void replaceMethodBinding(MessageSend send, MethodBinding newBinding) { | ||||
send.binding = send.codegenBinding = newBinding; | |||||
send.binding =/* send.codegenBinding =*/ newBinding; | |||||
send.setActualReceiverType(newBinding.declaringClass); | send.setActualReceiverType(newBinding.declaringClass); | ||||
} | } |
NormalAnnotation ann = new NormalAnnotation(annType,pos); | NormalAnnotation ann = new NormalAnnotation(annType,pos); | ||||
Expression targetExpr = new StringLiteral(targetTypeName,pos,pos,1); | Expression targetExpr = new StringLiteral(targetTypeName,pos,pos,1); | ||||
Expression nameExpr = new StringLiteral(name,pos,pos,1); | Expression nameExpr = new StringLiteral(name,pos,pos,1); | ||||
Expression modsExpr = new IntLiteral(Integer.toString(modifiers).toCharArray(),pos,pos); | |||||
Expression modsExpr = IntLiteral.buildIntLiteral(Integer.toString(modifiers).toCharArray(),pos,pos); | |||||
MemberValuePair[] mvps = new MemberValuePair[3]; | MemberValuePair[] mvps = new MemberValuePair[3]; | ||||
mvps[0] = new MemberValuePair("targetType".toCharArray(),pos,pos,targetExpr); | mvps[0] = new MemberValuePair("targetType".toCharArray(),pos,pos,targetExpr); | ||||
mvps[1] = new MemberValuePair("name".toCharArray(),pos,pos,nameExpr); | mvps[1] = new MemberValuePair("name".toCharArray(),pos,pos,nameExpr); |
} | } | ||||
protected int generateInfoAttributes(ClassFile classFile) { | protected int generateInfoAttributes(ClassFile classFile) { | ||||
return classFile.generateMethodInfoAttribute(binding, false, AstUtil.getAjSyntheticAttribute()); | |||||
return classFile.generateMethodInfoAttributes(binding, AstUtil.getAjSyntheticAttribute()); | |||||
} | } | ||||
public void resolveStatements() { | public void resolveStatements() { |
} | } | ||||
addDeclarationStartLineAttribute(l,classFile); | addDeclarationStartLineAttribute(l,classFile); | ||||
return classFile.generateMethodInfoAttribute(binding, false, l); | |||||
return classFile.generateMethodInfoAttributes(binding, l); | |||||
} | } | ||||
protected abstract Shadow.Kind getShadowKindForBody(); | protected abstract Shadow.Kind getShadowKindForBody(); |
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; | ||||
} | } | ||||
classFile.generateMethodInfoHeader(binding); | classFile.generateMethodInfoHeader(binding); | ||||
int methodAttributeOffset = classFile.contentsOffset; | int methodAttributeOffset = classFile.contentsOffset; | ||||
int attributeNumber = classFile.generateMethodInfoAttribute(binding, false, | |||||
makeEffectiveSignatureAttribute(sig, isGetter ? Shadow.FieldGet : Shadow.FieldSet, false)); | |||||
int attributeNumber = classFile.generateMethodInfoAttributes(binding, makeEffectiveSignatureAttribute(sig, isGetter ? Shadow.FieldGet : Shadow.FieldSet, false)); | |||||
int codeAttributeOffset = classFile.contentsOffset; | int codeAttributeOffset = classFile.contentsOffset; | ||||
classFile.generateCodeAttributeHeader(); | classFile.generateCodeAttributeHeader(); | ||||
CodeStream codeStream = classFile.codeStream; | CodeStream codeStream = classFile.codeStream; | ||||
classFile.completeCodeAttribute(codeAttributeOffset); | classFile.completeCodeAttribute(codeAttributeOffset); | ||||
attributeNumber++; | attributeNumber++; | ||||
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); | |||||
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); | |||||
} | } | ||||
private void generateInterfaceReadBody(MethodBinding binding, MethodBinding readMethod, CodeStream codeStream) { | private void generateInterfaceReadBody(MethodBinding binding, MethodBinding readMethod, CodeStream codeStream) { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.invokeinterface(readMethod); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface,readMethod,null); | |||||
} | } | ||||
private void generateInterfaceWriteBody(MethodBinding binding, MethodBinding writeMethod, CodeStream codeStream) { | private void generateInterfaceWriteBody(MethodBinding binding, MethodBinding writeMethod, CodeStream codeStream) { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.load(writeMethod.parameters[0], 1); | codeStream.load(writeMethod.parameters[0], 1); | ||||
codeStream.invokeinterface(writeMethod); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface, writeMethod, null); | |||||
} | } | ||||
private void generateClassReadBody(MethodBinding binding, FieldBinding field, CodeStream codeStream) { | private void generateClassReadBody(MethodBinding binding, FieldBinding field, CodeStream codeStream) { | ||||
PrivilegedFieldBinding fBinding = (PrivilegedFieldBinding) handler.getPrivilegedAccessField(field, null); | PrivilegedFieldBinding fBinding = (PrivilegedFieldBinding) handler.getPrivilegedAccessField(field, null); | ||||
if (field.isStatic()) { | if (field.isStatic()) { | ||||
codeStream.invokestatic(fBinding.reader); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,fBinding.reader,null); | |||||
} else { | } else { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.invokestatic(fBinding.reader); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,fBinding.reader,null); | |||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (field.isStatic()) { | if (field.isStatic()) { | ||||
codeStream.getstatic(field); | |||||
codeStream.fieldAccess(Opcodes.OPC_getstatic,field,null); | |||||
} else { | } else { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.getfield(field); | |||||
codeStream.fieldAccess(Opcodes.OPC_getfield,field,null); | |||||
} | } | ||||
} | } | ||||
if (field.isPrivate() || !field.canBeSeenBy(binding.declaringClass.fPackage)) { | if (field.isPrivate() || !field.canBeSeenBy(binding.declaringClass.fPackage)) { | ||||
PrivilegedFieldBinding fBinding = (PrivilegedFieldBinding) Scope.findPrivilegedHandler(binding.declaringClass) | PrivilegedFieldBinding fBinding = (PrivilegedFieldBinding) Scope.findPrivilegedHandler(binding.declaringClass) | ||||
.getPrivilegedAccessField(field, null); | .getPrivilegedAccessField(field, null); | ||||
if (field.isStatic()) { | if (field.isStatic()) { | ||||
codeStream.load(field.type, 0); | codeStream.load(field.type, 0); | ||||
codeStream.invokestatic(fBinding.writer); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,fBinding.writer,null); | |||||
} else { | } else { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.load(field.type, 1); | codeStream.load(field.type, 1); | ||||
codeStream.invokestatic(fBinding.writer); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,fBinding.writer,null); | |||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (field.isStatic()) { | if (field.isStatic()) { | ||||
codeStream.load(field.type, 0); | codeStream.load(field.type, 0); | ||||
codeStream.putstatic(field); | |||||
codeStream.fieldAccess(Opcodes.OPC_putstatic,field,null); | |||||
} else { | } else { | ||||
codeStream.aload_0(); | codeStream.aload_0(); | ||||
codeStream.load(field.type, 1); | codeStream.load(field.type, 1); | ||||
codeStream.putfield(field); | |||||
codeStream.fieldAccess(Opcodes.OPC_putfield,field,null); | |||||
} | } | ||||
} | } | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; | import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo; | import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext; | import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; | ||||
// the dispatch binding attributes will include the annotations from the 'binding'. | // the dispatch binding attributes will include the annotations from the 'binding'. | ||||
// There is a chance that something else on the binding (e.g. throws clause) might | // There is a chance that something else on the binding (e.g. throws clause) might | ||||
// damage the attributes generated for the dispatch binding. | // damage the attributes generated for the dispatch binding. | ||||
int attributeNumber = classFile.generateMethodInfoAttribute(binding, false, makeEffectiveSignatureAttribute(signature, | |||||
int attributeNumber = classFile.generateMethodInfoAttributes(binding, makeEffectiveSignatureAttribute(signature, | |||||
Shadow.MethodCall, false)); | Shadow.MethodCall, false)); | ||||
int codeAttributeOffset = classFile.contentsOffset; | int codeAttributeOffset = classFile.contentsOffset; | ||||
classFile.generateCodeAttributeHeader(); | classFile.generateCodeAttributeHeader(); | ||||
} | } | ||||
// TypeBinding type; | // TypeBinding type; | ||||
if (methodBinding.isStatic()) | if (methodBinding.isStatic()) | ||||
codeStream.invokestatic(methodBinding); | |||||
codeStream.invoke(Opcodes.OPC_invokestatic,methodBinding,null); | |||||
else { | else { | ||||
if (methodBinding.declaringClass.isInterface()) { | if (methodBinding.declaringClass.isInterface()) { | ||||
codeStream.invokeinterface(methodBinding); | |||||
codeStream.invoke(Opcodes.OPC_invokeinterface, methodBinding, null); | |||||
} else { | } else { | ||||
codeStream.invokevirtual(methodBinding); | |||||
codeStream.invoke(Opcodes.OPC_invokevirtual, methodBinding, null); | |||||
} | } | ||||
} | } | ||||
AstUtil.generateReturn(dispatchBinding.returnType, codeStream); | AstUtil.generateReturn(dispatchBinding.returnType, codeStream); | ||||
} | } | ||||
classFile.completeCodeAttribute(codeAttributeOffset); | classFile.completeCodeAttribute(codeAttributeOffset); | ||||
attributeNumber++; | attributeNumber++; | ||||
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); | |||||
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); | |||||
} | } | ||||
protected Shadow.Kind getShadowKindForBody() { | protected Shadow.Kind getShadowKindForBody() { |
public KnownFieldReference(FieldBinding binding, int startPos,int endPos) { | public KnownFieldReference(FieldBinding binding, int startPos,int endPos) { | ||||
super(new char[][] {binding.name},new long[1], startPos, endPos); | super(new char[][] {binding.name},new long[1], startPos, endPos); | ||||
this.binding = this.codegenBinding = binding; | |||||
this.binding = /*this.codegenBinding = */binding; | |||||
this.constant = Constant.NotAConstant; | this.constant = Constant.NotAConstant; | ||||
this.actualReceiverType = binding.declaringClass; | this.actualReceiverType = binding.declaringClass; | ||||
//XXX handle source locations | //XXX handle source locations | ||||
public KnownFieldReference(FieldBinding binding, long pos) { | public KnownFieldReference(FieldBinding binding, long pos) { | ||||
super(new char[][] {binding.name},new long[1], 0, 0); | super(new char[][] {binding.name},new long[1], 0, 0); | ||||
this.binding = this.codegenBinding = binding; | |||||
this.binding = /*this.codegenBinding = */binding; | |||||
this.constant = Constant.NotAConstant; | this.constant = Constant.NotAConstant; | ||||
this.actualReceiverType = binding.declaringClass; | this.actualReceiverType = binding.declaringClass; | ||||
* Contributors: | * Contributors: | ||||
* PARC initial implementation | * PARC initial implementation | ||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.ajdt.internal.compiler.ast; | package org.aspectj.ajdt.internal.compiler.ast; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; | ||||
public KnownMessageSend(MethodBinding binding, Expression receiver, Expression[] arguments) { | public KnownMessageSend(MethodBinding binding, Expression receiver, Expression[] arguments) { | ||||
super(); | super(); | ||||
this.binding = this.codegenBinding = binding; | |||||
this.binding = binding; | |||||
this.arguments = arguments; | this.arguments = arguments; | ||||
this.receiver = receiver; | this.receiver = receiver; | ||||
this.actualReceiverType = binding.declaringClass; | |||||
this.selector = binding.selector; | this.selector = binding.selector; | ||||
constant = Constant.NotAConstant; | constant = Constant.NotAConstant; | ||||
} | } | ||||
BlockScope scope, | BlockScope scope, | ||||
TypeBinding[] argumentTypes) { | TypeBinding[] argumentTypes) { | ||||
// we've already resolved this | // we've already resolved this | ||||
} | } | ||||
public String toStringExpression() { | public String toStringExpression() { | ||||
CodeStream codeStream, | CodeStream codeStream, | ||||
boolean valueRequired) { | boolean valueRequired) { | ||||
//System.out.println("about to generate: " +this + " args: " + Arrays.asList(arguments)); | //System.out.println("about to generate: " +this + " args: " + Arrays.asList(arguments)); | ||||
// this.actualReceiverType = this.receiver.resolveType(currentScope); | |||||
super.generateCode(currentScope, codeStream, valueRequired); | super.generateCode(currentScope, codeStream, valueRequired); | ||||
} | } | ||||
this.selector = parent.selector; | this.selector = parent.selector; | ||||
this.arguments = parent.arguments; | this.arguments = parent.arguments; | ||||
this.binding = parent.binding; | this.binding = parent.binding; | ||||
this.codegenBinding = parent.codegenBinding; | |||||
//this.codegenBinding = parent.codegenBinding; | |||||
this.syntheticAccessor = parent.syntheticAccessor; | this.syntheticAccessor = parent.syntheticAccessor; | ||||
this.expectedType = parent.expectedType; | this.expectedType = parent.expectedType; | ||||
} | } | ||||
constant = Constant.NotAConstant; | constant = Constant.NotAConstant; | ||||
binding = codegenBinding = aroundDecl.proceedMethodBinding; | |||||
binding =/* codegenBinding = */aroundDecl.proceedMethodBinding; | |||||
this.actualReceiverType = binding.declaringClass; | this.actualReceiverType = binding.declaringClass; | ||||
if (argType != null) { | if (argType != null) { | ||||
TypeBinding paramType = binding.parameters[i]; | TypeBinding paramType = binding.parameters[i]; | ||||
if (!argType.isCompatibleWith(paramType)) { | if (!argType.isCompatibleWith(paramType)) { | ||||
scope.problemReporter().typeMismatchError(argType, paramType, arg); | |||||
scope.problemReporter().typeMismatchError(argType, paramType, arg,null); | |||||
} | } | ||||
} | } | ||||
} | } |
//System.err.println("replace static ref"); | //System.err.println("replace static ref"); | ||||
NameReference receiver = (NameReference) call.receiver; | NameReference receiver = (NameReference) call.receiver; | ||||
receiver.binding = thisJoinPointStaticPartDecLocal; //thisJoinPointStaticPartDec; | receiver.binding = thisJoinPointStaticPartDecLocal; //thisJoinPointStaticPartDec; | ||||
receiver.codegenBinding = thisJoinPointStaticPartDecLocal; | |||||
// receiver.codegenBinding = thisJoinPointStaticPartDecLocal; | |||||
call.binding.declaringClass = | call.binding.declaringClass = | ||||
(ReferenceBinding) thisJoinPointStaticPartDec.type; | (ReferenceBinding) thisJoinPointStaticPartDec.type; |
public void endVisit(MessageSend call, BlockScope scope) { | public void endVisit(MessageSend call, BlockScope scope) { | ||||
// System.out.println("endVisit: " + call); | // System.out.println("endVisit: " + call); | ||||
// an error has already occurred | // an error has already occurred | ||||
if (call.codegenBinding == null) | |||||
if (call.binding/*codegenBinding*/ == null) | |||||
return; | return; | ||||
MethodBinding superBinding = call.codegenBinding; | |||||
MethodBinding superBinding = call.binding/*codegenBinding*/; | |||||
if (superBinding instanceof ProblemMethodBinding) { | if (superBinding instanceof ProblemMethodBinding) { | ||||
return; | return; | ||||
} | } |
// System.err.println("replace static ref: " + receiver + " is " + System.identityHashCode(receiver)); | // System.err.println("replace static ref: " + receiver + " is " + System.identityHashCode(receiver)); | ||||
receiver.binding = thisJoinPointStaticPartDecLocal; // thisJoinPointStaticPartDec; | receiver.binding = thisJoinPointStaticPartDecLocal; // thisJoinPointStaticPartDec; | ||||
receiver.codegenBinding = thisJoinPointStaticPartDecLocal; | |||||
// receiver.codegenBinding = thisJoinPointStaticPartDecLocal; | |||||
ReferenceBinding thisJoinPointStaticPartType = (ReferenceBinding) thisJoinPointStaticPartDec.type; | ReferenceBinding thisJoinPointStaticPartType = (ReferenceBinding) thisJoinPointStaticPartDec.type; | ||||
// } else { | // } else { | ||||
// declaringElement = makeTypeBinding((UnresolvedType)tVar.getDeclaringElement()); | // declaringElement = makeTypeBinding((UnresolvedType)tVar.getDeclaringElement()); | ||||
// } | // } | ||||
tvBinding = new TypeVariableBinding(tv.getName().toCharArray(), declaringElement, tv.getRank()); | |||||
tvBinding = new TypeVariableBinding(tv.getName().toCharArray(), declaringElement, tv.getRank(),this.lookupEnvironment); | |||||
typeVariableToTypeBinding.put(tv.getName(), tvBinding); | typeVariableToTypeBinding.put(tv.getName(), tvBinding); | ||||
if (tv.getSuperclass() != null | if (tv.getSuperclass() != null |
} | } | ||||
// may be unresolved if the aspect type binding was a BinaryTypeBinding | // may be unresolved if the aspect type binding was a BinaryTypeBinding | ||||
if (innerTypeBinding instanceof UnresolvedReferenceBinding) { | if (innerTypeBinding instanceof UnresolvedReferenceBinding) { | ||||
innerTypeBinding = BinaryTypeBinding.resolveType(innerTypeBinding, world.getLookupEnvironment(), true); | |||||
innerTypeBinding = (ReferenceBinding)BinaryTypeBinding.resolveType(innerTypeBinding, world.getLookupEnvironment(), true); | |||||
} | } | ||||
// rb = new InterTypeMemberClassBinding(world, munger, aspectType, aspectTypeBinding, onType, munger.getMemberTypeName(), | // rb = new InterTypeMemberClassBinding(world, munger, aspectType, aspectTypeBinding, onType, munger.getMemberTypeName(), | ||||
// sourceType); | // sourceType); |
private void generateMethod(ClassFile classFile, MethodBinding binding) { | private void generateMethod(ClassFile classFile, MethodBinding binding) { | ||||
classFile.generateMethodInfoHeader(binding); | classFile.generateMethodInfoHeader(binding); | ||||
int methodAttributeOffset = classFile.contentsOffset; | int methodAttributeOffset = classFile.contentsOffset; | ||||
int attributeNumber = classFile.generateMethodInfoAttribute(binding); | |||||
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); | |||||
int attributeNumber = classFile.generateMethodInfoAttributes(binding); | |||||
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); | |||||
} | } | ||||
int aliased = (aliases == null ? -1 : aliases.indexOf(variableName)); | int aliased = (aliases == null ? -1 : aliases.indexOf(variableName)); | ||||
if (aliased != -1) { | if (aliased != -1) { | ||||
if (aliased > sourceType.typeVariables.length || sourceType.typeVariables.length == 0) { | if (aliased > sourceType.typeVariables.length || sourceType.typeVariables.length == 0) { | ||||
TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(), null, 0); | |||||
TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(), null, 0,this.environment()); | |||||
tvb.superclass = getJavaLangObject(); | tvb.superclass = getJavaLangObject(); | ||||
tvb.fPackage = new PackageBinding(environment()); | tvb.fPackage = new PackageBinding(environment()); | ||||
return tvb; | return tvb; |
if (severity != ProblemSeverities.Ignore && DUMP_STACK) { | if (severity != ProblemSeverities.Ignore && DUMP_STACK) { | ||||
Thread.dumpStack(); | Thread.dumpStack(); | ||||
} | } | ||||
super.handle(problemId, problemArguments, messageArguments, severity, problemStartPosition, problemEndPosition, | |||||
super.handle(problemId, problemArguments, | |||||
0, // no message elaboration | |||||
messageArguments, severity, problemStartPosition, problemEndPosition, | |||||
referenceContext, unitResult); | referenceContext, unitResult); | ||||
} | } | ||||
* Overrides the implementation in ProblemReporter and is ITD aware. To report a *real* problem with an ITD marked @override, | * Overrides the implementation in ProblemReporter and is ITD aware. To report a *real* problem with an ITD marked @override, | ||||
* the other methodMustOverride() method is used. | * the other methodMustOverride() method is used. | ||||
*/ | */ | ||||
public void methodMustOverride(AbstractMethodDeclaration method) { | |||||
public void methodMustOverride(AbstractMethodDeclaration method, int complianceLevel) { | |||||
// ignore ajc$ methods | // ignore ajc$ methods | ||||
if (new String(method.selector).startsWith("ajc$")) | if (new String(method.selector).startsWith("ajc$")) | ||||
supertypeToLookAt = supertypeToLookAt.getSuperclass(); | supertypeToLookAt = supertypeToLookAt.getSuperclass(); | ||||
} | } | ||||
// report the error... | // report the error... | ||||
super.methodMustOverride(method); | |||||
super.methodMustOverride(method,complianceLevel); | |||||
} | } | ||||
private String typesAsString(boolean isVarargs, TypeBinding[] types, boolean makeShort) { | private String typesAsString(boolean isVarargs, TypeBinding[] types, boolean makeShort) { | ||||
} | } | ||||
} | } | ||||
public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) { | |||||
public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) { | |||||
if (new String(methodDecl.selector).startsWith("ajc$interMethod")) { | if (new String(methodDecl.selector).startsWith("ajc$interMethod")) { | ||||
// this is an ITD clash and will be reported in another way by AspectJ (173602) | // this is an ITD clash and will be reported in another way by AspectJ (173602) | ||||
return; | return; | ||||
} | } | ||||
super.duplicateMethodInType(type, methodDecl); | |||||
super.duplicateMethodInType(type, methodDecl, equalParameters, severity); | |||||
} | } | ||||
// pr246393 - if we are going to complain about privileged, we clearly don't know what is going on, so don't | // pr246393 - if we are going to complain about privileged, we clearly don't know what is going on, so don't |
import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit; | import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.env.INameEnvironment; | import org.aspectj.org.eclipse.jdt.internal.compiler.env.INameEnvironment; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.IrritantSet; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; | import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; | import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; | import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; | ||||
bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp()); | bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp()); | ||||
bcelWorld.setXHasMemberSupportEnabled(buildConfig.isXHasMemberEnabled()); | bcelWorld.setXHasMemberSupportEnabled(buildConfig.isXHasMemberEnabled()); | ||||
bcelWorld.setPinpointMode(buildConfig.isXdevPinpoint()); | bcelWorld.setPinpointMode(buildConfig.isXdevPinpoint()); | ||||
bcelWorld.setErrorAndWarningThreshold(buildConfig.getOptions().errorThreshold, buildConfig.getOptions().warningThreshold); | |||||
bcelWorld.setErrorAndWarningThreshold(buildConfig.getOptions().errorThreshold.isSet(24), buildConfig.getOptions().warningThreshold.isSet(24)); | |||||
BcelWeaver bcelWeaver = new BcelWeaver(bcelWorld); | BcelWeaver bcelWeaver = new BcelWeaver(bcelWorld); | ||||
bcelWeaver.setCustomMungerFactory(customMungerFactory); | bcelWeaver.setCustomMungerFactory(customMungerFactory); | ||||
state.setWorld(bcelWorld); | state.setWorld(bcelWorld); |
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; | import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.IrritantSet; | |||||
import org.aspectj.weaver.Constants; | import org.aspectj.weaver.Constants; | ||||
/** | /** | ||||
public static final String OPTION_GenerateJavaDocsInModel = "org.aspectj.ajdt.core.compiler.model.GenerateJavaDocsInModel"; | public static final String OPTION_GenerateJavaDocsInModel = "org.aspectj.ajdt.core.compiler.model.GenerateJavaDocsInModel"; | ||||
public static final String OPTION_Emacssym = "org.aspectj.ajdt.core.compiler.model.Emacssym"; | public static final String OPTION_Emacssym = "org.aspectj.ajdt.core.compiler.model.Emacssym"; | ||||
// constants for irritant levels | // constants for irritant levels | ||||
public static final long InvalidAbsoluteTypeName = ASTNode.Bit47L; | |||||
public static final long InvalidWildCardTypeName = ASTNode.Bit48L; | |||||
public static final long UnresolvableMember = ASTNode.Bit49L; | |||||
public static final long TypeNotExposedToWeaver = ASTNode.Bit50L; | |||||
public static final long ShadowNotInStructure = ASTNode.Bit51L; | |||||
public static final long UnmatchedSuperTypeInCall = ASTNode.Bit52L; | |||||
public static final long CannotImplementLazyTJP = ASTNode.Bit53L; | |||||
public static final long NeedSerialVersionUIDField = ASTNode.Bit54L; | |||||
public static final long IncompatibleSerialVersion = ASTNode.Bit55L; | |||||
public static final int InvalidAbsoluteTypeName = IrritantSet.GROUP2 | ASTNode.Bit8; | |||||
public static final int InvalidWildCardTypeName = IrritantSet.GROUP2 | ASTNode.Bit9; | |||||
public static final int UnresolvableMember = IrritantSet.GROUP2 | ASTNode.Bit10; | |||||
public static final int TypeNotExposedToWeaver = IrritantSet.GROUP2 | ASTNode.Bit11; | |||||
public static final int ShadowNotInStructure = IrritantSet.GROUP2 | ASTNode.Bit12; | |||||
public static final int UnmatchedSuperTypeInCall = IrritantSet.GROUP2 | ASTNode.Bit13; | |||||
public static final int CannotImplementLazyTJP = IrritantSet.GROUP2 | ASTNode.Bit14; | |||||
public static final int NeedSerialVersionUIDField = IrritantSet.GROUP2 | ASTNode.Bit15; | |||||
public static final int IncompatibleSerialVersion = IrritantSet.GROUP2 | ASTNode.Bit16; | |||||
public boolean terminateAfterCompilation = false; | public boolean terminateAfterCompilation = false; | ||||
public boolean xSerializableAspects = false; | public boolean xSerializableAspects = false; | ||||
*/ | */ | ||||
public Map getMap() { | public Map getMap() { | ||||
Map map = super.getMap(); | Map map = super.getMap(); | ||||
// now add AspectJ additional options | |||||
// now add AspectJ additional options | |||||
map.put(OPTION_ReportInvalidAbsoluteTypeName, getSeverityString(InvalidAbsoluteTypeName)); | map.put(OPTION_ReportInvalidAbsoluteTypeName, getSeverityString(InvalidAbsoluteTypeName)); | ||||
map.put(OPTION_ReportInvalidWildcardTypeName, getSeverityString(InvalidWildCardTypeName)); | map.put(OPTION_ReportInvalidWildcardTypeName, getSeverityString(InvalidWildCardTypeName)); | ||||
map.put(OPTION_ReportUnresolvableMember, getSeverityString(UnresolvableMember)); | map.put(OPTION_ReportUnresolvableMember, getSeverityString(UnresolvableMember)); | ||||
* Add these warnings to the default set... | * Add these warnings to the default set... | ||||
*/ | */ | ||||
private void setAspectJWarningDefaults() { | private void setAspectJWarningDefaults() { | ||||
super.warningThreshold = super.warningThreshold | InvalidAbsoluteTypeName | UnresolvableMember | TypeNotExposedToWeaver | |||||
| UnmatchedSuperTypeInCall | CannotImplementLazyTJP | CompilerOptions.SwallowedExceptionInCatchBlock; | |||||
super.warningThreshold = new IrritantSet(super.warningThreshold); | |||||
super.warningThreshold.set(InvalidAbsoluteTypeName | UnresolvableMember | TypeNotExposedToWeaver | |||||
| UnmatchedSuperTypeInCall | CannotImplementLazyTJP | CompilerOptions.SwallowedExceptionInCatchBlock); | |||||
} | } | ||||
/* | /* |
File sourceFile = new File(result.fileName()); | File sourceFile = new File(result.fileName()); | ||||
CompilationResult cr = result.result(); | CompilationResult cr = result.result(); | ||||
references.put(sourceFile, new ReferenceCollection(cr.qualifiedReferences, cr.simpleNameReferences)); | |||||
references.put(sourceFile, new ReferenceCollection(cr.qualifiedReferences, cr.simpleNameReferences,cr.rootReferences)); | |||||
UnwovenClassFile[] unwovenClassFiles = result.unwovenClassFiles(); | UnwovenClassFile[] unwovenClassFiles = result.unwovenClassFiles(); | ||||
for (int i = 0; i < unwovenClassFiles.length; i++) { | for (int i = 0; i < unwovenClassFiles.length; i++) { | ||||
existingCollection.addDependencies(typeNameDependencies); | existingCollection.addDependencies(typeNameDependencies); | ||||
return true; | return true; | ||||
} else { | } else { | ||||
ReferenceCollection rc = new ReferenceCollection(null, null); | |||||
ReferenceCollection rc = new ReferenceCollection(null, null, null); | |||||
rc.addDependencies(typeNameDependencies); | rc.addDependencies(typeNameDependencies); | ||||
references.put(sourceFile, rc); | references.put(sourceFile, rc); | ||||
return true; | return true; |
char[] genericSignature; | char[] genericSignature; | ||||
char[] superclassName; | char[] superclassName; | ||||
char[][] interfaces; | char[][] interfaces; | ||||
char[] enclosingMethod; | |||||
char[][][] missingTypeNames; | |||||
// this is the extra state that enables us to be an IBinaryType | // this is the extra state that enables us to be an IBinaryType | ||||
char[] enclosingTypeName; | char[] enclosingTypeName; | ||||
IBinaryMethod[] binMethods; | IBinaryMethod[] binMethods; | ||||
IBinaryNestedType[] memberTypes; | IBinaryNestedType[] memberTypes; | ||||
IBinaryAnnotation[] annotations; | IBinaryAnnotation[] annotations; | ||||
public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) { | public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) { | ||||
this.isMember = cfr.isMember(); | this.isMember = cfr.isMember(); | ||||
this.sourceFileName = cfr.sourceFileName(); | this.sourceFileName = cfr.sourceFileName(); | ||||
this.fileName = cfr.getFileName(); | this.fileName = cfr.getFileName(); | ||||
this.missingTypeNames = cfr.getMissingTypeNames(); | |||||
this.tagBits = cfr.getTagBits(); | this.tagBits = cfr.getTagBits(); | ||||
this.enclosingMethod = cfr.getEnclosingMethod(); | |||||
this.isBinaryType = cfr.isBinaryType(); | this.isBinaryType = cfr.isBinaryType(); | ||||
this.binFields = cfr.getFields(); | this.binFields = cfr.getFields(); | ||||
if (binFields == null) { | if (binFields == null) { | ||||
} | } | ||||
public char[][][] getMissingTypeNames() { | |||||
return missingTypeNames; | |||||
} | |||||
public char[] getEnclosingTypeName() { | public char[] getEnclosingTypeName() { | ||||
return enclosingTypeName; | return enclosingTypeName; | ||||
} | } | ||||
public char[] getGenericSignature() { | public char[] getGenericSignature() { | ||||
return genericSignature; | return genericSignature; | ||||
} | } | ||||
public char[] getEnclosingMethod() { | |||||
return enclosingMethod; | |||||
} | |||||
public char[][] getInterfaceNames() { | public char[][] getInterfaceNames() { | ||||
return interfaces; | return interfaces; |
ast.setDefaultNodeFlag(ASTNode.ORIGINAL); | ast.setDefaultNodeFlag(ASTNode.ORIGINAL); | ||||
BindingResolver resolver = null; | BindingResolver resolver = null; | ||||
if (isResolved) { | if (isResolved) { | ||||
resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables(), false); | |||||
resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope, workingCopy.owner, new DefaultBindingResolver.BindingTables(), false,true); | |||||
ast.setFlag(AST.RESOLVED_BINDINGS); | ast.setFlag(AST.RESOLVED_BINDINGS); | ||||
} else { | } else { | ||||
resolver = new BindingResolver(); | resolver = new BindingResolver(); |
} | } | ||||
} | } | ||||
} | } | ||||
buildBodyDeclarations(typeDeclaration, typeDecl); | |||||
buildBodyDeclarations(typeDeclaration, typeDecl,org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.kind(typeDeclaration.modifiers) == org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.INTERFACE_DECL); | |||||
if (this.resolveBindings) { | if (this.resolveBindings) { | ||||
recordNodes(typeDecl, typeDeclaration); | recordNodes(typeDecl, typeDeclaration); | ||||
recordNodes(typeName, typeDeclaration); | recordNodes(typeName, typeDeclaration); |
import org.aspectj.org.eclipse.jdt.core.dom.TypeCategoryTypePattern; | import org.aspectj.org.eclipse.jdt.core.dom.TypeCategoryTypePattern; | ||||
import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration; | import org.aspectj.org.eclipse.jdt.core.dom.TypeDeclaration; | ||||
import org.aspectj.org.eclipse.jdt.core.dom.TypePattern; | import org.aspectj.org.eclipse.jdt.core.dom.TypePattern; | ||||
import org.aspectj.org.eclipse.jdt.internal.core.SourceRange; | |||||
import org.aspectj.org.eclipse.jdt.core.SourceRange; | |||||
/** | /** | ||||
* For each AspectJ ASTNode there is a test for: | * For each AspectJ ASTNode there is a test for: |
import org.aspectj.org.eclipse.jdt.core.dom.AjAST; | import org.aspectj.org.eclipse.jdt.core.dom.AjAST; | ||||
import org.aspectj.org.eclipse.jdt.core.dom.AjASTVisitor; | import org.aspectj.org.eclipse.jdt.core.dom.AjASTVisitor; | ||||
import org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit; | import org.aspectj.org.eclipse.jdt.core.dom.CompilationUnit; | ||||
import org.aspectj.org.eclipse.jdt.internal.core.SourceRange; | |||||
import org.aspectj.org.eclipse.jdt.core.SourceRange; | |||||
public abstract class AjASTTestCase extends TestCase { | public abstract class AjASTTestCase extends TestCase { | ||||