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 import org.aspectj.compiler.crosscuts.*; 30 31 import org.aspectj.compiler.base.JavaCompiler; 32 33 import java.util.*; 34 35 public class ExceptionHandlerJp extends CodeBodyJp { 36 CatchClause catchClause; 37 38 public ExceptionHandlerJp(CatchClause catchClause, JoinPoint enclosingJoinPoint) { 39 super(enclosingJoinPoint); 40 this.catchClause = catchClause; 41 } 42 43 static final Kind KIND = new Kind("exception-handler", HANDLER); 44 45 public Kind getKind() { return KIND; } 46 47 48 protected Expr makeSignatureExpr() { 49 return makeSignatureExpr(catchClause); 50 } 51 52 public ASTObject getSourceLocation() { return catchClause; } 53 54 public Expr makeThrowableExpr() { 55 return getAST().makeVar(catchClause.getFormal()); 56 } 57 58 public Type getTargetType() { 59 return null; 60 } 61 62 public Dec getTargetDec() { return catchClause.getEnclosingCodeDec(); } 64 65 public Type getResultType() { 66 return getTypeManager().voidType; 67 } 68 69 public Type getExceptionType() { 70 return catchClause.getFormal().getType(); 71 } 72 73 public Exprs makeArgsExprs() { 74 return getAST().makeExprs(makeThrowableExpr()); 75 } 76 77 public boolean canThrow(Type t) { 78 return t.isUncheckedThrowable(); 80 } 81 82 public Collection getPossibleCheckedExceptions() { 83 return Collections.EMPTY_LIST; 85 } 86 87 88 89 public Stmts getStmts() { 90 Stmt body = catchClause.getBody(); 91 if (body instanceof BlockStmt) { 92 return ((BlockStmt)body).getStmts(); 93 } else { 94 return getAST().makeStmts(body); 95 } 96 } 97 98 public void setStmts(Stmts stmts) { 99 catchClause.setBody(getAST().makeBlock(stmts)); 100 } 101 102 public FormalDec getFormal() { return catchClause.getFormal(); } 103 104 105 public String toString() { 106 return "handler(" + catchClause.getFormal() + ")"; 107 } 108 109 private static int counter = 0; 111 protected String getJoinPointNameModifier() { return "Handler" + counter++; } 112 } 113 | Popular Tags |