diff options
author | jhugunin <jhugunin> | 2003-02-13 22:00:34 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2003-02-13 22:00:34 +0000 |
commit | d15eb325fc77d9f1eb0ac9ec1f6886562d531105 (patch) | |
tree | 5c20d3a4d08a8490784fbb422d64dd69faeabc92 /org.aspectj.ajdt.core/src | |
parent | 3e2801ad504e8f6b3fa7b50a42bf2706994e1727 (diff) | |
download | aspectj-d15eb325fc77d9f1eb0ac9ec1f6886562d531105.tar.gz aspectj-d15eb325fc77d9f1eb0ac9ec1f6886562d531105.zip |
fixed Bug 30168: bad optimization of thisJoinPoint to thisJoinPointStaticPart
Diffstat (limited to 'org.aspectj.ajdt.core/src')
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ThisJoinPointVisitor.java | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ThisJoinPointVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ThisJoinPointVisitor.java index c8bdab1a4..a940ffbe4 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ThisJoinPointVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/ThisJoinPointVisitor.java @@ -61,6 +61,7 @@ public class ThisJoinPointVisitor extends AbstractSyntaxTreeVisitorAdapter { method.traverse(this, (ClassScope) null); //??? add support for option to disable this optimization + //System.err.println("walked: " + method); //System.err.println("check: "+ hasEffectivelyStaticRef + ", " + needsDynamic); if (hasEffectivelyStaticRef && !needsDynamic) { // replace effectively static refs with thisJoinPointStaticPart @@ -68,41 +69,30 @@ public class ThisJoinPointVisitor extends AbstractSyntaxTreeVisitorAdapter { needsStatic = true; method.traverse(this, (ClassScope) null); } + //System.err.println("done: " + method); } boolean isRef(NameReference ref, Binding binding) { + //System.err.println("check ref: " + ref + " is " + System.identityHashCode(ref)); return ref.binding == binding; } boolean isRef(Expression expr, Binding binding) { - //System.err.println("isRef: " + expr + ", " + binding); return expr != null && expr instanceof NameReference && isRef((NameReference) expr, binding); } public void endVisit(SingleNameReference ref, BlockScope scope) { - if (isRef(ref, thisJoinPointDec)) + if (isRef(ref, thisJoinPointDec)) { needsDynamic = true; - else if (isRef(ref, thisJoinPointStaticPartDec)) + } else if (isRef(ref, thisJoinPointStaticPartDec)) { needsStatic = true; - else if (isRef(ref, thisEnclosingJoinPointStaticPartDec)) + } else if (isRef(ref, thisEnclosingJoinPointStaticPartDec)) { needsStaticEnclosing = true; + } } - // public void checkAndFix(ASTObject body) { - // this.process(body); - // if (needsFakeStatic && !needsDynamic) { - // if (!this.getCompiler().getOptions().noMetaJoinPointOptimization) { - // makeFakeStatics = true; - // needsStatic = true; - // this.process(body); - // } else { - // needsDynamic = true; - // } - // } - // } - boolean canTreatAsStatic(String id) { return id.equals("toString") || id.equals("toShortString") @@ -158,13 +148,17 @@ public class ThisJoinPointVisitor extends AbstractSyntaxTreeVisitorAdapter { } private void replaceEffectivelyStaticRef(MessageSend call) { - //System.err.println("replace static ref"); NameReference receiver = (NameReference) call.receiver; + //System.err.println("replace static ref: " + receiver + " is " + System.identityHashCode(receiver)); receiver.binding = thisJoinPointStaticPartDecLocal; //thisJoinPointStaticPartDec; receiver.codegenBinding = thisJoinPointStaticPartDecLocal; - call.binding.declaringClass = - (ReferenceBinding) thisJoinPointStaticPartDec.type; + call.binding = call.codegenBinding = getEquivalentStaticBinding(call.binding); + } + + private MethodBinding getEquivalentStaticBinding(MethodBinding template) { + ReferenceBinding b = (ReferenceBinding)thisJoinPointStaticPartDec.type; + return b.getExactMethod(template.selector, template.parameters); } public int removeUnusedExtraArguments() { |