1 24 25 package org.aspectj.compiler.crosscuts.joinpoints; 26 27 import org.aspectj.compiler.base.ast.*; 28 import org.aspectj.compiler.crosscuts.ast.*; 29 30 import java.util.*; 31 32 public class CalleeSideCallJp extends CodeDecJp { 33 TypeDec typeDec; 34 public CalleeSideCallJp(TypeDec typeDec, MethodDec methodDec) { 35 super(methodDec); 36 this.typeDec = typeDec; 37 } 38 39 public Kind getKind() { return MethodCallJp.KIND; } 40 41 public void addPlan(JpPlan plan) { 42 if (plan instanceof AdvicePlan) { 43 AdvicePlan advicePlan = (AdvicePlan)plan; 44 if (advicePlan.getAdviceDec() != null && 45 advicePlan.getAdviceDec().needsStaticEnclosingJoinPointFormal()) 46 { 47 getCompiler().showMessage(" skip plan on " + this + " needs enclosing join point"); 48 return; 49 } 50 } 51 plans.add(plan); 52 } 53 54 56 public String toString() { 57 return super.toString() + "*"; 58 } 59 60 public Type getBytecodeType() { 61 return getCodeDec().getBytecodeType(); 62 } 63 64 public Type getDeclaringType() { 65 return getCodeDec().getDeclaringType(); 66 } 67 68 public Expr makeTargetExpr() { 69 return super.makeThisExpr(); 70 } 71 72 public Type makeThisExprType() { return null; } 73 public Expr makeThisExpr() { 74 return null; 75 } 76 public Exprs makeArgsExprs() { 77 return getCodeFormals().makeExprs(); 78 } 79 80 public ASTObject getSourceLocation() { return null; } 81 public ASTObject getTargetNode() { return getCodeDec(); } 82 public Type getTargetType() { 83 return null; } 85 86 87 public Set getTargetTypes() { 88 return getBaseMethodDec().getMatchingSignatureTypes(); 90 } 91 92 93 112 public boolean isSynthetic() { 113 return getCodeDec().getDeclaringType() != typeDec.getType(); 114 } 115 116 public MethodDec getBaseMethodDec() { 117 if (isSynthetic()) { 118 } 120 return (MethodDec)getCodeDec(); 121 } 122 123 public String getPostDispatchMethodName() { 124 return getAST().makeGeneratedName(getCodeDec().getId() + "$ajcPostCall"); 125 } 126 127 private Formals codeFormals = null; 128 public Formals getCodeFormals() { 129 if (codeFormals == null) { 130 codeFormals = (Formals)getBaseMethodDec().getFormals().copy(); 131 } 132 return codeFormals; 133 } 134 135 136 public MethodDec getPostMethodDec() { 137 if (postDispatchMethod == null) { 138 Formals formals = getBaseMethodDec().getFormals(); 139 Type resultType = getBaseMethodDec().getResultType(); 140 String id = getPostDispatchMethodName(); 141 Modifiers modifiers = (Modifiers)getBaseMethodDec().getModifiers().copy(); 142 postDispatchMethod = 143 getAST().makeMethod(modifiers, resultType, id, formals, null); 144 TypeDs _throws = getBaseMethodDec().getThrows(); 145 if (_throws != null) { 146 postDispatchMethod.setThrows((TypeDs)_throws.copy()); 147 } 148 postDispatchMethod.owner = getBaseMethodDec(); 149 getBaseMethodDec().getBytecodeTypeDec().getBody().add(postDispatchMethod); 150 } 151 return postDispatchMethod; 152 } 153 154 155 MethodDec postDispatchMethod = null; 156 boolean madeInnerMethod = false; 157 public Stmts getStmts() { 158 if (!madeInnerMethod) { 159 madeInnerMethod = true; 160 CodeBody body = getBaseMethodDec().getBody(); 161 Type resultType = getBaseMethodDec().getResultType(); 162 163 getBaseMethodDec().setBody(null); 164 165 getPostMethodDec(); 166 167 getBaseMethodDec().setFormals(getCodeFormals()); 168 getBaseMethodDec().setResultTypeD(resultType.makeTypeD()); 169 170 171 postDispatchMethod.setBody(body); 172 173 Exprs args = getCodeFormals().makeExprs(); 174 Expr thisExpr = makeThisExprOrType(); 175 Expr callExpr = getAST().makeCall(postDispatchMethod, thisExpr, args); 176 callExpr.setSourceLocation(getTargetNode().getSourceLocation()); 177 Stmt stmt = null; 178 if (resultType.isVoid()) { 179 stmt = getAST().makeStmt(callExpr); 180 } else { 181 stmt = getAST().makeReturn(callExpr); 182 } 183 getBaseMethodDec().setBody(getAST().makeBlock(stmt)); 184 } 185 return getBaseMethodDec().getBody().getStmts(); 186 } 187 } 188 | Popular Tags |