1 24 25 package org.aspectj.compiler.crosscuts.ast; 26 import org.aspectj.compiler.base.ast.*; 27 import org.aspectj.compiler.crosscuts.joinpoints.*; 28 import org.aspectj.util.*; 29 30 import org.aspectj.compiler.base.JavaCompiler; 31 32 35 36 public abstract class PerClause extends ASTObject { 37 MethodDec aspectOfMethod; 38 MethodDec hasAspectMethod; 39 40 private AspectDec aspectDec = null; 41 public AspectDec getAspectDec() { 42 if (aspectDec == null) { 43 aspectDec = (AspectDec)getParent(); 44 } 45 return aspectDec; 46 } 47 48 TypeD getAspectTypeD() { 49 return getAspectDec().getType().makeTypeD(); 50 } 51 Type getAspectType() { 52 return getAspectDec().getType(); 53 } 54 55 60 public Type getLexicalType() { 61 return getAspectType(); 62 } 63 64 public Type getDeclaringType() { 65 return getAspectType(); 66 } 67 68 public abstract JpPlanner makeInnerPlanner(PlanData planData); 69 public abstract JpPlanner makeInitializerPlanner(PlanData planData); 70 71 protected MethodDec makeAspectOfMethod(Formals formals, BlockStmt body) { 72 final AST ast = getAST(); 73 Modifiers modifiers = ast.makeModifiers(Modifiers.PUBLIC | Modifiers.STATIC); 74 String name = "aspectOf"; 75 80 return ast.makeMethod(modifiers, getAspectType(), name, formals, body); 81 } 82 83 protected MethodDec makeHasAspectMethod(Formals formals, BlockStmt body) { 84 final AST ast = getAST(); 85 Modifiers modifiers = ast.makeModifiers(Modifiers.PUBLIC | Modifiers.STATIC); 86 String name = "hasAspect"; 87 92 return ast.makeMethod(modifiers, getTypeManager().booleanType, name, formals, body); 93 } 94 95 protected abstract MethodDec makeAspectOfMethod(); 96 protected abstract MethodDec makeHasAspectMethod(); 97 98 99 public void setupAspect() { 100 TypeDec typeDec = getAspectDec(); 101 if (typeDec.isAbstract()) return; 102 103 aspectOfMethod = makeAspectOfMethod(); 104 typeDec.addToBodyAndType(aspectOfMethod); 105 hasAspectMethod = makeHasAspectMethod(); 106 typeDec.addToBodyAndType(hasAspectMethod); 107 } 108 109 public Expr makeAspectOfExpr(Expr fromObject) { return null; } 110 111 113 public PerClause(SourceLocation location) { 114 super(location); 115 116 } 117 118 119 public String getDefaultDisplayName() { 120 return "PerClause()"; 121 } 122 123 } 125 126 | Popular Tags |