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 FieldSetJp extends FieldGetJp { 36 public static interface FieldSetExprPromise extends FieldGetExprPromise { 37 38 public AssignExpr getAssignExpr(); 39 } 40 public FieldSetJp(FieldSetExprPromise fieldSetExprPromise, 41 JoinPoint enclosingJoinPoint) 42 { 43 super(fieldSetExprPromise, enclosingJoinPoint); 44 } 45 46 public static final Kind KIND = new Kind("field-set", FIELD_SET); 47 48 public Kind getKind() { return KIND; } 49 50 FormalDec newValueFormal = null; 52 public FormalDec getNewValueFormal() { 53 if (newValueFormal == null) { 54 newValueFormal = getAST().makeFormal(getResultType(), "newValue"); 55 } 56 return newValueFormal; 57 } 58 59 public Expr makeNewFieldValueExpr() { 61 return getAST().makeVar(getNewValueFormal()); 62 } 63 64 public Expr makeNewValueExpr() { 65 return getResultType().makeObject(getAST().makeVar(getNewValueFormal())); 66 } 67 68 public List makeArgsTypes() { 69 List ret = new ArrayList(); 70 ret.add(getResultType()); 71 return ret; 72 } 73 74 public Exprs makeArgsExprs() { 75 return getAST().makeExprs(makeNewFieldValueExpr()); 76 } 77 78 protected ASTObject makeInnerCall(Expr targetExpr, Exprs argsExprs) { 79 return getAST().makeSet(targetExpr, getCalledFieldDec(), argsExprs.get(0)); 80 } 81 82 protected AnonymousMethodExpr makeSyntheticCall() { 83 final AST ast = getAST(); 84 AssignExpr setExpr = 85 ((FieldSetExprPromise)fieldGetExprPromise).getAssignExpr(); 86 87 Expr newValue = ast.makeCast(getNewValueFormal().getType(), setExpr.getRhs()); 90 91 return makeAnonMethodExpr(ast.makeFormals(getNewValueFormal()), 92 ((FieldAccessExpr)setExpr.getLhs()).getExpr(), 93 ast.makeExprs(newValue)); 94 } 95 protected void replaceExprWith(Expr newExpr) { 96 ((FieldSetExprPromise)fieldGetExprPromise).getAssignExpr().replaceWith(newExpr); 97 } 98 } 99 | Popular Tags |