import org.aspectj.ajdt.internal.compiler.lookup.HelperInterfaceBinding;
import org.aspectj.ajdt.internal.compiler.lookup.InlineAccessFieldBinding;
import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedHandler;
+import org.aspectj.apache.bcel.classfile.Signature.BaseTypeSignature;
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
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.Clinit;
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.classfmt.ClassFileConstants;
+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.ExceptionLabel;
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Label;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IGenericType;
-import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BaseTypes;
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.ClassScope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SyntheticFieldBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.AjcMemberMaker;
}
public boolean isAbstract() {
- return (modifiers & AccAbstract) != 0;
+ return (modifiers & ClassFileConstants.AccAbstract) != 0;
}
public void resolve() {
if (!isAbstract()) {
- initFailureField = factory.makeFieldBinding(AjcMemberMaker.initFailureCauseField(typeX));
- binding.addField(initFailureField);
+ initFailureField = factory.createSyntheticFieldBinding(binding,AjcMemberMaker.initFailureCauseField(typeX));
+// binding.addSyntheticField((SyntheticFieldBinding)initFailureField);
+ //initFailureField = factory.makeFieldBinding(AjcMemberMaker.initFailureCauseField(typeX));
+ //binding.addField(initFailureField);
if (perClause == null) {
// we've already produced an error for this
} else if (perClause.getKind() == PerClause.SINGLETON) {
- binding.addField(factory.makeFieldBinding(AjcMemberMaker.perSingletonField(
- typeX)));
+ factory.createSyntheticFieldBinding(binding, AjcMemberMaker.perSingletonField(typeX));
+//CUSTARD binding.addField(factory.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX)));
+//CUSTARD
methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, false, true, initFailureField);
} else if (perClause.getKind() == PerClause.PERCFLOW) {
- binding.addField(
- factory.makeFieldBinding(
- AjcMemberMaker.perCflowField(
- typeX)));
+ factory.createSyntheticFieldBinding(binding, AjcMemberMaker.perCflowField(typeX));
+//CUSTARD binding.addField(factory.makeFieldBinding(AjcMemberMaker.perCflowField(typeX)));
methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, true, false, null);
} else if (perClause.getKind() == PerClause.PEROBJECT) {
// binding.addField(
// AjcMemberMaker.perCflowField(
// typeX)));
} else if (perClause.getKind() == PerClause.PERTYPEWITHIN) {
+ factory.createSyntheticFieldBinding(binding, AjcMemberMaker.perTypeWithinWithinTypeField(typeX,typeX));
//PTWIMPL Add field for storing typename in aspect for which the aspect instance exists
- binding.addField(factory.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX,typeX)));
+// binding.addField(factory.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX,typeX)));
} else {
throw new RuntimeException("unimplemented");
}
gen.generate(codeStream);
// body ends here
if (codeStream.pcToSourceMapSize==0) codeStream.recordPositionsFrom(0,1);
- boolean b = codeStream.generateLocalVariableTableAttributes; // pr148693
- if (codeStream.maxLocals==0)
- codeStream.generateLocalVariableTableAttributes=false;
+ boolean b = ((codeStream.generateAttributes & ClassFileConstants.ATTR_VARS)!=0?true:false); // pr148693
+ if (codeStream.maxLocals==0) {
+ codeStream.generateAttributes &= ~ClassFileConstants.ATTR_VARS;
+ }
classFile.completeCodeAttribute(codeAttributeOffset);
- codeStream.generateLocalVariableTableAttributes=b;
+ if (b) codeStream.generateAttributes |= ClassFileConstants.ATTR_VARS;
attributeNumber++;
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber);
codeStream.dup();
codeStream.invokespecial(
new MethodBinding(0, "<init>".toCharArray(),
- BaseTypes.VoidBinding, new TypeBinding[0],
+ TypeBinding.VOID, new TypeBinding[0],
new ReferenceBinding[0], binding));
final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
generateMethod(classFile, aspectOfMethod, new BodyGenerator() {
public void generate(CodeStream codeStream) {
-
- Label instanceFound = new Label(codeStream);
+ BranchLabel instanceFound = new BranchLabel(codeStream);
ExceptionLabel anythingGoesWrong = new ExceptionLabel(codeStream,world.makeTypeBinding(UnresolvedType.JAVA_LANG_EXCEPTION));
+ anythingGoesWrong.placeStart();
codeStream.aload_0();
codeStream.invokestatic(world.makeMethodBindingForCall(AjcMemberMaker.perTypeWithinGetInstance(typeX)));
codeStream.astore_1();
generateMethod(classFile, aspectOfMethod, new BodyGenerator() {
public void generate(CodeStream codeStream) {
// body starts here
- Label wrongType = new Label(codeStream);
- Label popWrongType = new Label(codeStream);
+ BranchLabel wrongType = new BranchLabel(codeStream);
+ BranchLabel popWrongType = new BranchLabel(codeStream);
codeStream.aload_0();
codeStream.instance_of(interfaceType);
codeStream.ifeq(wrongType);
generateMethod(classFile, hasAspectMethod, new BodyGenerator() {
public void generate(CodeStream codeStream) {
// body starts here
- Label wrongType = new Label(codeStream);
+ BranchLabel wrongType = new BranchLabel(codeStream);
codeStream.aload_0();
codeStream.instance_of(interfaceType);
codeStream.ifeq(wrongType);
generateMethod(classFile, hasAspectMethod, new BodyGenerator() {
public void generate(CodeStream codeStream) {
ExceptionLabel goneBang = new ExceptionLabel(codeStream,world.makeTypeBinding(UnresolvedType.JAVA_LANG_EXCEPTION));
- Label noInstanceExists = new Label(codeStream);
- Label leave = new Label(codeStream);
+ BranchLabel noInstanceExists = new BranchLabel(codeStream);
+ BranchLabel leave = new BranchLabel(codeStream);
goneBang.placeStart();
codeStream.aload_0();
codeStream.invokestatic(world.makeMethodBinding(AjcMemberMaker.perTypeWithinGetInstance(typeX)));
new BodyGenerator() {
public void generate(CodeStream codeStream) {
// body starts here
- Label wrongType = new Label(codeStream);
+ BranchLabel wrongType = new BranchLabel(codeStream);
codeStream.aload_0();
codeStream.instance_of(interfaceType);
codeStream.ifeq(wrongType); //XXX this case might call for screaming
codeStream.dup();
codeStream.invokespecial(
new MethodBinding(0, "<init>".toCharArray(),
- BaseTypes.VoidBinding, new TypeBinding[0],
+ TypeBinding.VOID, new TypeBinding[0],
new ReferenceBinding[0], binding));
codeStream.invokeinterface(world.makeMethodBindingForCall(
AjcMemberMaker.perObjectInterfaceSet(typeX)));
codeStream.new_(world.makeTypeBinding(typeX));
codeStream.dup();
codeStream.invokespecial(new MethodBinding(0, "<init>".toCharArray(),
- BaseTypes.VoidBinding, new TypeBinding[0],
+ TypeBinding.VOID, new TypeBinding[0],
new ReferenceBinding[0], binding));
codeStream.astore_1();
codeStream.aload_1();
// body starts here (see end of each line for what it is doing!)
FieldBinding fb = world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX));
codeStream.getstatic(fb); // GETSTATIC
- Label isNonNull = new Label(codeStream);
+ BranchLabel isNonNull = new BranchLabel(codeStream);
codeStream.ifnonnull(isNonNull); // IFNONNULL
codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); // NEW
codeStream.dup(); // DUP
// body starts here
codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perSingletonField(
typeX)));
- Label isNull = new Label(codeStream);
+ BranchLabel isNull = new BranchLabel(codeStream);
codeStream.ifnull(isNull);
codeStream.iconst_1();
codeStream.ireturn();
codeStream.dup();
codeStream.invokespecial(
new MethodBinding(0, "<init>".toCharArray(),
- BaseTypes.VoidBinding, new TypeBinding[0],
+ TypeBinding.VOID, new TypeBinding[0],
new ReferenceBinding[0], binding));
codeStream.putstatic(
superclass.print(0, output);
}
if (superInterfaces != null && superInterfaces.length > 0) {
- output.append((kind() == IGenericType.INTERFACE_DECL) ? " extends " : " implements ");//$NON-NLS-2$ //$NON-NLS-1$
+ output.append((TypeDeclaration.kind(this.modifiers) == TypeDeclaration.INTERFACE_DECL) ? " extends " : " implements ");//$NON-NLS-2$ //$NON-NLS-1$
for (int i = 0; i < superInterfaces.length; i++) {
if (i > 0) output.append( ", "); //$NON-NLS-1$
superInterfaces[i].print(0, output);
package org.aspectj.ajdt.internal.compiler.ast;
import org.aspectj.weaver.AdviceKind;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend;
+import org.aspectj.org.eclipse.jdt.internal.compiler.impl.Constant;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope;
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.MethodBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
return super.resolveType(scope);
}
- constant = NotAConstant;
+ constant = Constant.NotAConstant;
binding = codegenBinding = aroundDecl.proceedMethodBinding;
this.actualReceiverType = binding.declaringClass;
boolean argsContainCast = false;
for (int i=0; i<arguments.length;i++) {
if (arguments[i] instanceof CastExpression) argsContainCast = true;
+ // if (arguments[i].constant==null) arguments[i].constant=Constant.NotAConstant;
}
+// TypeBinding[] argumentTypes = Binding.NO_PARAMETERS;
+// if (this.arguments != null) {
+// boolean argHasError = false; // typeChecks all arguments
+// int length = this.arguments.length;
+// argumentTypes = new TypeBinding[length];
+// for (int i = 0; i < length; i++){
+// Expression argument = this.arguments[i];
+// if (argument instanceof CastExpression) {
+// argument.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on
+// argsContainCast = true;
+// }
+// if ((argumentTypes[i] = argument.resolveType(scope)) == null){
+// argHasError = true;
+// }
+// }
+// if (argHasError) {
+// if (this.actualReceiverType instanceof ReferenceBinding) {
+// // record a best guess, for clients who need hint about possible method match
+// TypeBinding[] pseudoArgs = new TypeBinding[length];
+// for (int i = length; --i >= 0;)
+// pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type
+// this.binding =
+// this.receiver.isImplicitThis()
+// ? scope.getImplicitMethod(this.selector, pseudoArgs, this)
+// : scope.findMethod((ReferenceBinding) this.actualReceiverType, this.selector, pseudoArgs, this);
+// if (this.binding != null && !this.binding.isValidBinding()) {
+// MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
+// // record the closest match, for clients who may still need hint about possible method match
+// if (closestMatch != null) {
+// if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method
+// // shouldn't return generic method outside its context, rather convert it to raw method (175409)
+// closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null);
+// }
+// this.binding = closestMatch;
+// MethodBinding closestMatchOriginal = closestMatch.original();
+// if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) {
+// // ignore cases where method is used from within inside itself (e.g. direct recursions)
+// closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
+// }
+// }
+// }
+// }
+// return null;
+// }
+// }
+//
- checkInvocationArguments(scope,null,this.actualReceiverType,binding,
- this.arguments,binding.parameters,argsContainCast,this);
+ // checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
for (int i=0, len=arguments.length; i < len; i++) {
Expression arg = arguments[i];
TypeBinding argType = arg.resolveType(scope);
}
}
}
-
+ checkInvocationArguments(scope,null,this.actualReceiverType,binding,
+ this.arguments,binding.parameters,argsContainCast,this);
return binding.returnType;
}