1 24 25 package org.aspectj.compiler.crosscuts; 26 27 import org.aspectj.compiler.base.ast.*; 28 import org.aspectj.compiler.base.*; 29 30 import java.util.*; 31 32 33 public class MixinImplementationPass extends WalkerPass { 34 private TypeDec inTypeDec; 35 36 public MixinImplementationPass(JavaCompiler compiler) { 37 super(compiler); 38 } 39 40 public TypeDec getInTypeDec() { return inTypeDec; } 41 public void setInTypeDec(TypeDec typeDec) { inTypeDec = typeDec; } 42 43 public String getDisplayName() { 44 return "desugaring mixin methods"; 45 } 46 47 public Dec copyToClass(Dec dec, final TypeDec toClassDec) { 48 final Type toType = toClassDec.getType(); 49 final Type fromType = dec.getBytecodeTypeDec().getType(); 50 51 Walker w = new CopyWalker(getCompiler(), fromType, toType) { 53 public Expr makeThisExpr() { 54 return this.getAST().makeThis(this.toType); 55 } 56 }; 57 Dec newDec = (Dec)w.process(dec); 59 60 newDec.setBytecodeId(dec.getBytecodeId()); 61 newDec.setLexicalType(dec.getLexicalType()); 62 return newDec; 64 } 65 66 67 public ASTObject process(ASTObject object) { 68 object.implementMixin(this); 69 return object.postImplementMixin(this); 70 } 71 } 72 | Popular Tags |