From 2d10f482f22cf36649707f70e4cc5d8634d5325c Mon Sep 17 00:00:00 2001 From: jhugunin Date: Tue, 7 Jan 2003 23:20:59 +0000 Subject: [PATCH] proper handling of inter-type fields with array types --- .../ast/InterTypeFieldDeclaration.java | 21 ++++++++++++++++++- .../compiler/lookup/EclipseWorld.java | 2 +- .../internal/compiler/parser/AjParser.java | 6 +----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java index 86d5c9c8b..6051c9a7b 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java @@ -60,13 +60,30 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { EclipseWorld world = EclipseWorld.fromScopeLookupEnvironment(upperScope); ResolvedMember sig = munger.getSignature(); TypeX aspectType = EclipseWorld.fromBinding(upperScope.referenceContext.binding); +// +// System.err.println("sig: " + sig); +// System.err.println("field: " + world.makeFieldBinding( +// AjcMemberMaker.interFieldClassField(sig, aspectType))); + + + if (initialization != null && initialization instanceof ArrayInitializer) { + //System.err.println("got initializer: " + initialization); + ArrayAllocationExpression aae = new ArrayAllocationExpression(); + aae.initializer = (ArrayInitializer)initialization; + ArrayBinding arrayType = (ArrayBinding)world.makeTypeBinding(sig.getReturnType()); + aae.type = AstUtil.makeTypeReference(arrayType.leafComponentType()); + aae.sourceStart = initialization.sourceStart; + aae.sourceEnd = initialization.sourceEnd; + aae.dimensions = new Expression[arrayType.dimensions]; + initialization = aae; + } + if (initialization == null) { this.statements = new Statement[] { new ReturnStatement(null, 0, 0), }; } else if (!onTypeBinding.isInterface()) { - FieldBinding interField = world.makeFieldBinding( AjcMemberMaker.interFieldClassField(sig, aspectType)); Reference ref = new KnownFieldReference(interField, 0); @@ -117,6 +134,8 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { }; } + //System.err.println("type: " + binding.returnType + ", " + returnType); + ResolvedMember sig = new ResolvedMember(Member.FIELD, EclipseWorld.fromBinding(onTypeBinding), declaredModifiers, EclipseWorld.fromBinding(binding.returnType), diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java index c5ebf3dee..4b3c56499 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseWorld.java @@ -186,7 +186,7 @@ public class EclipseWorld extends World { dim++; typeX = typeX.getComponentType(); } - return new ArrayBinding(makeTypeBinding(typeX), dim); + return lookupEnvironment.createArrayType(makeTypeBinding(typeX), dim); } else { ResolvedTypeX rt = typeX.resolve(this); //System.out.println("typex: " + typeX + ", " + rt); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java index 40d65731e..ede3ca9f3 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java @@ -766,13 +766,9 @@ public class AjParser extends Parser { // field.sourceEnd = end; TypeReference onType = getTypeReference(0); - TypeReference returnType = getTypeReference(0); - // field.type = returnType; - + TypeReference returnType = getTypeReference(intStack[intPtr--]); this.display(); - int dontKnowWhatThisIs = intStack[intPtr--]; - int decSourceStart = intStack[intPtr--]; int modifiers = intStack[intPtr--]; -- 2.39.5