1 24 package org.aspectj.compiler.crosscuts.joinpoints; 25 26 import org.aspectj.compiler.base.ast.*; 27 import org.aspectj.compiler.crosscuts.ast.*; 28 29 import org.aspectj.compiler.base.JavaCompiler; 30 import org.aspectj.util.JavaStrings; 31 32 import java.util.*; 33 34 35 public class FieldGetJp extends ExprJp { 36 public static interface FieldGetExprPromise { 37 38 public FieldAccessExpr getFieldAccessExpr(); 39 40 public FieldDec getFieldDec(); 41 public Expr getSourceExpr(); 42 public Type getTargetType(); 43 public ASTObject getSourceLocation(); 44 } 45 46 FieldGetExprPromise fieldGetExprPromise; 47 48 public FieldGetJp(FieldGetExprPromise fieldGetExprPromise, 49 JoinPoint enclosingJoinPoint) 50 { 51 super(fieldGetExprPromise.getSourceExpr(), enclosingJoinPoint); 52 this.fieldGetExprPromise = fieldGetExprPromise; 53 } 54 55 public static final Kind KIND = new Kind("field-get", FIELD_GET); 56 57 public Kind getKind() { return KIND; } 58 59 public ASTObject getSourceLocation() { 60 return fieldGetExprPromise.getSourceLocation(); 61 } 62 63 public List makeArgsTypes() { return Collections.EMPTY_LIST; } 64 65 public Exprs makeArgsExprs() { 66 return getAST().makeExprs(); 67 } 68 69 public Type getTargetType() { 70 return fieldGetExprPromise.getTargetType(); 71 } 72 73 public Type getTargetExprType() { 74 if (fieldGetExprPromise.getFieldDec().isStatic()) return null; 75 return getTargetType(); 76 } 77 78 public Dec getTargetDec() { return getCalledFieldDec(); } 79 80 public FieldDec getCalledFieldDec() { 81 return fieldGetExprPromise.getFieldDec(); 82 } 83 84 public boolean canThrow(Type t) { return t.isUncheckedThrowable(); } 85 public Collection getPossibleCheckedExceptions() { 86 return Collections.EMPTY_LIST; 87 } 88 89 public Type getResultType() { 90 return getCalledFieldDec().getType(); 91 } 92 93 protected ASTObject makeInnerCall(Expr targetExpr, Exprs argsExprs) { 94 return getAST().makeGet(targetExpr, getCalledFieldDec()); 95 } 96 97 protected AnonymousMethodExpr makeSyntheticCall() { 98 final AST ast = getAST(); 99 FieldAccessExpr getExpr = fieldGetExprPromise.getFieldAccessExpr(); 100 return makeAnonMethodExpr(ast.makeFormals(), getExpr.getExpr(), 101 ast.makeExprs()); 102 } 103 104 protected void replaceExprWith(Expr newExpr) { 105 fieldGetExprPromise.getFieldAccessExpr().replaceWith(newExpr); 106 } 107 } 108 | Popular Tags |